Skip to content

Commit 0e8ff86

Browse files
authored
fix: show refresh notification on failed dynamic import
* Implemented e2e approach to handle failed fetching of dynamically imported module * Several dynamically imported modules wrapped with new error boundary * Removed unused MonacoDiffEditor * fix: notification wording * Fixed styles and content of ModuleFetchingErrorDialog * Style of DialogTitle has been aligned to mockups everywhere * Styles for DialogContent, DialogContentText have been aligned to mockups. Fixed test id
1 parent 03d5101 commit 0e8ff86

File tree

14 files changed

+193
-246
lines changed

14 files changed

+193
-246
lines changed

packages/editor/src/components/ConfirmationDialog.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,12 @@ export const ConfirmationDialog: FC<ConfirmationDialogProps> = memo<Confirmation
5656
sx={{ position: 'absolute', right: 8, top: 8, color: '#353C4E' }}
5757
onClick={onCancel}
5858
>
59-
<CloseOutlinedIcon fontSize="small"/>
59+
<CloseOutlinedIcon fontSize="small" />
6060
</IconButton>
6161
</DialogTitle>
6262

6363
<DialogContent>
64-
<DialogContentText
65-
variant="body2"
66-
sx={{ color: 'black' }}
67-
>
64+
<DialogContentText variant="body2">
6865
{message}
6966
</DialogContentText>
7067
</DialogContent>
@@ -95,5 +92,5 @@ function useCloseOnLoadingFinish(
9592
enabled?: boolean,
9693
): void {
9794
// eslint-disable-next-line react-hooks/exhaustive-deps
98-
useEffect(() => {enabled && !loading && onClose?.()}, [enabled, loading])
95+
useEffect(() => { enabled && !loading && onClose?.() }, [enabled, loading])
9996
}

packages/editor/src/components/MonacoDiffEditor/MonacoDiffEditor.tsx

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

packages/editor/src/components/MonacoDiffEditor/MonacoDiffEditorElement.tsx

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

packages/editor/src/components/MonacoDiffEditor/useMonacoDiffEditorElement.ts

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

packages/editor/src/routes/root/EditorPage/ProjectEditorPage/ProjectEditorBody/ProjectEditorBody.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { FilesModeBody } from './FilesModeBody/FilesModeBody'
2626
import { PublishModeBody } from './PublishModeBody/PublishModeBody'
2727
import { ChangesModeBody } from './ChangesModeBody/ChangesModeBody'
2828
import { SettingsModeBody } from './SettingsModeBody/SettingsModeBody'
29+
import { ModuleFetchingErrorBoundary } from '@netcracker/qubership-apihub-ui-shared/components/ModuleFetchingErrorBoundary/ModuleFetchingErrorBoundary'
2930

3031
export const ProjectEditorBody: FC = memo(() => {
3132
const isFilesEditorPageMode = useIsFilesProjectEditorMode()
@@ -35,7 +36,9 @@ export const ProjectEditorBody: FC = memo(() => {
3536

3637
if (isFilesEditorPageMode) {
3738
return (
38-
<FilesModeBody/>
39+
<ModuleFetchingErrorBoundary>
40+
<FilesModeBody/>
41+
</ModuleFetchingErrorBoundary>
3942
)
4043
}
4144

packages/editor/src/routes/root/EditorPage/ProjectEditorPage/ProjectEditorSidebar/PublishTabPanel/BwcPublishProjectVersionDialog.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { waitForSocketEvent } from '@netcracker/qubership-apihub-ui-shared/utils
3030
export const BwcPublishProjectVersionDialog: FC = memo(() => (
3131
<PopupDelegate
3232
type={SHOW_BWC_PUBLISH_PROJECT_VERSION_DIALOG}
33-
render={props => <BwcPublishProjectVersionPopup {...props}/>}
33+
render={props => <BwcPublishProjectVersionPopup {...props} />}
3434
/>
3535
))
3636

@@ -61,10 +61,7 @@ const BwcPublishProjectVersionPopup: FC<PopupProps> = memo<PopupProps>(({ open,
6161
</DialogTitle>
6262

6363
<DialogContent sx={{ width: 440 }}>
64-
<DialogContentText
65-
variant="body2"
66-
sx={{ color: 'black' }}
67-
>
64+
<DialogContentText variant="body2">
6865
There are breaking changes in current version. Do you want to publish it anyway?
6966
</DialogContentText>
7067
</DialogContent>

packages/portal/src/routes/root/PortalPage/VersionPage/OperationContent/OperationWithPlayground.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,19 @@
1414
* limitations under the License.
1515
*/
1616

17-
import type { FC, ReactNode } from 'react'
18-
import React, { memo } from 'react'
19-
import { Box } from '@mui/material'
20-
import { Resizable } from 're-resizable'
17+
import { Examples } from '@apihub/routes/root/PortalPage/VersionPage/OperationContent/Playground/Examples/Examples'
18+
import { Playground } from '@apihub/routes/root/PortalPage/VersionPage/OperationContent/Playground/Playground'
2119
import {
2220
usePlaygroundEvents,
2321
} from '@apihub/routes/root/PortalPage/VersionPage/OperationContent/Playground/usePlaygroundEvents'
24-
import { Playground } from '@apihub/routes/root/PortalPage/VersionPage/OperationContent/Playground/Playground'
25-
import { Examples } from '@apihub/routes/root/PortalPage/VersionPage/OperationContent/Playground/Examples/Examples'
22+
import { Box } from '@mui/material'
23+
import { ModuleFetchingErrorBoundary } from '@netcracker/qubership-apihub-ui-shared/components/ModuleFetchingErrorBoundary/ModuleFetchingErrorBoundary'
24+
import { NAVIGATION_MAX_WIDTH } from '@netcracker/qubership-apihub-ui-shared/utils/page-layouts'
25+
import { Resizable } from 're-resizable'
26+
import type { FC, ReactNode } from 'react'
27+
import { memo } from 'react'
2628
import { CreateCustomServerDialog } from './Playground/CreateCustomServerDialog'
2729
import { ExamplesDialog } from './Playground/Examples/ExamplesDialog'
28-
import { NAVIGATION_MAX_WIDTH } from '@netcracker/qubership-apihub-ui-shared/utils/page-layouts'
2930

3031
export type OperationWithPlaygroundProps = {
3132
changedOperationContent: string
@@ -61,7 +62,6 @@ export const OperationWithPlayground: FC<OperationWithPlaygroundProps> = memo<Op
6162
backgroundColor: '#FFFFFF',
6263
paddingRight: '24px',
6364
}}
64-
6565
enable={{
6666
top: false,
6767
right: false,
@@ -77,13 +77,15 @@ export const OperationWithPlayground: FC<OperationWithPlaygroundProps> = memo<Op
7777
maxWidth={PLAYGROUND_MAX_WIDTH}
7878
minWidth="300px"
7979
>
80-
{isPlaygroundMode && <Playground document={changedOperationContent} customServers={customServers}/>}
81-
{isExamplesMode && <Examples document={changedOperationContent}/>}
80+
<ModuleFetchingErrorBoundary>
81+
{isPlaygroundMode && <Playground document={changedOperationContent} customServers={customServers} />}
82+
{isExamplesMode && <Examples document={changedOperationContent} />}
83+
</ModuleFetchingErrorBoundary>
8284
</Resizable>
8385
)}
8486

85-
<CreateCustomServerDialog/>
86-
<ExamplesDialog document={changedOperationContent}/>
87+
<CreateCustomServerDialog />
88+
<ExamplesDialog document={changedOperationContent} />
8789
</Box>
8890
)
8991
})

packages/portal/src/routes/root/PortalPage/VersionPage/OperationContent/Playground/Playground.tsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@ export type PlaygroundProps = PropsWithChildren<{
2929
const PlaygroundElement: FC<PlaygroundElementProps> = lazy(() => import('./PlaygroundElement'))
3030

3131
export const Playground: FC<PlaygroundProps> = memo<PlaygroundProps>(({ document, customServers }) => {
32-
return (
33-
<Suspense fallback={<LoadingIndicator/>}>
34-
<Box lineHeight={1.5} height="100%" width="100%" data-testid="PlaygroundPanel">
35-
<PlaygroundElement
36-
key={crypto.randomUUID()}
37-
document={document}
38-
customServers={customServers}
39-
token={getToken()}
40-
origin={window.location.origin}
41-
/>
42-
</Box>
43-
</Suspense>
44-
)
45-
},
46-
)
32+
return (
33+
<Suspense fallback={<LoadingIndicator />}>
34+
<Box lineHeight={1.5} height="100%" width="100%" data-testid="PlaygroundPanel">
35+
<PlaygroundElement
36+
key={crypto.randomUUID()}
37+
document={document}
38+
customServers={customServers}
39+
token={getToken()}
40+
origin={window.location.origin}
41+
/>
42+
</Box>
43+
</Suspense>
44+
)
45+
})

packages/shared/src/components/ConfirmationDialog.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,13 @@ export const ConfirmationDialog: FC<ConfirmationDialogProps> = memo<Confirmation
4949
open={open}
5050
onClose={onCancel}
5151
>
52-
<DialogTitle sx={{ fontSize: 15, fontWeight: 600, color: 'black' }}>
52+
<DialogTitle>
5353
{title}
5454
</DialogTitle>
5555

5656
<DialogContent>
5757
<DialogContentText
5858
variant="body2"
59-
sx={{ color: 'black' }}
6059
data-testid="ConfirmationDialogContent"
6160
>
6261
{message}

0 commit comments

Comments
 (0)