Skip to content

Commit

Permalink
SLVUU-127: Add username cookie to NewTheme example
Browse files Browse the repository at this point in the history
  • Loading branch information
pling-scottlogic committed Dec 11, 2023
1 parent cca1557 commit 21169b5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ const metadataSaveLocation = "layouts/metadata";
const layoutsSaveLocation = "layouts/layouts";

export class LocalLayoutPersistenceManager implements LayoutPersistenceManager {
#urlKey = "api/vui/" + getAuthDetailsFromCookies()[0];
username: string = getAuthDetailsFromCookies()[0];

#urlKey = `api/vui/${this.username}`;
constructor(urlKey?: string) {
if (urlKey) {
this.#urlKey = urlKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export type GetApplicationResponseDto = { definition: ApplicationJSON };
export class RemoteLayoutPersistenceManager
implements LayoutPersistenceManager
{
username: string = getAuthDetailsFromCookies()[0];

createLayout(
metadata: LayoutMetadataDto,
layout: LayoutJSON
Expand Down Expand Up @@ -138,7 +140,7 @@ export class RemoteLayoutPersistenceManager
method: "PUT",
headers: {
"Content-Type": "application/json",
username: getAuthDetailsFromCookies()[0],
username: this.username,
},
body: JSON.stringify(applicationJSON),
})
Expand All @@ -159,7 +161,7 @@ export class RemoteLayoutPersistenceManager
fetch(`${baseURL}/${applicationLayoutsSaveLocation}`, {
method: "GET",
headers: {
username: "vuu-user",
username: this.username,
},
})
.then((response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { Input, Button, FormField, FormFieldLabel, Text } from "@salt-ds/core";
import { ComboBox, Checkbox, RadioButton } from "@finos/vuu-ui-controls";
import { takeScreenshot } from "@finos/vuu-utils";
import { LayoutMetadataDto } from "./layoutTypes";
import { getAuthDetailsFromCookies } from "../login";

import "./SaveLayoutPanel.css";
import { getAuthDetailsFromCookies } from "../login";

const classBase = "saveLayoutPanel";
const formField = `${classBase}-formField`;
Expand Down Expand Up @@ -33,6 +33,7 @@ export const SaveLayoutPanel = (props: SaveLayoutPanelProps) => {
const [checkValues, setCheckValues] = useState<string[]>([]);
const [radioValue, setRadioValue] = useState<RadioValue>(radioValues[0]);
const [screenshot, setScreenshot] = useState<string | undefined>();
const [username] = getAuthDetailsFromCookies();

useEffect(() => {
if (componentId) {
Expand All @@ -47,7 +48,7 @@ export const SaveLayoutPanel = (props: SaveLayoutPanelProps) => {
name: layoutName,
group,
screenshot: screenshot ?? "",
user: getAuthDetailsFromCookies()[0] ?? "vuu-user",
user: username,
});
};

Expand Down
2 changes: 2 additions & 0 deletions vuu-ui/showcase/src/examples/Apps/NewTheme.examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ const ShellWithNewTheme = () => {
};

export const ShellWithNewThemeAndLayoutManagement = () => {
document.cookie = `vuu-username=${user.username}`;

return (
<NotificationsProvider>
<LayoutManagementProvider>
Expand Down

0 comments on commit 21169b5

Please sign in to comment.