-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[shared-ux] Migrate redirect app links component #124197
Conversation
@elasticmachine merge upstream |
I pushed a change that adds useContainerRef as a prop to the inner component. But I would strongly advise against this inner component; I see little value in a component that's basically just a div, and it increases complexity. |
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.
@stacey-gammon The changes in packages/kbn-docs-utils/src/api_docs/tests/snapshots/
are triggering operations review, they look fine to me but you're probably the best one to make sure those are valid changes.
src/plugins/shared_ux/public/components/app_links/click_handler.ts
Outdated
Show resolved
Hide resolved
src/plugins/shared_ux/public/components/app_links/click_handler.ts
Outdated
Show resolved
Hide resolved
src/plugins/shared_ux/public/components/redirect_app_links/redirect_app_links.stories.tsx
Outdated
Show resolved
Hide resolved
src/plugins/shared_ux/public/components/redirect_app_links/redirect_app_links.tsx
Outdated
Show resolved
Hide resolved
src/plugins/shared_ux/public/components/redirect_app_links/utils.ts
Outdated
Show resolved
Hide resolved
src/plugins/shared_ux/public/components/redirect_app_links/redirect_app_links.tsx
Outdated
Show resolved
Hide resolved
navigateToUrl={() => Promise.resolve()} | ||
currentAppId$={new BehaviorSubject('test')} | ||
> | ||
<EuiButton data-test-subj="homeAddData" fill iconType="plusInCircle"> |
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.
Does this button not need an href
for the behavior to be picked up?
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.
Maybe there's also a way to output something so we can see that it is working? I think @majagrubic did something like that for the No Data Views component under Storybook's Action tab.
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.
Added an onClick handler in the story - let me know if this is what you meant. Thanks!
d1fd102
src/plugins/shared_ux/public/components/redirect_app_links/redirect_app_links.stories.tsx
Outdated
Show resolved
Hide resolved
src/plugins/shared_ux/public/components/redirect_app_links/redirect_app_links.stories.tsx
Outdated
Show resolved
Hide resolved
* | ||
* @example | ||
* ```tsx | ||
* <RedirectAppLinks application={application}> |
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.
@cchaos Publicly-exposed constructs require comments like this for the auto-generated API docs.
https://github.com/elastic/kibana/blob/main/api_docs/shared_u_x.devdocs.json
https://github.com/elastic/kibana/blob/main/api_docs/shared_u_x.mdx
Public APIs missing comments
Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.
import { createNavigateToUrlClickHandler } from './click_handler'; | ||
|
||
export interface RedirectAppLinksProps extends React.HTMLAttributes<HTMLDivElement> { | ||
navigateToUrl: ApplicationStart['navigateToUrl']; |
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.
I'm not going to block the PR, but we'll need to refactor this to not rely on other plugins or services, even core
. Feel free to add a TODO and assign it to me, as I'm working on this in the immediate term.
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.
I opened #127464 to track this thanks
import { ApplicationStart } from 'src/core/public'; | ||
import { createNavigateToUrlClickHandler } from './click_handler'; | ||
|
||
export interface RedirectAppLinksProps extends React.HTMLAttributes<HTMLDivElement> { |
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.
There's likely a better type for this, so data-test-subj
and className
would come along for free. I'll see what I can find.
Regardless, you could refactor this to be cleaner. Something like:
type Props = React.HTMLAttributes<HTMLDivElement> & Pick<ApplicationStart, 'navigateToUrl' | 'currentAppId$';
export interface RedirectAppLinksProps extends Props {
className?: string;
'data-test-subj'?: string;
}
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.
EUI provides these (and aria-label
) through CommonProps
if that's helpful
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.
Slightly cleaner now in dc63e36 thanks!
); | ||
|
||
return ( | ||
// eslint-disable-next-line jsx-a11y/click-events-have-key-events |
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.
Need a comment why this is necessary. @cchaos do you have any concerns about this?
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.
I always have concerns about adding onClick
behavior to typically non-interactive components, but it looks like this is just to intercept any child href
s. Other than that, I don't really know what this component is supposed to accomplish.
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.
src/plugins/shared_ux/public/components/redirect_app_links/utils.ts
Outdated
Show resolved
Hide resolved
container?: HTMLElement | ||
): HTMLAnchorElement | undefined => { | ||
let current = element; | ||
do { |
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.
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.
I prefer do...while
over while(true)
anytime.
…irect_app_links.mdx Co-authored-by: Caroline Horn <[email protected]>
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.
api doc snapshots look fine to me. The changes are unrelated to this PR, just looks like yarn jest
was ran locally, which due to a recent change, will update the date on these. Something to look into fixing, otherwise these two files will always have changes every time yarn jest
is run.
fill | ||
iconType="plusInCircle" | ||
onClick={action('button pressed')} | ||
/> |
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.
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.
Thank you~ 2d2ddc1 for changes and for below comment as well :face_palm:
* | ||
* @example | ||
* ```tsx | ||
* <RedirectAppLinks application={application}> |
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.
These comments still need updating as the example still shows needing application
/
src/plugins/shared_ux/public/components/redirect_app_links/redirect_app_links.stories.tsx
Outdated
Show resolved
Hide resolved
…irect_app_links.stories.tsx Co-authored-by: Caroline Horn <[email protected]>
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsasync chunk count
ESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Summary
This PR encompasses the migration of the redirect app link component into the shared_ux directory.
workspace_panel.tsx
in lensadd_data.tsx
in public/application/components/add_data/add_data.tsxmanage_data.tsx
in public/application/components/manage_data/manage_data.tsxrenderAppCard
and<KibanaPageTemplate />
inoverview.tsx
in plugins/kibana_overview/public/components/overview/overview.tsxactionAddData
inoverview_page_actions.tsx
in plugins/kibana_react/public/overview_page/overview_page_actions/overview_page_actions.tsxdefaultRouteButton
inoverview_page_footer.tsx
in plugins/kibana_react/public/overview_page/overview_page_footerElastic Agent Card
inelastic_agent_card.tsx
in kibana_react/public/page_template/no_data_page/no_data_cardSaved Object Edition page
insaved_objects_edition_page.tsx
in saved_objects_management/public/management_section/saved_objects_edition_page.tsxSaved Objects Table
insaved_objects_table.tsx
in plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsxgetTableColumns
inget_table_columns.tsx
in plugins/visualizations/public/visualize_app/utils/get_table_columns.tsxHomePage
inapp.tsx
test/plugin_functional/plugins/core_history_block/plubic/app.tsxexploratory_view_example
inmount.tsx
in x-pack/examples/exploratory_view_example/public/mount.tsxUXAppRoot
inux_app.tsx
in x-pack/plugins/apm/public/application/ux_app.tsxApmAppRoot
inapp_root.tsx
in x-pack/plugins/apm/public/components/routing/app_root.tsxgetColumns
inget_columns.tsx
in x-pack/plugins/data_enhanced/public/search/sessions_mgmt/lib/get_columns.tsxcreateConnectedSearchSessionIndicator
in connected_search_session_indicator.tsxFleetAppContext
in x-pack/plugins/fleet/public/applications/fleet/app.tsxAgentLogsUI
inagent_logs.tsx
in x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/agent_logs.tsxIntegrationsAppContext
inapp.tsx
in x-pack/plugins/fleet/public/applications/integrations/app.tsxCustomAssetsAccordion
incustom_assets_accordion.tsx
in x-pack/plugins/fleet/public/components/custom_assets_accordion.tsxTutorialDirectoryHeaderLink
intutorial_directory_header_link.tsx
x-pack/plugins/fleet/public/components/home_integration/tutorial_directory_header_link.tsxIndex Lifecycle Management
inindex.tsx
in x-pack/plugins/index_lifecycle_management/public/application/index.tsxInfrastructure Page
in index.tsx x-pack/plugins/infra/public/pages/metrics/index.tsxVisualizationWrapper
inworkspace_panel.tsx
x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsxCommonPageWrapper
inml_page.tsx
x-pack/plugins/ml/public/application/components/ml_page/ml_page.tsxJobs List Page
injobs_list_page.tsx
x-pack/plugins/ml/public/application/management/jobs_list/components/jobs_list_page/jobs_list_page.tsxObservability
inindex.tsx
x-pack/plugins/observability/public/application/index.tsxSpace Management App
in x-pack/plugins/spaces/public/management/spaces_management_app.tsxAppHandlingClusterUpgradeState
in x-pack/plugins/upgrade_assistant/public/application/app.tsxApplication
in x-pack/plugins/uptime/public/apps/uptime_app.tsxAlert Messages
in x-pack/plugins/uptime/public/lib/alert_types/alert_messages.tsxChecklist
Delete any items that are not applicable to this PR.
For maintainers