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:
parent
6cfe655421
commit
88b204f60c
@ -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() {
|
||||
|
||||
@ -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", () => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user