1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

fix preferences not scrolling when already open, clarify routes

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-03-16 15:39:18 -04:00
parent 6cfe655421
commit 88b204f60c
2 changed files with 21 additions and 6 deletions

View File

@ -1,7 +1,7 @@
import "./preferences.scss";
import React from "react";
import { computed, observable } from "mobx";
import { computed, observable, reaction } from "mobx";
import { observer } from "mobx-react";
import { userStore } from "../../../common/user-store";
@ -31,9 +31,12 @@ export class Preferences extends React.Component {
}
componentDidMount() {
const { hash } = navigation.location;
document.getElementById(hash.slice(1))?.scrollIntoView();
reaction(() => navigation.location.hash, hash => {
document.getElementById(hash.slice(1))?.scrollIntoView();
navigation.location.hash = "";
}, {
fireImmediately: true
});
}
render() {

View File

@ -15,11 +15,19 @@ export function bindProtocolAddRouteHandlers() {
.addInternalHandler("/preferences", ({ search: { highlight }}) => {
navigate(preferencesURL({ fragment: highlight }));
})
.addInternalHandler("/", () => {
navigate(landingURL());
})
.addInternalHandler("/landing", () => {
navigate(landingURL());
})
.addInternalHandler("/", () => {
navigate(landingURL());
.addInternalHandler("/landing/:workspaceId", ({ pathname: { workspaceId } }) => {
if (workspaceStore.getById(workspaceId)) {
workspaceStore.setActive(workspaceId);
navigate(landingURL());
} else {
console.log("[APP-HANDLER]: workspace with given ID does not exist", { workspaceId });
}
})
.addInternalHandler("/cluster", () => {
navigate(addClusterURL());
@ -30,6 +38,8 @@ export function bindProtocolAddRouteHandlers() {
if (cluster) {
workspaceStore.setActive(cluster.workspace);
navigate(clusterViewURL({ params: { clusterId } }));
} else {
console.log("[APP-HANDLER]: cluster with given ID does not exist", { clusterId });
}
})
.addInternalHandler("/cluster/:clusterId/settings", ({ pathname: { clusterId } }) => {
@ -38,6 +48,8 @@ export function bindProtocolAddRouteHandlers() {
if (cluster) {
workspaceStore.setActive(cluster.workspace);
navigate(clusterSettingsURL({ params: { clusterId } }));
} else {
console.log("[APP-HANDLER]: cluster with given ID does not exist", { clusterId });
}
})
.addInternalHandler("/extensions", () => {