Skip to content

Commit

Permalink
Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
iberdinsky-skilld committed Jun 19, 2024
1 parent 3ae4ab7 commit 2ebb016
Show file tree
Hide file tree
Showing 19 changed files with 677 additions and 193 deletions.
1 change: 1 addition & 0 deletions client/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ module.exports = {
],
'unicorn/no-null': 0,
'unicorn/prevent-abbreviations': 0,
'unicorn/prefer-add-event-listener': 0,
'unicorn/prefer-query-selector': 0,
'import/no-unresolved': [
2,
Expand Down
4 changes: 3 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@
"react-hook-form": "^7.51.5",
"react-i18next": "^14.1.2",
"react-router-dom": "^6.23.1",
"reactflow": "^11.11.3"
"reactflow": "^11.11.3",
"websocket": "^1.0.35"
},
"devDependencies": {
"@types/lodash": "^4",
"@types/node": "^18.19.34",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/websocket": "^1.0.10",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^7.12.0",
"@vitejs/plugin-react": "^4.3.0",
Expand Down
131 changes: 68 additions & 63 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import { ThemedHeaderV2 } from './components/layout/Header'
import { ThemedSiderV2 } from './components/layout/Sider'
import { ThemedTitleV2 } from './components/layout/Title'
import { ActionProvider } from './context/ActionContext'
import AppProvider from './context/AppContext'
import { liveProvider } from './live-provider'
import { ActionList, ActionShow } from './pages/actions'
import { AsyncActionList } from './pages/async'
import { FlowShow } from './pages/flow'
import { dataProvider as launchrDataProvider } from './rest-data-provider'
import { ThemeProvider } from './ThemeProvider'
Expand All @@ -23,73 +26,75 @@ const apiUrl = import.meta.env.VITE_API_URL

export function App() {
return (
<BrowserRouter>
<RefineKbarProvider>
<ThemeProvider>
<Refine
dataProvider={{
default: launchrDataProvider(apiUrl),
}}
notificationProvider={useNotificationProvider}
routerProvider={routerBindings}
resources={[
{
name: 'actions',
list: '/actions',
show: '/actions/:id/show',
// edit: "/actions/:id/edit",
meta: {
canDelete: false,
},
},
]}
options={{
// syncWithLocation: true,
warnWhenUnsavedChanges: true,
}}
>
<Routes>
<Route
element={
<ThemedLayoutV2
Header={ThemedHeaderV2}
Sider={ThemedSiderV2}
Title={ThemedTitleV2}
>
<Outlet />
</ThemedLayoutV2>
}
<AppProvider>
<ActionProvider>
<BrowserRouter>
<RefineKbarProvider>
<ThemeProvider>
<Refine
dataProvider={{
default: launchrDataProvider(apiUrl),
}}
liveProvider={liveProvider}
notificationProvider={useNotificationProvider}
routerProvider={routerBindings}
resources={[
{
name: 'actions',
list: '/actions',
show: '/actions/:id/show',
// edit: "/actions/:id/edit",
meta: {
canDelete: false,
},
},
]}
options={{
// syncWithLocation: true,
warnWhenUnsavedChanges: true,
liveMode: 'auto',
}}
>
<Route
index
element={<NavigateToResource resource="actions" />}
/>
<Route path="/actions">
<Route index element={<ActionList />} />
<Route path=":id/show" element={<ActionShow />} />
{/*<Route path=":id/running/:runId" element={<ActionAttach />} />*/}
{/*<Route path=":id/edit" element={<ActionEdit />} />*/}
</Route>
<Route path="/flow">
<Routes>
<Route
index
element={
<ActionProvider>
<FlowShow />
</ActionProvider>
<ThemedLayoutV2
Header={ThemedHeaderV2}
Sider={ThemedSiderV2}
Title={ThemedTitleV2}
>
<Outlet />
</ThemedLayoutV2>
}
/>
</Route>
<Route path="*" element={<ErrorComponent />} />
</Route>
</Routes>
>
<Route
index
element={<NavigateToResource resource="actions" />}
/>
<Route path="/actions">
<Route index element={<ActionList />} />
<Route path=":id/show" element={<ActionShow />} />
{/*<Route path=":id/running/:runId" element={<ActionAttach />} />*/}
{/*<Route path=":id/edit" element={<ActionEdit />} />*/}
</Route>
<Route path="/flow">
<Route index element={<FlowShow />} />
</Route>
<Route path="/async">
<Route index element={<AsyncActionList />} />
</Route>
<Route path="*" element={<ErrorComponent />} />
</Route>
</Routes>

<RefineKbar />
<UnsavedChangesNotifier />
<DocumentTitleHandler />
</Refine>
</ThemeProvider>
</RefineKbarProvider>
</BrowserRouter>
<RefineKbar />
<UnsavedChangesNotifier />
<DocumentTitleHandler />
</Refine>
</ThemeProvider>
</RefineKbarProvider>
</BrowserRouter>
</ActionProvider>
</AppProvider>
)
}
4 changes: 0 additions & 4 deletions client/src/components/FormFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
import validator from '@rjsf/validator-ajv8'
import { type FC, useState } from 'react'

import { useStartAction } from '../hooks/ActionHooks'
import type { IActionData, IFormValues } from '../types'

const Form = withTheme(Theme)
Expand All @@ -37,7 +36,6 @@ function TitleFieldTemplate<

export const FormFlow: FC<{ actionId: string }> = ({ actionId }) => {
const [actionRunning, setActionRunning] = useState(false)
const startAction = useStartAction()
const apiUrl = useApiUrl()
const { mutateAsync } = useCustomMutation()

Expand Down Expand Up @@ -70,8 +68,6 @@ export const FormFlow: FC<{ actionId: string }> = ({ actionId }) => {

setActionRunning(true)

startAction(actionId)

await mutateAsync(
{
url: `${apiUrl}/actions/${actionId}`,
Expand Down
94 changes: 94 additions & 0 deletions client/src/components/StatusBox.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import CloseIcon from '@mui/icons-material/Close'
import TerminalIcon from '@mui/icons-material/Terminal'
import { Badge, Box, Fab, Modal, Tab, Tabs, Typography } from '@mui/material'
import { useTheme } from '@mui/material/styles'
import React, { useContext, useState } from 'react'

import { AppContext } from '../context/AppContext'
import StatusBoxAction from './StatusBoxAction'

const StatusBox: React.FC = () => {
const { appState } = useContext(AppContext)!
const [open, setOpen] = useState(false)
const [selectedActionIndex, setSelectedActionIndex] = useState(0)
const theme = useTheme()

const handleOpen = () => setOpen(true)
const handleClose = () => setOpen(false)
const handleChange = (event: React.SyntheticEvent, newValue: number) => {
setSelectedActionIndex(newValue)
}

if (appState.runningActions.length === 0) {
return null
}

return (
<div>
<Fab
color="primary"
aria-label="status"
onClick={handleOpen}
style={{ position: 'fixed', bottom: 16, right: 16, zIndex: 1000 }}
>
<Badge badgeContent={appState.runningActions.length} color="secondary">
<TerminalIcon />
</Badge>
</Fab>
<Modal
open={open}
onClose={handleClose}
sx={{
top: 'auto',
bottom: 0,
height: '50vh',
width: '100%',
}}
>
<Box
sx={{
color: theme.palette.text,
backgroundColor: theme.palette.background.default,
height: '100%',
}}
>
<Box
display="flex"
justifyContent="space-between"
alignItems="center"
>
<Tabs
value={selectedActionIndex}
onChange={handleChange}
variant="scrollable"
scrollButtons="auto"
sx={{ backgroundColor: theme.palette.background.default }}
>
{appState.runningActions.map((action, index) => (
<Tab
label={action.id || 'No Id'}
key={action.id}
sx={{ color: theme.palette.text.primary, fontSize: '10px' }}
/>
))}
</Tabs>
<Fab
size="small"
color="secondary"
onClick={handleClose}
sx={{ m: 1 }}
>
<CloseIcon />
</Fab>
</Box>

<StatusBoxAction
action={appState.runningActions[selectedActionIndex]}
/>
</Box>
</Modal>
</div>
)
}

export default StatusBox
17 changes: 17 additions & 0 deletions client/src/components/StatusBoxAction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Typography } from '@mui/material'
import React from 'react'

import { IAction } from '../types'

interface IStatusBoxActionProps {
action: IAction
}

const StatusBoxAction: React.FC<IStatusBoxActionProps> = ({ action }) => {
return (
<>
<Typography variant="caption">{action.title}</Typography>
</>
)
}
export default StatusBoxAction
3 changes: 3 additions & 0 deletions client/src/components/layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { RefineThemedLayoutV2Props } from '@refinedev/mui'
import { ThemedLayoutContextProvider } from '@refinedev/mui'
import type { FC } from 'react'

import StatusBox from '../StatusBox'
import { ThemedHeaderV2 as DefaultHeader } from './Header'

export const ThemedLayoutV2: FC<RefineThemedLayoutV2Props> = ({
Expand Down Expand Up @@ -35,6 +36,7 @@ export const ThemedLayoutV2: FC<RefineThemedLayoutV2Props> = ({
sx={{
flexGrow: 1,
bgcolor: (theme) => theme.palette.background.default,
paddingBlockEnd: '100px',
'& > .MuiPaper-root, & > div:not([class]) > .MuiPaper-root': {
borderRadius: {
xs: 0,
Expand All @@ -48,6 +50,7 @@ export const ThemedLayoutV2: FC<RefineThemedLayoutV2Props> = ({
{Footer && <Footer />}
</Box>
{OffLayoutArea && <OffLayoutArea />}
<StatusBox />
</Box>
</ThemedLayoutContextProvider>
)
Expand Down
Loading

0 comments on commit 2ebb016

Please sign in to comment.