Skip to content

Commit b970514

Browse files
authored
Merge pull request #13 from CatalysmsServerManager/development
2 parents 5448e89 + 15895fe commit b970514

File tree

20 files changed

+2000
-114
lines changed

20 files changed

+2000
-114
lines changed

package-lock.json

Lines changed: 1548 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
"dependencies": {
1111
"@craco/craco": "^6.1.1",
1212
"@material-ui/core": "^4.11.3",
13+
"@sentry/react": "^6.16.1",
14+
"@sentry/tracing": "^6.16.1",
15+
"antd": "^4.18.2",
1316
"axios": "^0.21.1",
1417
"faker": "^5.5.3",
1518
"framer-motion": "^3.10.3",
@@ -23,7 +26,7 @@
2326
"react-dom": "^17.0.1",
2427
"react-helmet": "^6.1.0",
2528
"react-redux": "^7.2.2",
26-
"react-router-dom": "^6.0.0-beta.0",
29+
"react-router-dom": "^6.2.1",
2730
"react-scripts": "4.0.3",
2831
"react-sortable-hoc": "^1.11.0",
2932
"styled-components": "^5.2.1",

src/App.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1+
import 'antd/dist/antd.css';
2+
13
import { FC, StrictMode } from 'react';
24
import { ThemeProvider } from 'styled-components';
35

46
import { Router } from './router';
7+
import { getServerId, OptionsContext } from './services/optionsContext';
58
import { DEFAULT, GlobalStyle } from './styled';
69

710
export const App: FC = () => {
811
return (
912
<StrictMode>
1013
<ThemeProvider theme={DEFAULT}>
1114
<GlobalStyle />
12-
<Router />
15+
<OptionsContext.Provider value={{ serverId: getServerId() }}>
16+
<Router />
17+
</OptionsContext.Provider>
1318
</ThemeProvider>
1419
</StrictMode>
1520
);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { FC } from 'react';
2+
import styled from 'styled-components';
3+
4+
const Container = styled.div`
5+
width: 100%;
6+
height: 100vh;
7+
padding: 2.5%;
8+
`;
9+
10+
export const ContentContainer: FC = (props) => {
11+
return (
12+
<Container>
13+
{props.children}
14+
</Container>
15+
);
16+
};

src/components/Data.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getData } from '../services/data';
66
import { editorOptions } from './Editor/settings';
77

88
const EditorContainer = styled.div`
9-
height: 100vh;
9+
height: 100%;
1010
width: 100%;
1111
`;
1212

src/components/Editor/settings/index.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,7 @@ export function setup() {
6565
});
6666
}
6767

68-
const initialValue = `{{#if (gt player.role.level 10 )}}
69-
pm {{player.steamId}} "Hey {{player.name}} You have the correct role to execute this command";
70-
{{else}}
71-
pm {{player.steamId}} "Sorry, {{player.name}}, you're not allowed to do that";
72-
{{/if}}
73-
`;
74-
75-
export const editorOptions = (init = initialValue, extraOptions = {}) => {
68+
export const editorOptions = (init: string, extraOptions = {}) => {
7669
return {
7770
value: init,
7871
language: CUSTOM_LANGUAGE,

src/components/Header.tsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/components/NavBar.tsx

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,62 @@
1-
import { FC } from 'react';
1+
import { Menu, Typography } from 'antd';
2+
import { FC, useContext } from 'react';
3+
import { Link } from 'react-router-dom';
24
import styled from 'styled-components';
35

4-
const Container = styled.div<{ open: boolean }>`
5-
position: absolute;
6-
top: 0;
7-
right: 0;
8-
width: 250px;
6+
import { OptionsContext } from '../services/optionsContext';
7+
8+
const { Title } = Typography;
9+
10+
const Container = styled.div`
11+
width: 100%;
912
height: 100vh;
10-
background-color: ${({ theme }) => theme.p};
11-
z-index: 1;
1213
`;
1314

14-
const Content = styled.div``;
15+
const TitleContainer = styled.div`
16+
background-color: ${({ theme }) => theme.p};
17+
color: ${({ theme }) => theme.c};
18+
height: 5%;
19+
width: 100%;
20+
`;
1521

1622
export const NavBar: FC = () => {
23+
const options = useContext(OptionsContext);
24+
1725
return (
18-
<Container open={true}>
19-
<Content>navbar</Content>
26+
<Container>
27+
28+
<TitleContainer>
29+
<Title level={2}>
30+
Playground
31+
</Title>
32+
</TitleContainer>
33+
34+
<Menu
35+
defaultOpenKeys={['sub1']}
36+
defaultSelectedKeys={['1']}
37+
mode="inline"
38+
>
39+
<Menu.Item key="editor">
40+
<Link to={`/${options.serverId}/playground/editor`}>
41+
<span>Editor</span>
42+
</Link>
43+
</Menu.Item>
44+
<Menu.Item key="variables">
45+
<Link to={`/${options.serverId}/playground/variables`}>
46+
<span>Variables</span>
47+
</Link>
48+
</Menu.Item>
49+
<Menu.Item key="executions">
50+
<Link to={`/${options.serverId}/playground/executions`}>
51+
<span>Executions</span>
52+
</Link>
53+
</Menu.Item>
54+
<Menu.Item key="settings">
55+
<Link to={`/${options.serverId}/playground/settings`}>
56+
<span>Settings</span>
57+
</Link>
58+
</Menu.Item>
59+
</Menu>
2060
</Container>
2161
);
2262
};

src/components/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export { Output } from './Output';
22
export { ExecuteButton } from './ExecuteButton';
33
export { NavBar } from './NavBar';
4-
export { Header } from './Header';

src/hooks/useLocalStorage.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { useState } from 'react';
2+
3+
export function useLocalStorage<T>(key: string, initialValue: T) {
4+
// State to store our value
5+
// Pass initial state function to useState so logic is only executed once
6+
const [storedValue, setStoredValue] = useState<T>(() => {
7+
// Get from local storage by key
8+
const item = window.localStorage.getItem(key);
9+
// Parse stored json or if none return initialValue
10+
return item ? JSON.parse(item) : initialValue;
11+
});
12+
13+
// Return a wrapped version of useState's setter function that ...
14+
// ... persists the new value to localStorage.
15+
const setValue = (value: T | ((val: T) => T)) => {
16+
// Allow value to be a function so we have same API as useState
17+
const valueToStore =
18+
value instanceof Function ? value(storedValue) : value;
19+
// Save state
20+
setStoredValue(valueToStore);
21+
// Save to local storage
22+
window.localStorage.setItem(key, JSON.stringify(valueToStore));
23+
};
24+
25+
return [storedValue, setValue] as const;
26+
}

0 commit comments

Comments
 (0)