Skip to content

Commit

Permalink
605 hide collaboration functioanlity (#610)
Browse files Browse the repository at this point in the history
* add back homepage

* revert back font default color to whit

* rearrange file locations

* introduce devMode state => for releasing new feature that won't deploy

* change to isDev => is in development

---------

Co-authored-by: david zhou <[email protected]>
  • Loading branch information
Dammshine and david zhou authored Mar 17, 2024
1 parent f5b370a commit 10efe97
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 25 deletions.
10 changes: 5 additions & 5 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ThemeProvider, Box } from '@mui/material';
import { AnimatePresence } from 'framer-motion';
import { Route, Routes } from 'react-router-dom';
import Feedback from 'visualiser-debugger/Feedback';
import HomePage from 'visualiser-debugger/HomePage';
import Page404 from 'visualiser-debugger/Page404';
import VisualiserPage from 'visualiser-debugger/VisualiserPage';
import Feedback from 'Feedback';
import HomePage from 'HomePage';
import Page404 from 'Page404';
import VisualiserPage from 'VisualiserPage';
import { structsTheme } from 'structsThemes';
import './App.scss';
import DevelopmentMode from 'visualiser-debugger/DevelopmentMode';
Expand All @@ -15,7 +15,7 @@ const App = () => (
<ThemeProvider theme={structsTheme}>
<Routes>
{/* Homepage */}
<Route path="/" element={<DevelopmentMode />} />
<Route path="/" element={<HomePage />} />

{/* Visualiser routes */}
<Route path="/visualiser/:topic/:data?" element={<VisualiserPage />} />
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 18 additions & 12 deletions client/src/components/Navbars/TopNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { titleToUrl, toTitleCase, urlToTitle } from 'utils/url';
import axios from 'axios';
import Login from 'components/Login/Login';
import { getTopics } from '../../visualiser-src/common/helpers';
import useGlobalState from '../../store/globalStore';

const LogoText = styled(Typography)({
textTransform: 'none',
Expand Down Expand Up @@ -57,6 +58,7 @@ const TopNavbar: FC<Props> = ({ position = 'fixed' }) => {
setLoggedIn(false);
};

const inDev = useGlobalState((state) => state.inDev);
return (
<Box>
<AppBar
Expand Down Expand Up @@ -105,18 +107,22 @@ const TopNavbar: FC<Props> = ({ position = 'fixed' }) => {
</LogoText>
</Button>
</Grid>
<Grid item xs={4} display="flex" justifyContent="end">
{loggedIn ? (
<>
<Button style={{ color: '#0288D1' }}>{localStorage.getItem('user')}</Button>
<Button style={{ color: '#0288D1' }} onClick={handleLogout}>
Log Out
</Button>
</>
) : (
<Login handleLogon={setLoggedIn} />
)}
</Grid>

{/* TODO: Release this feature */}
{inDev && (
<Grid item xs={4} display="flex" justifyContent="end">
{loggedIn ? (
<>
<Button style={{ color: '#0288D1' }}>{localStorage.getItem('user')}</Button>
<Button style={{ color: '#0288D1' }} onClick={handleLogout}>
Log Out
</Button>
</>
) : (
<Login handleLogon={setLoggedIn} />
)}
</Grid>
)}
</Grid>
</Toolbar>
</AppBar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, { useCallback, useContext } from 'react';
import VisualiserContext from './VisualiserContext';
import CreateLink from './CreateLink';
import Saving from './Saving';
import useGlobalState from '../../../store/globalStore';

const MenuButton = styled(Button)({
backgroundColor: '#46B693',
Expand Down Expand Up @@ -39,6 +40,7 @@ const CreateMenu = () => {
controller.generateDataStructure();
}, [controller]);

const inDev = useGlobalState((state) => state.inDev);
return (
<Box
display="flex"
Expand All @@ -59,8 +61,13 @@ const CreateMenu = () => {
Reset All
</Typography>
</MenuButton>
<Saving topicTitle={topicTitle} controller={controller} />
<CreateLink />
{/* TODO: Release this feature */}
{inDev && (
<>
<Saving topicTitle={topicTitle} controller={controller} />
<CreateLink />
</>
)}
</Box>
);
};
Expand Down
11 changes: 11 additions & 0 deletions client/src/store/globalStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { create } from 'zustand';

export interface GlobalState {
inDev: boolean;
}

const useGlobalState = create<GlobalState>(() => ({
inDev: true,
}));

export default useGlobalState;
2 changes: 1 addition & 1 deletion client/src/structsThemes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const structsTheme = createTheme({
paper: '#14113C',
},
text: {
primary: '#00000',
primary: '#FFFFFF',
secondary: 'rgba(255, 255, 255, 0.7)',
disabled: 'rgba(255, 255, 255, 0.5)',
},
Expand Down
8 changes: 3 additions & 5 deletions client/src/visualiser-debugger/DevelopmentMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import globalStyles from 'styles/global.module.css';
import classNames from 'classnames';
import { Tabs, Tab } from 'components/Tabs';
import { Socket } from 'socket.io-client';
import Console from 'components/DevelopmentMode/Console';
import Console from 'visualiser-debugger/Component/Console/Console';
import DevelopmentModeNavbar from '../components/Navbars/DevelopmentModeNavbar';
import Configuration from './Component/Configuration/Configuration';
import Controls from './Component/Control/Controls';
Expand All @@ -21,6 +21,7 @@ import {
PLACEHOLDER_WORKSPACE,
loadCode,
} from './Component/FileTree/Util/util';
import useGlobalState from '../store/globalStore';

type ExtendedWindow = Window &
typeof globalThis & { socket: Socket; getBreakpoints: (line: string, listName: string) => void };
Expand Down Expand Up @@ -190,8 +191,7 @@ const DevelopmentMode = () => {
// Refactor to better support Debugger mode
// - There're a lot of console.log functions, we can delegate responsibility in each component
// - Refactor Tabs
const DEBUG_MODE = false;
return !DEBUG_MODE ? (
return (
<div className={classNames(globalStyles.root, styles.light)}>
<div className={styles.layout}>
<div className={classNames(styles.pane, styles.nav)}>
Expand Down Expand Up @@ -255,8 +255,6 @@ const DevelopmentMode = () => {
</div>
</div>
</div>
) : (
<VisualizerMain backendState={backendState} />
);
};

Expand Down

0 comments on commit 10efe97

Please sign in to comment.