Skip to content

Commit

Permalink
HPCC-30535 ECL Watch allow v5 and v9 UI in different tabs
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Clements <[email protected]>
  • Loading branch information
jeclrsg committed Oct 25, 2023
1 parent 472e200 commit 424b323
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
2 changes: 1 addition & 1 deletion esp/src/eclwatch/stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ define([
const params = ioQuery.queryToObject(dojo.doc.location.search.substr((dojo.doc.location.search.substr(0, 1) === "?" ? 1 : 0)));
const hpccWidget = params.Widget ? params.Widget : "HPCCPlatformWidget";

const store = KeyValStore.userKeyValStore();
const store = KeyValStore.sessionKeyValStore();
store.getEx(BuildInfo.ModernMode, { defaultValue: String(true) }).then(modernMode => {
if (modernMode === String(true) && hpccWidget !== "IFrameWidget") {
switch (hpccWidget) {
Expand Down
7 changes: 3 additions & 4 deletions esp/src/src-react/components/Title.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import { cookie } from "dojo/main";

import nlsHPCC from "src/nlsHPCC";
import * as Utility from "src/Utility";
import { ModernMode } from "src/BuildInfo";

import { useBanner } from "../hooks/banner";
import { useECLWatchLogger } from "../hooks/logging";
import { useBuildInfo } from "../hooks/platform";
import { useGlobalStore, useUserStore } from "../hooks/store";
import { useBuildInfo, useModernMode } from "../hooks/platform";
import { useGlobalStore } from "../hooks/store";
import { useMyAccount, useUserSession } from "../hooks/user";
import { replaceUrl } from "../util/history";

Expand Down Expand Up @@ -71,7 +70,7 @@ export const DevTitle: React.FunctionComponent<DevTitleProps> = ({

const [log, logLastUpdated] = useECLWatchLogger();

const [_modernMode, setModernMode] = useUserStore(ModernMode, String(true));
const { setModernMode } = useModernMode();
const onTechPreviewClick = React.useCallback(
(ev?: React.MouseEvent<HTMLButtonElement>, item?: IContextualMenuItem): void => {
setModernMode(String(false));
Expand Down
6 changes: 2 additions & 4 deletions esp/src/src-react/components/controls/ComingSoon.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import * as React from "react";
import { IStyle, Toggle } from "@fluentui/react";
import nlsHPCC from "src/nlsHPCC";
import { ModernMode } from "src/BuildInfo";
import { useUserStore } from "../../hooks/store";
import { useBuildInfo } from "../../hooks/platform";
import { useBuildInfo, useModernMode } from "../../hooks/platform";

const legacyIndex = {};
const modernIndex = {};
Expand Down Expand Up @@ -75,7 +73,7 @@ export const ComingSoon: React.FunctionComponent<ComingSoon> = ({
}) => {

const [, { opsCategory }] = useBuildInfo();
const [modernMode, setModernMode] = useUserStore(ModernMode, String(defaultValue));
const { modernMode, setModernMode } = useModernMode();

React.useEffect(() => {
if (value !== undefined) {
Expand Down
28 changes: 27 additions & 1 deletion esp/src/src-react/hooks/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as React from "react";
import { scopedLogger } from "@hpcc-js/util";
import { Topology, TpLogicalClusterQuery } from "@hpcc-js/comms";
import { getBuildInfo, BuildInfo } from "src/Session";
import { cmake_build_type, containerized } from "src/BuildInfo";
import { cmake_build_type, containerized, ModernMode } from "src/BuildInfo";
import { sessionKeyValStore, userKeyValStore } from "src/KeyValStore";

const logger = scopedLogger("src-react/hooks/platform.ts");

Expand Down Expand Up @@ -66,3 +67,28 @@ export function useLogicalClusters(): [TpLogicalClusterQuery.TpLogicalCluster[]

return [targetClusters, defaultCluster];
}

export function useModernMode(): {
modernMode: string;
setModernMode: (value: string) => void;
} {
const userStore = userKeyValStore();
const sessionStore = sessionKeyValStore();

const modernMode = React.useRef(String(true));
const setModernMode = React.useCallback((value) => {
sessionStore.set(ModernMode, value);
userStore.set(ModernMode, value);
}, []);

Check warning on line 82 in esp/src/src-react/hooks/platform.ts

View workflow job for this annotation

GitHub Actions / Check eclwatch and npm (18)

React Hook React.useCallback has missing dependencies: 'sessionStore' and 'userStore'. Either include them or remove the dependency array

Check warning on line 82 in esp/src/src-react/hooks/platform.ts

View workflow job for this annotation

GitHub Actions / Check eclwatch and npm (16)

React Hook React.useCallback has missing dependencies: 'sessionStore' and 'userStore'. Either include them or remove the dependency array

React.useEffect(() => {
sessionStore.get(ModernMode).then(async value => {
modernMode.current = value;
if (!!modernMode) {
modernMode.current = await userStore.getEx(ModernMode, { defaultValue: String(true) });
}
});
}, []);

Check warning on line 91 in esp/src/src-react/hooks/platform.ts

View workflow job for this annotation

GitHub Actions / Check eclwatch and npm (18)

React Hook React.useEffect has missing dependencies: 'sessionStore' and 'userStore'. Either include them or remove the dependency array

Check warning on line 91 in esp/src/src-react/hooks/platform.ts

View workflow job for this annotation

GitHub Actions / Check eclwatch and npm (16)

React Hook React.useEffect has missing dependencies: 'sessionStore' and 'userStore'. Either include them or remove the dependency array

return { modernMode: modernMode.current, setModernMode };
}
4 changes: 2 additions & 2 deletions esp/src/src-react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";
import * as ReactDOM from "react-dom";
import { initializeIcons } from "@fluentui/react";
import { scopedLogger } from "@hpcc-js/util";
import { cookieKeyValStore, userKeyValStore } from "src/KeyValStore";
import { cookieKeyValStore, sessionKeyValStore } from "src/KeyValStore";
import { ModernMode } from "src/BuildInfo";
import { ECLWatchLogger } from "./hooks/logging";

Expand Down Expand Up @@ -31,7 +31,7 @@ dojoConfig.urlInfo = {
};
dojoConfig.disableLegacyHashing = true;

const store = userKeyValStore();
const store = sessionKeyValStore();
store.getEx(ModernMode, { defaultValue: String(true) }).then(async modernMode => {
if (modernMode === String(false)) {
window.location.replace("/esp/files/stub.htm");
Expand Down

0 comments on commit 424b323

Please sign in to comment.