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 "./preferences.scss";
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { computed, observable } from "mobx";
|
import { computed, observable, reaction } from "mobx";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
|
|
||||||
import { userStore } from "../../../common/user-store";
|
import { userStore } from "../../../common/user-store";
|
||||||
@ -31,9 +31,12 @@ export class Preferences extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { hash } = navigation.location;
|
reaction(() => navigation.location.hash, hash => {
|
||||||
|
document.getElementById(hash.slice(1))?.scrollIntoView();
|
||||||
document.getElementById(hash.slice(1))?.scrollIntoView();
|
navigation.location.hash = "";
|
||||||
|
}, {
|
||||||
|
fireImmediately: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
@ -15,11 +15,19 @@ export function bindProtocolAddRouteHandlers() {
|
|||||||
.addInternalHandler("/preferences", ({ search: { highlight }}) => {
|
.addInternalHandler("/preferences", ({ search: { highlight }}) => {
|
||||||
navigate(preferencesURL({ fragment: highlight }));
|
navigate(preferencesURL({ fragment: highlight }));
|
||||||
})
|
})
|
||||||
|
.addInternalHandler("/", () => {
|
||||||
|
navigate(landingURL());
|
||||||
|
})
|
||||||
.addInternalHandler("/landing", () => {
|
.addInternalHandler("/landing", () => {
|
||||||
navigate(landingURL());
|
navigate(landingURL());
|
||||||
})
|
})
|
||||||
.addInternalHandler("/", () => {
|
.addInternalHandler("/landing/:workspaceId", ({ pathname: { workspaceId } }) => {
|
||||||
navigate(landingURL());
|
if (workspaceStore.getById(workspaceId)) {
|
||||||
|
workspaceStore.setActive(workspaceId);
|
||||||
|
navigate(landingURL());
|
||||||
|
} else {
|
||||||
|
console.log("[APP-HANDLER]: workspace with given ID does not exist", { workspaceId });
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.addInternalHandler("/cluster", () => {
|
.addInternalHandler("/cluster", () => {
|
||||||
navigate(addClusterURL());
|
navigate(addClusterURL());
|
||||||
@ -30,6 +38,8 @@ export function bindProtocolAddRouteHandlers() {
|
|||||||
if (cluster) {
|
if (cluster) {
|
||||||
workspaceStore.setActive(cluster.workspace);
|
workspaceStore.setActive(cluster.workspace);
|
||||||
navigate(clusterViewURL({ params: { clusterId } }));
|
navigate(clusterViewURL({ params: { clusterId } }));
|
||||||
|
} else {
|
||||||
|
console.log("[APP-HANDLER]: cluster with given ID does not exist", { clusterId });
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.addInternalHandler("/cluster/:clusterId/settings", ({ pathname: { clusterId } }) => {
|
.addInternalHandler("/cluster/:clusterId/settings", ({ pathname: { clusterId } }) => {
|
||||||
@ -38,6 +48,8 @@ export function bindProtocolAddRouteHandlers() {
|
|||||||
if (cluster) {
|
if (cluster) {
|
||||||
workspaceStore.setActive(cluster.workspace);
|
workspaceStore.setActive(cluster.workspace);
|
||||||
navigate(clusterSettingsURL({ params: { clusterId } }));
|
navigate(clusterSettingsURL({ params: { clusterId } }));
|
||||||
|
} else {
|
||||||
|
console.log("[APP-HANDLER]: cluster with given ID does not exist", { clusterId });
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.addInternalHandler("/extensions", () => {
|
.addInternalHandler("/extensions", () => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user