Skip to content

Commit

Permalink
Merge pull request #35 from ScottLogic/feature/VUU-33-Layout-Manager-…
Browse files Browse the repository at this point in the history
…Context

VUU-33 add context for layouts
  • Loading branch information
vferraro-scottlogic authored Sep 6, 2023
2 parents 5c5fc6c + 82f0107 commit f7ceec0
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 100 deletions.
1 change: 1 addition & 0 deletions vuu-ui/packages/vuu-filters/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from "./filter-bar";
export * from "./filter-clause";
export * from "./filter-input";
export * from "./filter-utils";
export * from "./local-config";
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
padding: 8px 0px;
align-self: stretch;
flex: 1 1 auto;
cursor: pointer;
}

.vuuLayoutList-layoutName {
Expand Down
18 changes: 14 additions & 4 deletions vuu-ui/packages/vuu-shell/src/layout-management/LayoutList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { HTMLAttributes } from 'react';
import { List } from '@finos/vuu-ui-controls';
import { LayoutMetadata } from './layoutTypes';
import { useLayoutManager } from './useLayoutManager';

import './LayoutList.css'

Expand All @@ -10,10 +11,18 @@ type LayoutGroups = {

const classBase = "vuuLayoutList";

export const LayoutsList = (props: { layouts: LayoutMetadata[] } & HTMLAttributes<HTMLDivElement>) => {
const { layouts, ...otherProps } = props;
export const LayoutsList = (props: HTMLAttributes<HTMLDivElement>) => {
const { layouts } = useLayoutManager();

const layoutsByGroup = layouts.reduce((acc: LayoutGroups, cur) => {
const layoutMetadata = layouts.map(layout => layout.metadata)

const handleLoadLayout = (layoutId?: string) => {
// TODO load layout
console.log("loading layout with id", layoutId)
console.log("json:", layouts.find(layout => layout.metadata.id === layoutId))
}

const layoutsByGroup = layoutMetadata.reduce((acc: LayoutGroups, cur) => {
if (acc[cur.group]) {
return {
...acc,
Expand All @@ -27,7 +36,7 @@ export const LayoutsList = (props: { layouts: LayoutMetadata[] } & HTMLAttribute
}, {})

return (
<div className={classBase} {...otherProps}>
<div className={classBase} {...props}>
<div className={`${classBase}-header`}>My Layouts</div>
<List<[string, LayoutMetadata[]]>
height='fit-content'
Expand All @@ -41,6 +50,7 @@ export const LayoutsList = (props: { layouts: LayoutMetadata[] } & HTMLAttribute
<div
className={`${classBase}-layoutContainer`}
key={layout?.id}
onClick={() => handleLoadLayout(layout?.id)}
>
<img className={`${classBase}-screenshot`} src={layout?.screenshot} />
<div>
Expand Down
44 changes: 34 additions & 10 deletions vuu-ui/packages/vuu-shell/src/layout-management/SaveLayoutPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ChangeEvent, useState } from "react";
import { ChangeEvent, useEffect, useState } from "react";
import { Input, Button, FormField, FormFieldLabel, Text } from "@salt-ds/core";
import { ComboBox, Checkbox, RadioButton, RadioIcon } from "@finos/vuu-ui-controls";
import { ComboBox, Checkbox, RadioButton } from "@finos/vuu-ui-controls";
import { formatDate, takeScreenshot } from "@finos/vuu-utils";
import { LayoutMetadata } from "./layoutTypes";

import "./SaveLayoutPanel.css";

Expand Down Expand Up @@ -30,17 +32,36 @@ type RadioValue = typeof radioValues[number];

type SaveLayoutPanelProps = {
onCancel: () => void;
onSave: (layoutName: string, group: string, checkValues: string[], radioValue: string) => void;
screenshot: string | undefined;
onSave: (layoutMetadata: Omit<LayoutMetadata, "id">) => void;
componentId?: string
};

export const SaveLayoutPanel = (props: SaveLayoutPanelProps) => {
const { onCancel, onSave, screenshot } = props;
const { onCancel, onSave, componentId } = props;

const [layoutName, setLayoutName] = useState<string>("");
const [group, setGroup] = useState<string>("");
const [checkValues, setCheckValues] = useState<string[]>([]);
const [radioValue, setRadioValue] = useState<RadioValue>(radioValues[0]);
const [screenshot, setScreenshot] = useState<string | undefined>();

useEffect(() => {
if (componentId) {
takeScreenshot(document.getElementById(componentId) as HTMLElement).then(screenshot =>
setScreenshot(screenshot)
)
}
}, [])

const handleSubmit = () => {
onSave({
name: layoutName,
group,
screenshot: screenshot ?? "",
user: "User",
date: formatDate(new Date(), "dd.mm.yyyy")
})
}

return (
<div className={`${classBase}-panelContainer`}>
Expand Down Expand Up @@ -118,14 +139,17 @@ export const SaveLayoutPanel = (props: SaveLayoutPanelProps) => {
</div>
</div>
<div className={`${classBase}-buttonsContainer`}>
<Button className={`${classBase}-cancelButton`} onClick={onCancel}>
Cancel
<Button
className={`${classBase}-cancelButton`}
onClick={onCancel}
>Cancel
</Button>
<Button
className={`${classBase}-saveButton`}
onClick={() => onSave(layoutName, group, checkValues, radioValue)}
disabled={layoutName === "" || group === ""}>
Save
onClick={handleSubmit}
disabled={layoutName === "" || group === ""}
>Save

</Button>
</div>
</div>
Expand Down
5 changes: 3 additions & 2 deletions vuu-ui/packages/vuu-shell/src/layout-management/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./SaveLayoutPanel";
export * from "./LayoutList";
export * from "./layoutTypes";
export * from "./LayoutList"
export * from "./layoutTypes"
export * from "./useLayoutManager"
21 changes: 14 additions & 7 deletions vuu-ui/packages/vuu-shell/src/layout-management/layoutTypes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { LayoutJSON } from "@finos/vuu-layout";

export type LayoutMetadata = {
name: string,
group: string,
screenshot: string,
user: string,
date: string,
id: string
}
name: string;
group: string;
screenshot: string;
user: string;
date: string;
id: string;
};

export type Layout = {
json: LayoutJSON;
metadata: LayoutMetadata;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, { useState, useCallback, useContext, useEffect } from "react";
import { getLocalEntity, saveLocalEntity } from "@finos/vuu-filters";
import { LayoutJSON } from "@finos/vuu-layout";
import { getUniqueId } from "@finos/vuu-utils";
import { LayoutMetadata, Layout } from "./layoutTypes";

export const LayoutManagementContext = React.createContext<{
layouts: Layout[],
saveLayout: (n: Omit<LayoutMetadata, "id">) => void
}>({ layouts: [], saveLayout: () => { } })

export const LayoutManagementProvider = (props: { children: JSX.Element | JSX.Element[] }) => {

const [layouts, setLayouts] = useState<Layout[]>([])

useEffect(() => {
const layouts = getLocalEntity<Layout[]>("layouts")
setLayouts(layouts || [])
}, [])

useEffect(() => {
saveLocalEntity<Layout[]>("layouts", layouts)
}, [layouts])

const saveLayout = useCallback((metadata: Omit<LayoutMetadata, "id">) => {
const json = getLocalEntity<LayoutJSON>("api/vui")
if (json) {
setLayouts(prev =>
[
...prev,
{
metadata: {
...metadata,
id: getUniqueId()
},
json
}
]
)
}
}, [])

return (
<LayoutManagementContext.Provider value={{ layouts, saveLayout }} >
{props.children}
</LayoutManagementContext.Provider>
)
}

export const useLayoutManager = () => useContext(LayoutManagementContext);
1 change: 1 addition & 0 deletions vuu-ui/packages/vuu-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ export * from "./selection-utils";
export * from "./sort-utils";
export * from "./text-utils";
export * from "./url-utils";
export * from "./screenshot-utils"
3 changes: 0 additions & 3 deletions vuu-ui/packages/vuu-utils/src/screenshot-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { toPng } from "html-to-image";
* @returns Base64 encoded image url
*/
export async function takeScreenshot(node: HTMLElement) {
localStorage.removeItem("layout-screenshot");

const screenshot = await toPng(node, { cacheBust: true })
.then((dataUrl) => {
Expand All @@ -20,7 +19,5 @@ export async function takeScreenshot(node: HTMLElement) {
if (!screenshot) {
return undefined;
}

localStorage.setItem("layout-screenshot", screenshot);
return screenshot;
}
28 changes: 16 additions & 12 deletions vuu-ui/packages/vuu-utils/test/screenshot-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import { describe, expect, it, vi } from "vitest";
* @vitest-environment happy-dom
*/

describe("screenshot-utils", () => {
vi.mock("html-to-image");

it("takes a screenshot and saves it to local storage", async () => {
const setItem = vi.spyOn(window.localStorage, "setItem");
describe("takeScreenshot", () => {
it("returns a string when toPng() promise is resolved", async () => {
const placeholderImage =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA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ndCqwXAhCoSkCLgX59+vQp+6/e1Isnfn3K7/27t9yV/3327NksO9CvvMT0/Plz9fTpU3Xz5k2ls4x169apDRs2qGPHji0TkF5RKK6jmA1pcen921oGQomqavjQHgIQSJWA3tAvXLigbty4oe7fv79CQIrPKIpZRm/GoUVIC1Cv+GzZsqVb3tKZQ74/67bnzp1T58+fV3v27FG6xFV8pqIN0Z/rz3LBKGYcvdlKowyEElWq4c+6IQCBJgS0EOzatSsrI61WstJzlBUQ3bb4wFtnIPmzitxWLVy6lHXixIms9KUfuD958iR7dpJnLnq+mZmZ7O+3b98uK1lZERBKVE1Ch74QgEDKBPQm/PjxY3X16tXs20z9BCR/UF22hNX7Da5cAPJvSxUFRIuKbr9t2za1sLCQiUfxW1y6b/5wfnZ2dtlD/NolLEpUKYc8a4cABGwR6C0Z5ePmX5G9detW98F4v4foecmqNzvRf+sN/uTJk2r9+vXqyJEjfTOQXECKXw0u7u+fP39Wjx49ykprP378WPaAvdJDdEpUtkKGcSAAAQj0J9D7YLzO13j1cw5dnsrFYXJyctkzkH4ZiBaQfg/t9Vd6x8bGst+arFmzRt2+fTv7rcm+ffvKfY2XEhWhDgEIQKAdAk1+SJg/58jFQ4tCXs7SmY5+AJ4/ENerKYpMnoH0/pAwz4SGh4ezEtebN2+y34l8/PhRHT16NPu674ofEmrFMv0QpR2czAIBCEAAApIIDHqEoQWpMz09vfT3799MVbTqFH+92Ol0lC5lFV/6M/0qft7kMz3WoP5157Yx5qC5+629rJ1lx+wXPDmj3vlXa9s7X29bn2PWmdu09n5jrhbDpvEk3cTYAgEJBLSY6KxFv7VW/A8L/q17HrcSiwAAAABJRU5ErkJggg==";

Expand All @@ -20,15 +17,22 @@ describe("screenshot-utils", () => {

const node = document.createElement("div");

node.style.backgroundColor = "red";
node.style.border = "1px solid black";
node.style.width = "100px";
node.style.height = "100px";
const screenshot = await takeScreenshot(node);

expect(typeof screenshot).toEqual("string");
});

it("returns undefined when toPng() promise is rejected", async () => {
// We need to mock the html-to-image package because the web API operations it relies on (e.g. canvas.toDataUrl) are not available in the test environment
const htmlToImage = await import("html-to-image");
htmlToImage.toPng = vi.fn().mockRejectedValue({});

const node = document.createElement("div");

const screenshot = await takeScreenshot(node);

expect(screenshot).toBeDefined();
expect(setItem).toHaveBeenCalledWith("layout-screenshot", screenshot);
expect(localStorage.getItem("layout-screenshot")).toEqual(screenshot);
console.log(screenshot);

expect(screenshot).toBeUndefined();
});
});
58 changes: 29 additions & 29 deletions vuu-ui/showcase/src/examples/Apps/NewTheme.examples.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import { LeftNav, SaveLayoutPanel, Shell } from "@finos/vuu-shell";
import {
CSSProperties,
ReactElement,
useCallback,
useMemo,
useState,
} from "react";
import { AutoTableNext } from "../Table/TableNext.examples";
import {
LayoutMetadata,
LeftNav,
SaveLayoutPanel,
Shell,
LayoutManagementProvider,
useLayoutManager
} from "@finos/vuu-shell";
import { registerComponent } from "@finos/vuu-layout";
import { TableSettingsPanel } from "@finos/vuu-table-extras";
import {
Expand All @@ -18,44 +24,31 @@ import {
ContextMenuItemDescriptor,
MenuActionHandler,
MenuBuilder,
} from "packages/vuu-data-types";
} from "@finos/vuu-data-types";
import { AutoTableNext } from "../Table/TableNext.examples";

import "./NewTheme.examples.css";
import { takeScreenshot } from "@finos/vuu-utils/src/screenshot-utils";

registerComponent("AutoTableNext", AutoTableNext, "view");
registerComponent("TableSettings", TableSettingsPanel, "view");

const user = { username: "test-user", token: "test-token" };

let displaySequence = 1;

export const ShellWithNewTheme = () => {
const ShellWithNewTheme = () => {
const [dialogContent, setDialogContent] = useState<ReactElement>();

const handleCloseDialog = useCallback(() => {
setDialogContent(undefined);
}, []);

const handleSave = useCallback(
(
layoutName: string,
layoutGroup: string,
checkValues: string[],
radioValues: string
) => {
console.log(
`Save Layout as ${layoutName} to group ${layoutGroup} with settings [${checkValues}] and ${radioValues}`
);
},
[]
);
const { saveLayout } = useLayoutManager();

const handleScreenshot = async (nodeId: string) => {
await takeScreenshot(document.getElementById(nodeId) as HTMLElement);

return localStorage.getItem("layout-screenshot") || undefined;
};
const handleSave = useCallback((layoutMetadata: Omit<LayoutMetadata, "id">) => {
console.log(`Save layout as ${layoutMetadata.name} to group ${layoutMetadata.group}`);
saveLayout(layoutMetadata)
setDialogContent(undefined)
}, []);

const [buildMenuOptions, handleMenuAction] = useMemo<
[MenuBuilder, MenuActionHandler]
Expand All @@ -81,7 +74,7 @@ export const ShellWithNewTheme = () => {
}
return menuDescriptors;
},
async (action: MenuActionClosePopup) => {
(action: MenuActionClosePopup) => {
console.log("menu action", {
action,
});
Expand All @@ -90,9 +83,7 @@ export const ShellWithNewTheme = () => {
<SaveLayoutPanel
onCancel={handleCloseDialog}
onSave={handleSave}
screenshot={await handleScreenshot(
action.options.controlledComponentId as string
)}
componentId={action.options.controlledComponentId}
/>
);
return true;
Expand Down Expand Up @@ -170,6 +161,7 @@ export const ShellWithNewTheme = () => {
leftSidePanel={<LeftNav style={{ width: 240 }} />}
loginUrl={window.location.toString()}
user={user}
saveLocation="local"
style={
{
"--vuuShell-height": "100vh",
Expand All @@ -191,4 +183,12 @@ export const ShellWithNewTheme = () => {
);
};

ShellWithNewTheme.displaySequence = displaySequence++;
export const ShellWithNewThemeAndLayoutManagement = () => {
return (
<LayoutManagementProvider>
<ShellWithNewTheme />
</LayoutManagementProvider>
)
}

ShellWithNewThemeAndLayoutManagement.displaySequence = displaySequence++;
Loading

0 comments on commit f7ceec0

Please sign in to comment.