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

[Dashboard De-Angular] Render a custom routing error message when route does not exist #4596

Open
Tracked by #3365
abbyhu2000 opened this issue Jul 19, 2023 · 5 comments
Labels
dashboards needs more info Requires more information from poster

Comments

@abbyhu2000
Copy link
Member

abbyhu2000 commented Jul 19, 2023

Current behavior:

  • when route does not exist, auto navigating to overview page

We can render some custom routing error message like how visualize plugin handles it.

@abbyhu2000 abbyhu2000 changed the title Dashboard no match page: we can also render a custom routing error message like the visualize plugin instead of just auto navigating to overview page [Dashboard De-Angular] Render a custom routing error message when route does not exist Jul 19, 2023
@abbyhu2000 abbyhu2000 added the good first issue Good for newcomers label Sep 26, 2023
@shawnkchan
Copy link

Hey there, I would like to be assigned to this issue. May I know more about the task?

@joshuarrrr
Copy link
Member

@abbyhu2000 Can you provide some code links here?

@ashwin-pc
Copy link
Member

@kgcreative Whats your take on this? It looks like each app is creating their own way of handling page/route not found. I think we should have a common 404 page that behaves identically instead of relyingon each plugin to create their own 404 page

@ashwin-pc ashwin-pc added needs more info Requires more information from poster dashboards and removed good first issue Good for newcomers labels Oct 11, 2023
@abbyhu2000
Copy link
Member Author

yea this was a proposal when i was de-angularizing dashboard.

  • Currently, visualize plugin render the below page when the route does not exist:
Screenshot 2023-10-11 at 2 04 49 PM
  • However, when i configure the routing for dashboard plugin, since it previously did not have a error page so when the routing is invalid or not found, i just route the page to the overview page.

src/plugins/dashboard/public/application/app.tsx:

export const DashboardApp = () => {
  return (
    <Switch>
      <Route path={[DashboardConstants.CREATE_NEW_DASHBOARD_URL, createDashboardEditUrl(':id')]}>
        <div className="app-container dshAppContainer">
          <DashboardEditor />
          <div id="dashboardViewport" />
        </div>
      </Route>
      <Route exact path={['/', DashboardConstants.LANDING_PAGE_PATH]}>
        <DashboardListing />
      </Route>
      <DashboardNoMatch />
    </Switch>
  );
};

src/plugins/dashboard/public/application/components/dashboard_no_match.tsx:

/*
 * Copyright OpenSearch Contributors
 * SPDX-License-Identifier: Apache-2.0
 */

import { useEffect } from 'react';
import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public';
import { DashboardServices } from '../../types';

export const DashboardNoMatch = () => {
  const { services } = useOpenSearchDashboards<DashboardServices>();
  useEffect(() => {
    const path = window.location.hash.substring(1);
    services.restorePreviousUrl();

    const { navigated } = services.navigateToLegacyOpenSearchDashboardsUrl(path);
    if (!navigated) {
      services.navigateToDefaultApp();
    }
  }, [services]);

  return null;
};

Before implementing this, can we confirm that we want to add such an error page for the dashboard plugin? @kgcreative @KrooshalUX

@kgcreative
Copy link
Member

@kgcreative Whats your take on this? It looks like each app is creating their own way of handling page/route not found. I think we should have a common 404 page that behaves identically instead of relyingon each plugin to create their own 404 page

We should create a 404 page template in OUI that all plugins should leverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dashboards needs more info Requires more information from poster
Projects
None yet
Development

No branches or pull requests

5 participants