-
Notifications
You must be signed in to change notification settings - Fork 7
feat: react router v6 #1013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: react router v6 #1013
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
edfebe1
Merge branch 'feat/react-18' of https://github.com/devtron-labs/devtr…
arunjaindev 4ce95e3
feat: migrate react-router to v6
arunjaindev 6d7705a
feat: update dependencies in package-lock.json
arunjaindev b93feca
feat: implement Automation Enablement Icon and update related components
arunjaindev 153cd03
feat: improve usePrompt logic
arunjaindev ee4d70c
fix: empty logs due to react batching
arunjaindev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,18 +15,18 @@ | |
| */ | ||
|
|
||
| import React, { useMemo, useEffect } from 'react' | ||
| import { Link, useRouteMatch, useParams } from 'react-router-dom' | ||
| import { generatePath, Link, useParams } from 'react-router-dom' | ||
| import { useBreadcrumbContext, getBreadCrumbSeparator } from './BreadcrumbStore' | ||
| import { ConditionalWrap } from '../Helper' | ||
| import { Breadcrumb, Breadcrumbs, UseBreadcrumbOptionalProps, UseBreadcrumbState } from './Types' | ||
|
|
||
| export const BreadcrumbContext = React.createContext(null) | ||
|
|
||
| export function useBreadcrumb(props?: UseBreadcrumbOptionalProps, deps?: any[]): UseBreadcrumbState { | ||
| export function useBreadcrumb(pathPattern: string, props?: UseBreadcrumbOptionalProps, deps?: any[]): UseBreadcrumbState { | ||
| const sep = props?.sep || '/' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we make params obj? |
||
| deps = deps || [] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you check if deps need to be memoized? |
||
| const { url, path } = useRouteMatch() | ||
| const params = useParams() | ||
| const url = generatePath(pathPattern, params) | ||
| const { state, setState } = useBreadcrumbContext() | ||
|
|
||
| useEffect(() => { | ||
|
|
@@ -48,7 +48,7 @@ export function useBreadcrumb(props?: UseBreadcrumbOptionalProps, deps?: any[]): | |
| } | ||
|
|
||
| const levels: Breadcrumb[] = useMemo(() => { | ||
| const paths = path.split('/').filter(Boolean) | ||
| const paths = pathPattern.split('/').filter(Boolean) | ||
| const urls = url.split('/').filter(Boolean) | ||
| return paths.map((path, idx) => { | ||
| const crumb: Breadcrumb = { to: urls[idx], name: path } | ||
|
|
@@ -57,7 +57,7 @@ export function useBreadcrumb(props?: UseBreadcrumbOptionalProps, deps?: any[]): | |
| } | ||
| return crumb | ||
| }) | ||
| }, [path, url]) | ||
| }, [pathPattern, url]) | ||
| const { res: breadcrumbs } = useMemo( | ||
| () => | ||
| levels.reduce( | ||
|
|
@@ -89,10 +89,12 @@ export function useBreadcrumb(props?: UseBreadcrumbOptionalProps, deps?: any[]): | |
|
|
||
| export const BreadCrumb: React.FC<Breadcrumbs> = ({ | ||
| breadcrumbs, | ||
| path, | ||
|
arunjaindev marked this conversation as resolved.
|
||
| sep = '/', | ||
| className = 'dc__devtron-breadcrumb__item fs-16 fw-4 lh-1-5 dc__ellipsis-right dc__mxw-155', | ||
| }) => { | ||
| const { url } = useRouteMatch() | ||
| const params = useParams() | ||
| const url = generatePath(path, params) | ||
| const filteredCrumbs = breadcrumbs.filter((crumb) => !!crumb.name) | ||
| return ( | ||
| <> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.