amaannawab923 commented on code in PR #45522: URL: https://github.com/apache/superset/pull/45522#discussion_r4389348102
########## superset-frontend/src/pages/ExtensionPage/index.tsx: ########## @@ -0,0 +1,105 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import { useEffect, useState } from 'react'; +import { useLocation } from 'react-router-dom'; +import { t } from '@apache-superset/core/translation'; +import { Loading } from '@superset-ui/core/components'; +import { findPageByPath, resolvePage, usePages } from 'src/core/pages'; +import ExtensionsLoader from 'src/extensions/ExtensionsLoader'; +import { ErrorAlert } from 'src/components/ErrorMessage/ErrorAlert'; + +/** + * Renders whichever extension page claims the current URL. + * + * Mounted on a catch-all route that every host route outranks, so this is + * reached only for a path the host itself does not serve. Whether an + * extension serves it can only be decided once extensions have finished + * loading, so until then this must not say "not found": the page may be + * moments away. + */ +export default function ExtensionPage() { Review Comment: Agreed, and we're taking the SIP's approach here rather than patching around it. Worth recording why it belongs with the route change: `derivePage` is a pure function of the pathname, and with author-chosen flat paths nothing about `/approvals` identifies it as an extension page — so it would have to consult the registered path set, which isn't known at module load (`navigation/index.ts` derives the initial value at import time, while declared pages arrive after the `userId` gate and a fetch). Under the host-owned `/extensions/pages/<pageId>` route it's one `PAGE_ROUTES` entry and the timing problem doesn't exist. Same entry keys the active-tab highlighting in your other comment. Two things we found while scoping it: - `'extension'` as a single union value can't distinguish one contributed page from another, or two pages of the same extension. Since the `navigation` namespace is deliberately payload-free by its own fileoverview, we'd keep `Page` a string union and add an accessor to the `pages` namespace, which already owns `ResolvedPage` and the subscribe machinery, for callers that need to know which page. - Adding the member looks safe to ship: there's no exhaustive `switch` or `Record<Page, …>` over `getPage()` anywhere in the repo, so it's an additive change here and compile-time only for a published consumer. Separately, and pre-existing: `'home'` doubles as the welcome surface and as the fallback for any route not enumerated, which is why a dashboard to extension-page transition fires a confident `'home'` — and why `/roles/`, `/theme/list/` and `/tasks/list/` report `'home'` today. Probably worth splitting regardless of this PR. Not in the push above; it lands with the route move. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
