diff options
Diffstat (limited to 'subprojects/frontend/src/editor/GenerateButton.tsx')
-rw-r--r-- | subprojects/frontend/src/editor/GenerateButton.tsx | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/subprojects/frontend/src/editor/GenerateButton.tsx b/subprojects/frontend/src/editor/GenerateButton.tsx index 3837ef8e..5bac0464 100644 --- a/subprojects/frontend/src/editor/GenerateButton.tsx +++ b/subprojects/frontend/src/editor/GenerateButton.tsx | |||
@@ -4,10 +4,8 @@ | |||
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
6 | 6 | ||
7 | import DangerousOutlinedIcon from '@mui/icons-material/DangerousOutlined'; | 7 | import CancelIcon from '@mui/icons-material/Cancel'; |
8 | import PlayArrowIcon from '@mui/icons-material/PlayArrow'; | 8 | import PlayArrowIcon from '@mui/icons-material/PlayArrow'; |
9 | import Button from '@mui/material/Button'; | ||
10 | import type { SxProps, Theme } from '@mui/material/styles'; | ||
11 | import { observer } from 'mobx-react-lite'; | 9 | import { observer } from 'mobx-react-lite'; |
12 | 10 | ||
13 | import AnimatedButton from './AnimatedButton'; | 11 | import AnimatedButton from './AnimatedButton'; |
@@ -18,26 +16,45 @@ const GENERATE_LABEL = 'Generate'; | |||
18 | const GenerateButton = observer(function GenerateButton({ | 16 | const GenerateButton = observer(function GenerateButton({ |
19 | editorStore, | 17 | editorStore, |
20 | hideWarnings, | 18 | hideWarnings, |
21 | sx, | ||
22 | }: { | 19 | }: { |
23 | editorStore: EditorStore | undefined; | 20 | editorStore: EditorStore | undefined; |
24 | hideWarnings?: boolean | undefined; | 21 | hideWarnings?: boolean | undefined; |
25 | sx?: SxProps<Theme> | undefined; | ||
26 | }): JSX.Element { | 22 | }): JSX.Element { |
27 | if (editorStore === undefined) { | 23 | if (editorStore === undefined) { |
28 | return ( | 24 | return ( |
29 | <Button | 25 | <AnimatedButton color="inherit" disabled> |
30 | color="inherit" | ||
31 | className="rounded shaded" | ||
32 | disabled | ||
33 | {...(sx === undefined ? {} : { sx })} | ||
34 | > | ||
35 | Loading… | 26 | Loading… |
36 | </Button> | 27 | </AnimatedButton> |
28 | ); | ||
29 | } | ||
30 | |||
31 | const { analyzing, errorCount, warningCount, semanticsError } = | ||
32 | editorStore.delayedErrors; | ||
33 | |||
34 | if (analyzing) { | ||
35 | return ( | ||
36 | <AnimatedButton color="inherit" disabled> | ||
37 | Analyzing… | ||
38 | </AnimatedButton> | ||
37 | ); | 39 | ); |
38 | } | 40 | } |
39 | 41 | ||
40 | const { errorCount, warningCount } = editorStore; | 42 | if (semanticsError !== undefined && editorStore.opened) { |
43 | return ( | ||
44 | <AnimatedButton | ||
45 | color="error" | ||
46 | disabled | ||
47 | startIcon={<CancelIcon />} | ||
48 | sx={(theme) => ({ | ||
49 | '&.Mui-disabled': { | ||
50 | color: `${theme.palette.error.main} !important`, | ||
51 | }, | ||
52 | })} | ||
53 | > | ||
54 | Analysis error | ||
55 | </AnimatedButton> | ||
56 | ); | ||
57 | } | ||
41 | 58 | ||
42 | const diagnostics: string[] = []; | 59 | const diagnostics: string[] = []; |
43 | if (errorCount > 0) { | 60 | if (errorCount > 0) { |
@@ -54,8 +71,7 @@ const GenerateButton = observer(function GenerateButton({ | |||
54 | aria-label={`Select next diagnostic out of ${summary}`} | 71 | aria-label={`Select next diagnostic out of ${summary}`} |
55 | onClick={() => editorStore.nextDiagnostic()} | 72 | onClick={() => editorStore.nextDiagnostic()} |
56 | color="error" | 73 | color="error" |
57 | startIcon={<DangerousOutlinedIcon />} | 74 | startIcon={<CancelIcon />} |
58 | {...(sx === undefined ? {} : { sx })} | ||
59 | > | 75 | > |
60 | {summary} | 76 | {summary} |
61 | </AnimatedButton> | 77 | </AnimatedButton> |
@@ -67,7 +83,6 @@ const GenerateButton = observer(function GenerateButton({ | |||
67 | disabled={!editorStore.opened} | 83 | disabled={!editorStore.opened} |
68 | color={warningCount > 0 ? 'warning' : 'primary'} | 84 | color={warningCount > 0 ? 'warning' : 'primary'} |
69 | startIcon={<PlayArrowIcon />} | 85 | startIcon={<PlayArrowIcon />} |
70 | {...(sx === undefined ? {} : { sx })} | ||
71 | > | 86 | > |
72 | {summary === '' ? GENERATE_LABEL : `${GENERATE_LABEL} (${summary})`} | 87 | {summary === '' ? GENERATE_LABEL : `${GENERATE_LABEL} (${summary})`} |
73 | </AnimatedButton> | 88 | </AnimatedButton> |
@@ -76,7 +91,6 @@ const GenerateButton = observer(function GenerateButton({ | |||
76 | 91 | ||
77 | GenerateButton.defaultProps = { | 92 | GenerateButton.defaultProps = { |
78 | hideWarnings: false, | 93 | hideWarnings: false, |
79 | sx: undefined, | ||
80 | }; | 94 | }; |
81 | 95 | ||
82 | export default GenerateButton; | 96 | export default GenerateButton; |