Skip to content

Commit

Permalink
Fixed dialog states
Browse files Browse the repository at this point in the history
  • Loading branch information
roll committed Nov 26, 2024
1 parent 2f099df commit d980936
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const { state, useState, resetState } = helpers.createState(
export function closeDialog() {
if (!state.progress?.blocking) {
appStore.closeDialog()
resetState()
}
}

Expand Down
8 changes: 8 additions & 0 deletions client/components/Application/Dialogs/Assistant/Assistant.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import TwoButtonDialog from '@client/components/Parts/Dialogs/TwoButton'
import * as appStore from '@client/store'
import AutoFixHighIcon from '@mui/icons-material/AutoFixHigh'
import Box from '@mui/material/Box'
import LinearProgress from '@mui/material/LinearProgress'
Expand All @@ -18,6 +19,11 @@ and provide descriptions for each of them

export function AssistantDialog() {
const state = store.useState()
const dialog = appStore.useStore((state) => state.dialog)

React.useEffect(() => {
store.resetState()
}, [dialog])

switch (state.step) {
case 'terms':
Expand Down Expand Up @@ -61,6 +67,7 @@ function CredsStepDialog() {
<Box>Please enter your OpenAI API key:</Box>
<StyledTextField
fullWidth
autoFocus
label="OpenAI API Key"
variant="outlined"
value={key}
Expand Down Expand Up @@ -88,6 +95,7 @@ function PromptStepDialog() {
<Stack spacing={1}>
<Box>Please enter your prompt to the AI assistant:</Box>
<StyledTextField
autoFocus
value={prompt}
label="Prompt"
variant="outlined"
Expand Down
11 changes: 9 additions & 2 deletions client/components/Application/Dialogs/FileUpload/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import iconUploadFileImg from '@client/assets/icon_upload_file.png'
import DialogTabs from '@client/components//Parts/Tabs/Dialog'
import SimpleButton from '@client/components/Parts/Buttons/SimpleButton'
import Columns from '@client/components/Parts/Grids/Columns'
import * as appStore from '@client/store'
import CloseIcon from '@mui/icons-material/Close'
import Box from '@mui/material/Box'
import Dialog from '@mui/material/Dialog'
Expand All @@ -23,6 +24,11 @@ const TAB_LABELS = ['From your computer', 'Add external data']

export function FileUploadDialog() {
const { progress } = store.useState()
const dialog = appStore.useStore((state) => state.dialog)

React.useEffect(() => {
store.resetState()
}, [dialog])

return (
<Dialog
Expand Down Expand Up @@ -62,14 +68,14 @@ export function FileUploadDialog() {
disabled={progress?.blocking}
onChange={store.resetState}
>
<Box sx={{ minHeight: '20em' }}>
<Box>
<Columns columns={2} spacing={4}>
<LocalFileForm />
<LocalFileForm isFolder />
</Columns>
<ProgressIndicator />
</Box>
<Box sx={{ minHeight: '20em' }}>
<Box>
<RemoteFileForm />
<ProgressIndicator />
</Box>
Expand Down Expand Up @@ -191,6 +197,7 @@ function AddRemoteTextField(props: {
<StyledTextField
fullWidth
size="small"
autoFocus
value={props.value || ''}
disabled={props.disabled}
error={props.invalid}
Expand Down
4 changes: 2 additions & 2 deletions client/store/actions/app.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { client } from '@client/client'
import * as settings from '@client/settings'
import { redoTableChange, togglePanel, undoTableChange } from '@client/store'
import delay from 'delay'
import * as store from '../store'
Expand Down Expand Up @@ -28,7 +28,7 @@ export async function onAppStart() {
} catch (error) {
attempt += 1
if (attempt >= maxAttempts) {
const serverUrl = client.serverUrl
const serverUrl = settings.SERVER_URL
const message = `Client cannot connect to server on "${serverUrl}"`
sendFatalError ? sendFatalError(message) : alert(message)
}
Expand Down

0 comments on commit d980936

Please sign in to comment.