EnxDev commented on code in PR #44101:
URL: https://github.com/apache/superset/pull/44101#discussion_r4431273361


##########
superset-frontend/src/features/home/RightMenu.tsx:
##########
@@ -521,6 +527,41 @@ const RightMenu = ({
         }
       });
 
+      const extensionSettingsItems = (settingsMenuExtension?.primary ?? [])
+        .map(menuItem => {
+          const command = commands.getCommand(menuItem.command);
+          if (!command) {
+            return null;
+          }
+          return {
+            key: `extension:${command.id}`,
+            label: command.title,
+            title: command.description,
+            onClick: () => {
+              Promise.resolve(commands.executeCommand(command.id)).catch(

Review Comment:
   Nothing covers this catch yet: the Settings test only clicks a command that 
succeeds.
   
   Mind adding a case where the callback throws and asserting the error toast 
shows up?



##########
superset-frontend/src/pages/ExtensionView/index.tsx:
##########
@@ -0,0 +1,113 @@
+/**
+ * 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 { useParams } from 'react-router-dom';
+import { t } from '@apache-superset/core/translation';
+import { Loading } from '@superset-ui/core/components';
+import SubMenu, { SubMenuProps } from 'src/features/home/SubMenu';
+import ExtensionsLoader from 'src/extensions/ExtensionsLoader';
+import { useRegisteredView, useResolveView } from 'src/core/views';
+
+/**
+ * Generic full-page host for a single extension-registered view, reached at
+ * `/extensions/view/:viewId+`. Extensions cannot render their own views
+ * directly (`resolveView`/`useResolveView` are host-internal, not part of
+ * the public `@apache-superset/core` SDK) -- they register a view at
+ * `GlobalLocations.settings.panel` and a matching command at
+ * `GlobalLocations.settings.menu` whose callback navigates here, and the
+ * host resolves and renders it.
+ *
+ * Uses the reactive `useResolveView`, not the plain `resolveView`: this
+ * page is reachable by a direct/full navigation (a bookmark, a page
+ * refresh, or an extension's own menu command falling back to
+ * `window.location.assign` in the absence of an SDK-level SPA-navigation
+ * primitive), and the providing extension's own code loads asynchronously
+ * -- a non-reactive resolve would permanently commit to the "could not be
+ * loaded" placeholder from before that load finishes. Until the extension
+ * loader settles, an unregistered id shows a loading state rather than
+ * that placeholder, so a slow load and a wrong id look different.
+ */
+
+/**
+ * The router's `history` (v4) runs `decodeURI` on the pathname before
+ * `useParams` sees it. That pass decodes everything except the URI's
+ * reserved characters, so an id navigated to via `encodeURIComponent`
+ * arrives with `%2F` (and friends) still escaped but every other sequence,
+ * including a literal `%` sent as `%25`, already decoded. A second full
+ * `decodeURIComponent` would throw on an id that legitimately contains
+ * `%`, so only the reserved-character escapes that first pass leaves
+ * behind are decoded here.
+ */
+const RESERVED_CHARACTER_ESCAPES = /%(2F|3A|40|26|3D|2B|24|2C|3B|3F|23)/gi;

Review Comment:
   The reply on Joe's thread says `my-ext/literal%2Fname` round-trips, but it 
still doesn't at this head: `encodeURIComponent` sends `%252F`, history's 
`decodeURI` makes it `%2F`, and this regex makes it `/`, so the page looks up 
`my-ext/literal/name`.
   
   `useParams` can't tell those apart anymore, so the fix probably means 
decoding the raw `window.location.pathname` once, or narrowing the "including 
ids that contain `%`" line in settings.md. A test with that id would pin it 
either way.



-- 
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]

Reply via email to