mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
PageRegistration / PageMenuRegistration fixes & more simplification (#1386)
* PageRegistration & PageMenuRegistration fixes & more simplification, fix #1383 Signed-off-by: Roman <ixrock@gmail.com> * clean up test, deprecate page.routePath Signed-off-by: Roman <ixrock@gmail.com> * fix: proper `isActive` state matching for page-menu-target to page considering current document location Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
1 parent
596e60a6f3
commit
13dbdac2f2
12 files changed
+147
-93
No files matched your search
@@ -14,7 +14,7 @@ import { ClusterIcon } from "../cluster-icon";
|
||||
import { Icon } from "../icon";
|
||||
import { autobind, cssNames, IClassName } from "../../utils";
|
||||
import { Badge } from "../badge";
|
||||
import { isActiveRoute, navigate } from "../../navigation";
|
||||
import { navigate, navigation } from "../../navigation";
|
||||
import { addClusterURL } from "../+add-cluster";
|
||||
import { clusterSettingsURL } from "../+cluster-settings";
|
||||
import { landingURL } from "../+landing-page";
|
||||
@@ -22,8 +22,7 @@ import { Tooltip } from "../tooltip";
|
||||
import { ConfirmDialog } from "../confirm-dialog";
|
||||
import { clusterIpc } from "../../../common/cluster-ipc";
|
||||
import { clusterViewURL } from "./cluster-view.route";
|
||||
import { globalPageMenuRegistry, globalPageRegistry } from "../../../extensions/registries";
|
||||
import { compile } from "path-to-regexp";
|
||||
import { getExtensionPageUrl, globalPageMenuRegistry, globalPageRegistry } from "../../../extensions/registries";
|
||||
|
||||
interface Props {
|
||||
className?: IClassName;
|
||||
@@ -152,13 +151,15 @@ export class ClustersMenu extends React.Component<Props> {
|
||||
{globalPageMenuRegistry.getItems().map(({ title, target, components: { Icon } }) => {
|
||||
const registeredPage = globalPageRegistry.getByPageMenuTarget(target);
|
||||
if (!registeredPage) return;
|
||||
const { routePath, exact } = registeredPage;
|
||||
const { extensionId, id: pageId } = registeredPage;
|
||||
const pageUrl = getExtensionPageUrl({ extensionId, pageId, params: target.params });
|
||||
const isActive = pageUrl === navigation.location.pathname;
|
||||
return (
|
||||
<Icon
|
||||
key={routePath}
|
||||
key={pageUrl}
|
||||
tooltip={title}
|
||||
active={isActiveRoute({ path: routePath, exact })}
|
||||
onClick={() => navigate(compile(routePath)(target.params))}
|
||||
active={isActive}
|
||||
onClick={() => navigate(pageUrl)}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
|
||||
Reference in new issue
Block a user