Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lwjameson committed Jan 3, 2024
1 parent 5e31fd0 commit 8a55b85
Show file tree
Hide file tree
Showing 6 changed files with 2,186 additions and 2,164 deletions.
69 changes: 69 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion src/components/Branding/Branding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function Branding() {
const [footerMessage, setFooterMessage] = useState<string | undefined>();
const [topLogos, setTopLogos] = useState<boolean>(false);
const [bottomLogos, setBottomLogos] = useState<boolean>(false);
const [favicon, setFavicon] = useState<string>('favicon.svg');

useEffect(() => {
if (configFile) {
Expand Down Expand Up @@ -62,6 +63,9 @@ function Branding() {
setBottomLogos(
configFile.branding ? configFile.branding.bottom_logos_enabled : false
);
setFavicon(
configFile.branding ? configFile.branding.favicon : 'favicon.svg'
);
}
}, [configFile]);

Expand Down Expand Up @@ -95,6 +99,9 @@ function Branding() {
setBottomLogos(
configFile.branding ? configFile.branding.bottom_logos_enabled : false
);
setFavicon(
configFile.branding ? configFile.branding.favicon : 'favicon.svg'
);
}
};

Expand All @@ -110,6 +117,7 @@ function Branding() {
home_banner: homeBanner,
footer_message: footerMessage,
top_logos_enabled: topLogos,
favicon: favicon,
});
};

Expand Down Expand Up @@ -246,7 +254,19 @@ function Branding() {
onChange={(e) => setHomeBanner(e.target.value)}
/>
</FlexRow>

<FlexRow fullWidth padding={5}>
<TextField
autoFocus
margin='dense'
id='favicon'
label='Favicon'
type='text'
fullWidth
variant='standard'
value={favicon || ''}
onChange={(e) => setFavicon(e.target.value)}
/>
</FlexRow>
<FlexRow fullWidth spaceBetween padTop={32}>
<Button
variant='contained'
Expand Down
104 changes: 62 additions & 42 deletions src/components/LoadConfigDialog/LoadConfigDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import Button from "@mui/material/Button";
import TextField from "@mui/material/TextField";
import Dialog from "@mui/material/Dialog";
import DialogActions from "@mui/material/DialogActions";
import DialogContent from "@mui/material/DialogContent";
import DialogContentText from "@mui/material/DialogContentText";
import DialogTitle from "@mui/material/DialogTitle";
import { ConfigFile, PolicyDefinition } from "../../types";
import { useEffect, useState } from "react";
import { copyObject } from "../../utilities";
import { MuiFileInput } from "mui-file-input";
import Button from '@mui/material/Button';
import TextField from '@mui/material/TextField';
import Dialog from '@mui/material/Dialog';
import DialogActions from '@mui/material/DialogActions';
import DialogContent from '@mui/material/DialogContent';
import DialogContentText from '@mui/material/DialogContentText';
import DialogTitle from '@mui/material/DialogTitle';
import { ConfigFile, PolicyDefinition } from '../../types';
import { useEffect, useState } from 'react';
import { copyObject } from '../../utilities';
import { MuiFileInput } from 'mui-file-input';

export interface LoadConfigDialogProps {
open: boolean;
Expand Down Expand Up @@ -43,7 +43,7 @@ const LoadConfigDialog = (props: LoadConfigDialogProps) => {
const handleChooseFile = (newFile) => {
const data = new FileReader();
setFile(newFile);
data.addEventListener("load", () => {
data.addEventListener('load', () => {
if (newFile) {
setConfigFile(JSON.parse(data.result as string) as ConfigFile);
setFileName(newFile.name);
Expand Down Expand Up @@ -73,9 +73,9 @@ const LoadConfigDialog = (props: LoadConfigDialogProps) => {
setLoading(false);
// noinspection TypeScriptValidateTypes
setConfigFile({
project_name: "",
author: "",
version: "",
project_name: '',
author: '',
version: '',
created_at: Date.now().toString(),
updated_at: undefined,
policies: copyObject(policies),
Expand All @@ -84,19 +84,39 @@ const LoadConfigDialog = (props: LoadConfigDialogProps) => {
project_groups: [],
layer_groups: [],
admin: {
admin_email: "",
admin_email: '',
admin_groups: [],
},
branding: {
platform_name: "",
site_name: "",
site_color: "orange",
welcome_blurb: "",
home_banner: "",
platform_name: '',
site_name: '',
welcome_blurb: undefined,
site_color: 'orange',
home_banner: undefined,
footer_message: '',
background_color: 'black',
contrast_color: 'white',
top_logos_enabled: false,
bottom_logos_enabled: false,
favicon: 'favicon.svg',
},
authentication: {
methods: [],
},
supported_languages: ['en', 'de'],
default_language: 'en',
dynamic_text: {
public_document_warning: [
{
language: 'en',
text: '',
},
{
language: 'de',
text: '',
},
],
},
});
};

Expand All @@ -121,50 +141,50 @@ const LoadConfigDialog = (props: LoadConfigDialogProps) => {
</DialogContentText>
{loading ? (
<MuiFileInput
placeholder="Load a Config File"
placeholder='Load a Config File'
value={file}
onChange={handleChooseFile}
/>
) : (
<>
<TextField
autoFocus
margin="dense"
id="fileName"
label="Name for Config file"
type="text"
margin='dense'
id='fileName'
label='Name for Config file'
type='text'
fullWidth
variant="standard"
variant='standard'
value={fileName}
onChange={(e) => setFileName(e.target.value)}
/>
<TextField
margin="dense"
id="projectName"
label="Project Name"
type="text"
margin='dense'
id='projectName'
label='Project Name'
type='text'
fullWidth
variant="standard"
variant='standard'
value={projectName}
onChange={(e) => setProjectName(e.target.value)}
/>
<TextField
margin="dense"
id="author"
label="Author"
type="text"
margin='dense'
id='author'
label='Author'
type='text'
fullWidth
variant="standard"
variant='standard'
value={author}
onChange={(e) => setAuthor(e.target.value)}
/>
<TextField
margin="dense"
id="version"
label="Version"
type="text"
margin='dense'
id='version'
label='Version'
type='text'
fullWidth
variant="standard"
variant='standard'
value={version}
onChange={(e) => setVersion(e.target.value)}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/providers/ConfigToolProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ const ConfigToolProvider = (props: ConfigToolProviderProps) => {
contrast_color: 'white',
top_logos_enabled: false,
bottom_logos_enabled: false,
favicon: 'favicon.svg',
};
}
copy.branding.platform_name = branding.platform_name;
Expand All @@ -284,6 +285,7 @@ const ConfigToolProvider = (props: ConfigToolProviderProps) => {
copy.branding.top_logos_enabled = branding.top_logos_enabled;
copy.branding.bottom_logos_enabled = branding.bottom_logos_enabled;
copy.branding.contrast_color = branding.contrast_color;
copy.branding.favicon = branding.favicon;
setConfigFile(copy);
}
};
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type Branding = {
bottom_logos_enabled: boolean;
footer_message: string | undefined;
top_logos_enabled: boolean;
favicon: string;
};

export type Policy = Database['public']['Tables']['policies']['Row'];
Expand Down
Loading

0 comments on commit 8a55b85

Please sign in to comment.