-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[ENG - 506] Add support for custom links in the left sidebar #16472
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
Open
yash-learner
wants to merge
11
commits into
develop
Choose a base branch
from
ENG-506-support-for-inserting-links-in-left-nav
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2046720
feat: add support for custom links in the left sidebar
yash-learner 6ed9db9
Address copilot review comments
yash-learner 13f123e
Address copilot review comments
yash-learner 3cc5d7f
Merge branch 'develop' into ENG-506-support-for-inserting-links-in-le…
yash-learner 29583b8
Address https://github.com/ohcnetwork/care_fe/pull/16472#discussion_r…
yash-learner 38a5ad5
Merge branch 'ENG-506-support-for-inserting-links-in-left-nav' of htt…
yash-learner 0b9d477
Address https://github.com/ohcnetwork/care_fe/pull/16472#discussion_r…
yash-learner b0dedca
Remove unnecessary external prop
yash-learner 41e1672
Address https://github.com/ohcnetwork/care_fe/pull/16472#discussion_r…
yash-learner 8a17625
Merge branch 'develop' into ENG-506-support-for-inserting-links-in-le…
nihal467 a2cb0ce
Merge branch 'develop' into ENG-506-support-for-inserting-links-in-le…
abhimanyurajeesh 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
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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /** | ||
| * URL-safety predicates. | ||
| * | ||
| * This module is intentionally dependency-free so it can be reused by both the | ||
| * app runtime and build-time scripts (e.g. scripts/validate-env.ts) without | ||
| * pulling in the heavier @/Utils/utils dependency graph. | ||
| */ | ||
|
|
||
| /** | ||
| * Checks whether a URL is a safe external link. | ||
| * Only absolute http(s) URLs are allowed; anything else (e.g. javascript:, | ||
| * data:) is rejected to avoid script injection via configuration. | ||
| */ | ||
| export const isSafeExternalUrl = (url: string): boolean => { | ||
| try { | ||
| const protocol = new URL(url).protocol; | ||
| return protocol === "http:" || protocol === "https:"; | ||
| } catch { | ||
| return false; | ||
| } | ||
| }; | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * Checks whether a URL is an internal app path ("/..." but not a | ||
| * protocol-relative "//..." URL, which resolves to an external origin). | ||
| */ | ||
| export const isInternalNavPath = (url: string): boolean => | ||
| url.startsWith("/") && !url.startsWith("//"); | ||
|
|
||
| /** | ||
| * Checks whether a URL is safe to render as an anchor-based nav link. | ||
| * Allows internal app paths ("/..." but not protocol-relative "//...") and | ||
| * absolute http(s) URLs; rejects javascript:, data:, and other schemes. | ||
| */ | ||
| export const isSafeNavUrl = (url: string): boolean => | ||
| isInternalNavPath(url) || isSafeExternalUrl(url); | ||
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 |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { NavMain } from "@/components/ui/sidebar/nav-main"; | ||
|
|
||
| import { useCustomNavLinks } from "@/hooks/useCustomNavLinks"; | ||
|
|
||
| import type { NavScope } from "@/types/nav/customNavLink"; | ||
|
|
||
| /** | ||
| * Renders configuration- and plugin-provided custom links for the given sidebar | ||
| * scope. Returns nothing when no links apply, so it is safe to mount in every | ||
| * sidebar context. | ||
| */ | ||
| export function CustomNavLinks({ scope }: { scope: NavScope }) { | ||
| const links = useCustomNavLinks(scope); | ||
|
|
||
| if (links.length === 0) { | ||
| return null; | ||
| } | ||
|
|
||
| return <NavMain links={links} />; | ||
| } |
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.
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.