Skip to content

Commit

Permalink
⚗️Added experimental SMT lsp snackbar
Browse files Browse the repository at this point in the history
  • Loading branch information
soaibsafi committed Oct 29, 2024
1 parent b0e3d29 commit 228b6c2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 66 deletions.
7 changes: 6 additions & 1 deletion frontend/src/components/Playground/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { executeNuxmvTool } from '../../assets/ts/toolExecutor/nuxmvExecutor.js'
import { executeSpectraTool } from '../../assets/ts/toolExecutor/spectraExecutor.js';
import { executeAlloyTool } from '../../assets/ts/toolExecutor/alloyExecutor.js';
import fmpConfig, { ToolDropdown } from '../../../fmp.config.js';
import UpdateSnackbar from '../Utils/Modals/UpdateSnackbar.js';

interface PlaygroundProps {
editorValue: string;
Expand Down Expand Up @@ -281,7 +282,7 @@ const Playground: React.FC<PlaygroundProps> = ({ editorValue, setEditorValue, la
<MDBIcon size='lg' className='playground-icon'
style={{ marginTop: "5px" }}
data-tooltip-id="playground-tooltip"
data-tooltip-content="This allows you to check the syntax of the code, get suggestions/code completion. Currently experimental."
data-tooltip-content="This allows you to check the syntax of the code, get suggestions/code completion."
>
<Toggle
id='cheese-status'
Expand Down Expand Up @@ -459,6 +460,10 @@ const Playground: React.FC<PlaygroundProps> = ({ editorValue, setEditorValue, la
errorMessage={errorMessage}
/>
)}
{enableLsp && language.id === "smt2" && (
<UpdateSnackbar
message="This feature is experimental for the SMT language. <br/> If you encounter any misbehavior, please provide a <i>Feedback</i>." />
)}
</div>
)
}
Expand Down
48 changes: 14 additions & 34 deletions frontend/src/components/Utils/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,23 @@
import { MDBFooter } from 'mdb-react-ui-kit';
import '../../assets/style/Footer.css';
import { AlertColor } from '@mui/material/Alert';
import UpdateSnackbar from './Modals/UpdateSnackbar';
type infoSnackBarContent = {
visible?: string,
severity?: AlertColor,
message: string,
targetDate?: string
}

const UPDATE_SNACKBAR = import.meta.env.VITE_FMP_UPDATE_SNACKBAR || '{"visible":"false","severity":"info","message":"No message"}';
const Footer = () => {
const infoSnackBarContent: infoSnackBarContent = JSON.parse(UPDATE_SNACKBAR);
const visible = infoSnackBarContent.visible === 'true';

return (
<>
<MDBFooter className='text-center text-lg-left mt-5'>
<div className='text-center p-3 footer-text'>
Privacy Policy:
This website logs the specifications and options, which may be analyzed and made public for research purposes.
Do not share confidential information.
<br />
Unless you login, it does not collect any personally identifiable information.
Deleting your profile will remove all records of your profile from our servers.
The specifications will be unlinked from your profile, but remain on the servers (see first bullet).
<br />
&copy; {new Date().getFullYear()} Copyright:{' '}
Made with ♥ in Bauhaus-Universität Weimar
</div>
</MDBFooter>
{visible &&
<UpdateSnackbar
visible={visible}
severity={infoSnackBarContent.severity}
message={infoSnackBarContent.message}
targetDate={infoSnackBarContent.targetDate}
/>}
</>
<MDBFooter className='text-center text-lg-left mt-5'>
<div className='text-center p-3 footer-text'>
Privacy Policy:
This website logs the specifications and options, which may be analyzed and made public for research purposes.
Do not share confidential information.
<br />
Unless you login, it does not collect any personally identifiable information.
Deleting your profile will remove all records of your profile from our servers.
The specifications will be unlinked from your profile, but remain on the servers (see first bullet).
<br />
&copy; {new Date().getFullYear()} Copyright:{' '}
Made with ♥ in Bauhaus-Universität Weimar
</div>
</MDBFooter>

);
}
Expand Down
37 changes: 6 additions & 31 deletions frontend/src/components/Utils/Modals/UpdateSnackbar.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,17 @@
import React, { useState, useEffect, SyntheticEvent } from 'react';
import Alert, { AlertColor } from '@mui/material/Alert';
import Snackbar, { SnackbarCloseReason } from '@mui/material/Snackbar';
import React, { useState } from 'react';
import Alert from '@mui/material/Alert';
import Snackbar from '@mui/material/Snackbar';

type UpdateSnackbarProps = {
message: string,
severity?: AlertColor,
visible?: boolean,
targetDate?: string
};

const UpdateSnackbar: React.FC<UpdateSnackbarProps> = (props) => {
const [open, setOpen] = useState(props.visible || false);
const [manuallyClosed, setManuallyClosed] = useState(false);
const targetDate = new Date(props.targetDate || '1970-01-01');
const [open, setOpen] = useState(true);

useEffect(() => {
const currentDate = new Date();
if (currentDate < targetDate && !manuallyClosed) {
setOpen(true);
} else {
setOpen(false);
}
}, [targetDate, manuallyClosed]);

const handleClose = (
event?: SyntheticEvent | Event,
reason?: SnackbarCloseReason,
) => {
if (reason === 'clickaway') {
return;
}
const handleClose = () => {
setOpen(false);
setManuallyClosed(true);
};

return (
Expand All @@ -41,12 +21,7 @@ const UpdateSnackbar: React.FC<UpdateSnackbarProps> = (props) => {
autoHideDuration={5000}
anchorOrigin={{ vertical: 'bottom', horizontal: 'right' }}
onClose={handleClose}>
<Alert
onClose={handleClose}
severity={props.severity}
variant="standard"
sx={{ width: '30vw' }}
>
<Alert onClose={handleClose} severity="warning">
<span dangerouslySetInnerHTML={{ __html: props.message }} />
</Alert>
</Snackbar>
Expand Down

0 comments on commit 228b6c2

Please sign in to comment.