-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Toggle between dashboard and code views
- Loading branch information
1 parent
0250ebe
commit 9d17a18
Showing
9 changed files
with
214 additions
and
55 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/components/shared/Entity/Details/Logs/Status/SectionFormatter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Box, ToggleButtonGroup } from '@mui/material'; | ||
import OutlinedToggleButton from 'components/shared/buttons/OutlinedToggleButton'; | ||
import { outlinedToggleButtonGroupStyling } from 'context/Theme'; | ||
import { useIntl } from 'react-intl'; | ||
import { useEntityStatusStore } from 'stores/EntityStatus/Store'; | ||
|
||
export default function SectionFormatter() { | ||
const intl = useIntl(); | ||
|
||
const format = useEntityStatusStore((state) => state.format); | ||
const setFormat = useEntityStatusStore((state) => state.setFormat); | ||
|
||
return ( | ||
<Box style={{ paddingTop: 4 }}> | ||
<ToggleButtonGroup | ||
size="small" | ||
exclusive | ||
sx={outlinedToggleButtonGroupStyling} | ||
> | ||
<OutlinedToggleButton | ||
size="small" | ||
value="dashboard" | ||
selected={format === 'dashboard'} | ||
onClick={(_event, value) => setFormat(value, 'code')} | ||
> | ||
{intl.formatMessage({ | ||
id: 'details.ops.status.cta.formatted', | ||
})} | ||
</OutlinedToggleButton> | ||
|
||
<OutlinedToggleButton | ||
size="small" | ||
value="code" | ||
selected={format === 'code'} | ||
onClick={(_event, value) => setFormat(value, 'dashboard')} | ||
> | ||
{intl.formatMessage({ id: 'details.ops.status.cta.raw' })} | ||
</OutlinedToggleButton> | ||
</ToggleButtonGroup> | ||
</Box> | ||
); | ||
} |
34 changes: 34 additions & 0 deletions
34
src/components/shared/Entity/Details/Logs/Status/SectionViews.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Divider, Typography } from '@mui/material'; | ||
import ControllerStatusHistoryTable from 'components/tables/ControllerStatusHistory'; | ||
import { useIntl } from 'react-intl'; | ||
import { useEntityStatusStore } from 'stores/EntityStatus/Store'; | ||
import Overview from './Overview'; | ||
import StatusResponseViewer from './StatusResponseViewer'; | ||
|
||
export default function SectionViews() { | ||
const intl = useIntl(); | ||
|
||
const format = useEntityStatusStore((state) => state.format); | ||
|
||
if (format === 'dashboard') { | ||
return ( | ||
<> | ||
<Overview /> | ||
|
||
<Divider /> | ||
|
||
<Typography | ||
style={{ fontSize: 18, fontWeight: 400, marginBottom: 24 }} | ||
> | ||
{intl.formatMessage({ | ||
id: 'details.ops.status.table.header', | ||
})} | ||
</Typography> | ||
|
||
<ControllerStatusHistoryTable serverErrorExists={false} /> | ||
</> | ||
); | ||
} else { | ||
return <StatusResponseViewer />; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/components/shared/Entity/Details/Logs/Status/StatusResponseViewer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Editor } from '@monaco-editor/react'; | ||
import { Box, Divider, Paper, useTheme } from '@mui/material'; | ||
import { MonacoEditorSkeleton } from 'components/editor/MonacoEditor/EditorSkeletons'; | ||
import { editorToolBarSx } from 'context/Theme'; | ||
import * as monacoEditor from 'monaco-editor/esm/vs/editor/editor.api'; | ||
import { useRef } from 'react'; | ||
import { logRocketConsole } from 'services/shared'; | ||
import { stringifyJSON } from 'services/stringify'; | ||
import { useEntityStatusStore } from 'stores/EntityStatus/Store'; | ||
import { DEFAULT_TOOLBAR_HEIGHT } from 'utils/editor-utils'; | ||
import { hasLength } from 'utils/misc-utils'; | ||
|
||
const EDITOR_HEIGHT = 400; | ||
|
||
export default function StatusResponseViewer() { | ||
const theme = useTheme(); | ||
const editorRef = useRef<monacoEditor.editor.IStandaloneCodeEditor | null>( | ||
null | ||
); | ||
|
||
const response = useEntityStatusStore((state) => state.response); | ||
|
||
if (response) { | ||
return ( | ||
<Paper sx={{ width: '100%' }} variant="outlined"> | ||
<Box | ||
sx={{ | ||
...editorToolBarSx, | ||
minHeight: DEFAULT_TOOLBAR_HEIGHT, | ||
}} | ||
/> | ||
|
||
<Divider /> | ||
|
||
<Editor | ||
defaultLanguage="json" | ||
height={EDITOR_HEIGHT} | ||
onMount={( | ||
editor: monacoEditor.editor.IStandaloneCodeEditor | ||
) => { | ||
logRocketConsole('handlers:mount'); | ||
editorRef.current = editor; | ||
}} | ||
options={{ | ||
readOnly: true, | ||
minimap: { | ||
enabled: false, | ||
}, | ||
}} | ||
path={ | ||
hasLength(response.catalog_name) | ||
? response.catalog_name | ||
: 'preset_status_path' | ||
} | ||
saveViewState={false} | ||
theme={theme.palette.mode === 'light' ? 'vs' : 'vs-dark'} | ||
value={stringifyJSON(response)} | ||
/> | ||
</Paper> | ||
); | ||
} else { | ||
return <MonacoEditorSkeleton editorHeight={EDITOR_HEIGHT} />; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters