Skip to content
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

Merged
merged 37 commits into from
Mar 14, 2022

Conversation

rshen91
Copy link
Contributor

@rshen91 rshen91 commented Feb 1, 2022

Summary

This PR encompasses the migration of the redirect app link component into the shared_ux directory.

  • Where the component is used currently:
    • workspace_panel.tsx in lens
    • add_data.tsx in public/application/components/add_data/add_data.tsx
    • manage_data.tsx in public/application/components/manage_data/manage_data.tsx
    • renderAppCard and <KibanaPageTemplate /> in overview.tsx in plugins/kibana_overview/public/components/overview/overview.tsx
    • actionAddData in overview_page_actions.tsx in plugins/kibana_react/public/overview_page/overview_page_actions/overview_page_actions.tsx
    • defaultRouteButton in overview_page_footer.tsx in plugins/kibana_react/public/overview_page/overview_page_footer
    • Elastic Agent Card in elastic_agent_card.tsx in kibana_react/public/page_template/no_data_page/no_data_card
    • Saved Object Edition page in saved_objects_edition_page.tsx in saved_objects_management/public/management_section/saved_objects_edition_page.tsx
    • Saved Objects Table in saved_objects_table.tsx in plugins/saved_objects_management/public/management_section/objects_table/saved_objects_table.tsx
    • getTableColumns in get_table_columns.tsx in plugins/visualizations/public/visualize_app/utils/get_table_columns.tsx
    • Tests --> HomePage in app.tsx test/plugin_functional/plugins/core_history_block/plubic/app.tsx
    • exploratory_view_example in mount.tsx in x-pack/examples/exploratory_view_example/public/mount.tsx
    • UXAppRoot in ux_app.tsx in x-pack/plugins/apm/public/application/ux_app.tsx
    • ApmAppRoot in app_root.tsx in x-pack/plugins/apm/public/components/routing/app_root.tsx
    • getColumns in get_columns.tsx in x-pack/plugins/data_enhanced/public/search/sessions_mgmt/lib/get_columns.tsx
    • createConnectedSearchSessionIndicator in connected_search_session_indicator.tsx
    • FleetAppContext in x-pack/plugins/fleet/public/applications/fleet/app.tsx
    • AgentLogsUI in agent_logs.tsx in x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_details_page/components/agent_logs/agent_logs.tsx
    • IntegrationsAppContext in app.tsx in x-pack/plugins/fleet/public/applications/integrations/app.tsx
    • CustomAssetsAccordion in custom_assets_accordion.tsx in x-pack/plugins/fleet/public/components/custom_assets_accordion.tsx
    • TutorialDirectoryHeaderLink in tutorial_directory_header_link.tsx x-pack/plugins/fleet/public/components/home_integration/tutorial_directory_header_link.tsx
    • Index Lifecycle Management in index.tsx in x-pack/plugins/index_lifecycle_management/public/application/index.tsx
    • Infrastructure Page in index.tsx x-pack/plugins/infra/public/pages/metrics/index.tsx
    • VisualizationWrapper in workspace_panel.tsx x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx
    • CommonPageWrapper in ml_page.tsx x-pack/plugins/ml/public/application/components/ml_page/ml_page.tsx
    • Jobs List Page in jobs_list_page.tsx x-pack/plugins/ml/public/application/management/jobs_list/components/jobs_list_page/jobs_list_page.tsx
    • Observability in index.tsx x-pack/plugins/observability/public/application/index.tsx
    • Space Management App in x-pack/plugins/spaces/public/management/spaces_management_app.tsx
    • AppHandlingClusterUpgradeState in x-pack/plugins/upgrade_assistant/public/application/app.tsx
    • Application in x-pack/plugins/uptime/public/apps/uptime_app.tsx
    • Alert Messages in x-pack/plugins/uptime/public/lib/alert_types/alert_messages.tsx

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@rshen91 rshen91 added loe:medium Medium Level of Effort backport:skip This commit does not require backporting Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) labels Feb 1, 2022
@rshen91
Copy link
Contributor Author

rshen91 commented Feb 3, 2022

@elasticmachine merge upstream

@majagrubic
Copy link
Contributor

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.
Another thing I noticed - the naming. The file is called redirect_app_link; the component itself is called RedirectAppLinkS. I understand this was taken from kibana_react, but since we're already refactoring the component, I suggest we make the naming consistent.

@rshen91 rshen91 marked this pull request as ready for review March 8, 2022 14:39
@rshen91 rshen91 requested a review from a team March 8, 2022 14:39
@rshen91 rshen91 requested a review from a team as a code owner March 8, 2022 14:39
@rshen91 rshen91 added v8.2.0 release_note:skip Skip the PR/issue when compiling release notes labels Mar 8, 2022
Copy link
Contributor

@spalger spalger left a 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.

navigateToUrl={() => Promise.resolve()}
currentAppId$={new BehaviorSubject('test')}
>
<EuiButton data-test-subj="homeAddData" fill iconType="plusInCircle">
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

*
* @example
* ```tsx
* <RedirectAppLinks application={application}>
Copy link
Contributor

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'];
Copy link
Contributor

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.

Copy link
Contributor Author

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> {
Copy link
Contributor

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;
}

Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor

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 hrefs. Other than that, I don't really know what this component is supposed to accomplish.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

container?: HTMLElement
): HTMLAnchorElement | undefined => {
let current = element;
do {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might not be entirely relevant, but it's something I think of whenever I see a do/while:

:-D It will probably make all of this code cleaner, too.

Copy link
Contributor

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.

Copy link
Contributor

@stacey-gammon stacey-gammon left a 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')}
/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The button still needs a label/text it just didn't need to be internationalized 😄
Screen Shot 2022-03-10 at 16 59 16 PM

Suggested change
/>
>Test link</EuiButton>

Copy link
Contributor Author

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}>
Copy link
Contributor

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/

@rshen91 rshen91 requested a review from cchaos March 14, 2022 01:56
@rshen91 rshen91 enabled auto-merge (squash) March 14, 2022 15:33
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
sharedUX 49 55 +6

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
sharedUX 100.7KB 102.1KB +1.5KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
sharedUX 4.8KB 4.9KB +49.0B
Unknown metric groups

async chunk count

id before after diff
sharedUX 4 5 +1

ESLint disabled in files

id before after diff
sharedUX 2 4 +2

ESLint disabled line counts

id before after diff
sharedUX 1 2 +1

Total ESLint disabled count

id before after diff
sharedUX 3 6 +3

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@rshen91 rshen91 merged commit 9d8f95f into elastic:main Mar 14, 2022
@rshen91 rshen91 deleted the migrate-app_links branch March 14, 2022 17:51
maksimkovalev pushed a commit to maksimkovalev/kibana that referenced this pull request Mar 18, 2022
@rshen91 rshen91 self-assigned this Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting loe:medium Medium Level of Effort release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) v8.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants