-
Notifications
You must be signed in to change notification settings - Fork 49
fix(components): LinkToExternal
retake
#2867
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
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
66e7ecb
fix(components): `LinkToExtrnal` & make `ember-engines` optional
aklkv 002c7f1
fix(components): convert common code to the new `hdsResolveLinkToCompβ¦
aklkv 19d3400
fix(components): move to utils folder
aklkv cd0774e
fix: initialize the value in constructor as it is derived from `args`
aklkv 1981591
feat(components): add changeset entry
aklkv 779e0cd
fix: remove extension
aklkv c2be5fe
fix(components): use dynamic import approach
aklkv 72c553e
fix: percy
aklkv 49fe382
fix(components): only resolve `linkToExternal` when itβs needed
aklkv daac299
Update packages/components/src/components/hds/breadcrumb/item.ts
aklkv 6a6e7ee
Update packages/components/src/components/hds/interactive/index.ts
aklkv 853129d
Update packages/components/src/components/hds/interactive/index.ts
aklkv 28fd26f
Update packages/components/src/components/hds/interactive/index.ts
aklkv 129d856
fix(components): rename utility function
aklkv 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@hashicorp/design-system-components': patch | ||
--- | ||
|
||
Introduce the `hds-resolve-link-to-component` utility to correctly resolve the LinkTo component when `@isRouteExternal` is set on `HdsBreadcrumbItem` or `HdsInteractive`. Consumers are now required to install `ember-engines` when `@isRouteExternal` is `true`. | ||
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
31 changes: 31 additions & 0 deletions
31
packages/components/src/utils/hds-resolve-link-to-external.ts
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,31 @@ | ||
import { LinkTo } from '@ember/routing'; | ||
import { assert } from '@ember/debug'; | ||
|
||
/** | ||
* Resolves the correct component to use for the `LinkTo`. | ||
* | ||
* @param isRouteExternal - If true, will return the `LinkToExternal` component. If `ember-engines` is not installed, an assertion will be thrown. | ||
* @returns A promise resolving to the correct component to use for the `LinkTo`. | ||
*/ | ||
export async function hdsResolveLinkToExternal( | ||
isRouteExternal?: boolean | ||
): Promise<typeof LinkTo> { | ||
if (isRouteExternal) { | ||
try { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const mod = await import( | ||
// @ts-expect-error: we list this as optional peer dependency | ||
'ember-engines/components/link-to-external-component' | ||
); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
return mod.default as typeof LinkTo; | ||
} catch { | ||
assert( | ||
`@isRouteExternal is only available when using the "ember-engines" addon. Please install it to use this feature.`, | ||
false | ||
); | ||
} | ||
} | ||
|
||
return LinkTo; | ||
} |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import '@glint/environment-ember-loose'; | ||
import '@glint/environment-ember-template-imports'; | ||
|
||
import { LinkTo } from '@ember/routing'; | ||
import { Portal, PortalTarget } from 'ember-stargate'; | ||
|
||
import type HdsComponentsRegistry from '../src/template-registry'; | ||
|
@@ -25,7 +24,6 @@ declare module '@glint/environment-ember-loose/registry' { | |
RenderModifiersRegistry, | ||
EmbroiderUtilRegistry /*, other addon registries */ { | ||
// local entries | ||
LinkToExternal: typeof LinkTo; | ||
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. [praise] Great that you remembered to remove it :) |
||
Portal: typeof Portal; | ||
PortalTarget: typeof PortalTarget; | ||
'sort-by': HelperLike<{ | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for @alex-ju: does this works with the automated script for release notes generation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script currently only picks up changelog entries written in this format: