Skip to content

Commit 662a7f1

Browse files
Show loader skeleton in result view for running workflows (#705)
* init commit for loading * Add loader * fix test * Fix lint issue * Fix colours * update snapshots
1 parent 7d16a25 commit 662a7f1

File tree

10 files changed

+115
-11
lines changed

10 files changed

+115
-11
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { type Theme } from 'baseui';
2+
import { type SkeletonOverrides } from 'baseui/skeleton/types';
3+
import { type StyleObject } from 'styletron-react';
4+
5+
export const overrides = {
6+
borderSkeleton: {
7+
Row: {
8+
style: ({ $theme }: { $theme: Theme }): StyleObject => ({
9+
height: $theme.sizing.scale600,
10+
borderRadius: $theme.borders.radius500,
11+
}),
12+
},
13+
} satisfies SkeletonOverrides,
14+
centralSkeleton: {
15+
Root: {
16+
style: ({ $theme }: { $theme: Theme }): StyleObject => ({
17+
marginLeft: $theme.sizing.scale550,
18+
marginTop: $theme.sizing.scale400,
19+
marginBottom: $theme.sizing.scale400,
20+
}),
21+
},
22+
Row: {
23+
style: ({ $theme }: { $theme: Theme }): StyleObject => ({
24+
height: $theme.sizing.scale600,
25+
borderRadius: $theme.borders.radius500,
26+
}),
27+
},
28+
} satisfies SkeletonOverrides,
29+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use client';
2+
import { Skeleton } from 'baseui/skeleton';
3+
4+
import { overrides } from './pretty-json-skeleton.styles';
5+
import { type Props } from './pretty-json-skeleton.types';
6+
7+
export default function PrettyJsonSkeleton({ width }: Props) {
8+
return (
9+
<div>
10+
<Skeleton
11+
width="20px"
12+
rows={1}
13+
overrides={overrides.borderSkeleton}
14+
animation
15+
/>
16+
<Skeleton
17+
width={width}
18+
rows={3}
19+
overrides={overrides.centralSkeleton}
20+
animation
21+
/>
22+
<Skeleton
23+
width="20px"
24+
rows={1}
25+
overrides={overrides.borderSkeleton}
26+
animation
27+
/>
28+
</div>
29+
);
30+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export type Props = {
2+
width: string;
3+
};

src/config/theme/theme-light.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const themeLight = {
1212
colors: {
1313
borderOpaque: '#F3F3F3',
1414
backgroundSecondary: '#F3F3F3',
15+
backgroundTertiary: '#E8E8E8',
1516
backgroundWarningLight: '#FDF2DC',
1617
},
1718
} satisfies DeepPartial<MakeExtendable<Theme>>;

src/views/workflow-history/workflow-history-event-status-badge/__tests__/workflow-history-tab-event-status-badge.test.tsx.snapshot

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,14 @@ exports[`WorkflowHistoryEventStatusBadge should match snapshot when status is ON
376376
animationIterationCount: 'infinite',
377377
animationName: "keyFrames={\\n from: { transform: 'rotate(0deg)' },\\n to: { transform: 'rotate(360deg)' },\\n}\\n",
378378
animationTimingFunction: 'linear',
379-
borderBottomColor: '#EEEEEE',
379+
borderBottomColor: '#E8E8E8',
380380
borderBottomStyle: 'solid',
381381
borderBottomWidth: 'NaNpx',
382-
borderLeftColor: '#EEEEEE',
382+
borderLeftColor: '#E8E8E8',
383383
borderLeftStyle: 'solid',
384384
borderLeftWidth: 'NaNpx',
385385
borderRadius: '50%',
386-
borderRightColor: '#EEEEEE',
386+
borderRightColor: '#E8E8E8',
387387
borderRightStyle: 'solid',
388388
borderRightWidth: 'NaNpx',
389389
borderTopColor: '#276EF1',
@@ -441,14 +441,14 @@ exports[`WorkflowHistoryEventStatusBadge should match snapshot when status is ON
441441
animationIterationCount: 'infinite',
442442
animationName: "keyFrames={\\n from: { transform: 'rotate(0deg)' },\\n to: { transform: 'rotate(360deg)' },\\n}\\n",
443443
animationTimingFunction: 'linear',
444-
borderBottomColor: '#EEEEEE',
444+
borderBottomColor: '#E8E8E8',
445445
borderBottomStyle: 'solid',
446446
borderBottomWidth: 'NaNpx',
447-
borderLeftColor: '#EEEEEE',
447+
borderLeftColor: '#E8E8E8',
448448
borderLeftStyle: 'solid',
449449
borderLeftWidth: 'NaNpx',
450450
borderRadius: '50%',
451-
borderRightColor: '#EEEEEE',
451+
borderRightColor: '#E8E8E8',
452452
borderRightStyle: 'solid',
453453
borderRightWidth: 'NaNpx',
454454
borderTopColor: '#276EF1',

src/views/workflow-queries/workflow-queries-status-icon/__tests__/workflow-queries-status-icon.test.tsx.snapshot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ exports[`WorkflowQueriesStatusIcon should render correctly for fetching status 1
6363
animationIterationCount: 'infinite',
6464
animationName: "keyFrames={\\n from: { transform: 'rotate(0deg)' },\\n to: { transform: 'rotate(360deg)' },\\n}\\n",
6565
animationTimingFunction: 'linear',
66-
borderBottomColor: '#EEEEEE',
66+
borderBottomColor: '#E8E8E8',
6767
borderBottomStyle: 'solid',
6868
borderBottomWidth: 'NaNpx',
69-
borderLeftColor: '#EEEEEE',
69+
borderLeftColor: '#E8E8E8',
7070
borderLeftStyle: 'solid',
7171
borderLeftWidth: 'NaNpx',
7272
borderRadius: '50%',
73-
borderRightColor: '#EEEEEE',
73+
borderRightColor: '#E8E8E8',
7474
borderRightStyle: 'solid',
7575
borderRightWidth: 'NaNpx',
7676
borderTopColor: '#276EF1',

src/views/workflow-summary-tab/workflow-summary-tab-json-view/__tests__/workflow-summary-tab-json-view.test.tsx

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,19 @@ import WorkflowSummaryTabJsonView from '../workflow-summary-tab-json-view';
1010
jest.mock('copy-to-clipboard', jest.fn);
1111
jest.mock(
1212
'@/components/segmented-control-rounded/segmented-control-rounded',
13-
() => jest.fn(() => <div>SegmentedControlRounded Mock</div>)
13+
() =>
14+
jest.fn(({ onChange }) => (
15+
<div onClick={() => onChange({ activeKey: 'result' })}>
16+
SegmentedControlRounded Mock
17+
</div>
18+
))
1419
);
1520
jest.mock('@/components/pretty-json/pretty-json', () =>
1621
jest.fn(() => <div>PrettyJson Mock</div>)
1722
);
23+
jest.mock('@/components/pretty-json-skeleton/pretty-json-skeleton', () =>
24+
jest.fn(() => <div>Mock JSON skeleton</div>)
25+
);
1826

1927
describe('WorkflowSummaryTabJsonView Component', () => {
2028
const inputJson = { input: 'inputJson' };
@@ -25,6 +33,7 @@ describe('WorkflowSummaryTabJsonView Component', () => {
2533
<WorkflowSummaryTabJsonView
2634
inputJson={inputJson}
2735
resultJson={resultJson}
36+
isWorkflowRunning={false}
2837
/>
2938
);
3039

@@ -37,6 +46,7 @@ describe('WorkflowSummaryTabJsonView Component', () => {
3746
<WorkflowSummaryTabJsonView
3847
inputJson={inputJson}
3948
resultJson={resultJson}
49+
isWorkflowRunning={false}
4050
/>
4151
);
4252

@@ -46,11 +56,27 @@ describe('WorkflowSummaryTabJsonView Component', () => {
4656
expect(segmentedControl).toBeInTheDocument();
4757
});
4858

59+
it('renders loading state correctly', () => {
60+
const { getByText } = render(
61+
<WorkflowSummaryTabJsonView
62+
inputJson={inputJson}
63+
resultJson={resultJson}
64+
isWorkflowRunning={true}
65+
/>
66+
);
67+
68+
// Mock the onChange event for SegmentedControlRounded
69+
const segmentedControl = screen.getByText('SegmentedControlRounded Mock');
70+
fireEvent.click(segmentedControl);
71+
expect(getByText('Mock JSON skeleton')).toBeInTheDocument();
72+
});
73+
4974
it('copies JSON to clipboard', () => {
5075
render(
5176
<WorkflowSummaryTabJsonView
5277
inputJson={inputJson}
5378
resultJson={resultJson}
79+
isWorkflowRunning={false}
5480
/>
5581
);
5682

@@ -67,6 +93,7 @@ describe('WorkflowSummaryTabJsonView Component', () => {
6793
<WorkflowSummaryTabJsonView
6894
inputJson={inputJson}
6995
resultJson={resultJson}
96+
isWorkflowRunning={false}
7097
/>
7198
);
7299

src/views/workflow-summary-tab/workflow-summary-tab-json-view/workflow-summary-tab-json-view.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { MdCopyAll } from 'react-icons/md';
88

99
import PrettyJson from '@/components/pretty-json/pretty-json';
1010
import { type JsonValue } from '@/components/pretty-json/pretty-json.types';
11+
import PrettyJsonSkeleton from '@/components/pretty-json-skeleton/pretty-json-skeleton';
1112
import SegmentedControlRounded from '@/components/segmented-control-rounded/segmented-control-rounded';
1213
import useStyletronClasses from '@/hooks/use-styletron-classes';
1314

@@ -18,6 +19,7 @@ import type { Props } from './workflow-summary-tab-json-view.types';
1819
export default function WorkflowSummaryTabJsonView({
1920
inputJson,
2021
resultJson,
22+
isWorkflowRunning,
2123
}: Props) {
2224
const { cls } = useStyletronClasses(cssStyles);
2325
const [showTooltip, setShowTooltip] = useState(false);
@@ -67,7 +69,11 @@ export default function WorkflowSummaryTabJsonView({
6769
</Button>
6870
</Tooltip>
6971
</div>
70-
<PrettyJson json={jsonMap[activeTab]} />
72+
{activeTab === 'result' && isWorkflowRunning ? (
73+
<PrettyJsonSkeleton width="200px" />
74+
) : (
75+
<PrettyJson json={jsonMap[activeTab]} />
76+
)}
7177
</div>
7278
);
7379
}

src/views/workflow-summary-tab/workflow-summary-tab-json-view/workflow-summary-tab-json-view.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ import { type JsonValue } from '@/components/pretty-json/pretty-json.types';
33
export type Props = {
44
inputJson: JsonValue;
55
resultJson: JsonValue;
6+
isWorkflowRunning: boolean;
67
};

src/views/workflow-summary-tab/workflow-summary-tab.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import request from '@/utils/request';
1515
import { type RequestError } from '@/utils/request/request-error';
1616
import type { WorkflowPageTabContentProps } from '@/views/workflow-page/workflow-page-tab-content/workflow-page-tab-content.types';
1717

18+
import getWorkflowIsCompleted from '../workflow-page/helpers/get-workflow-is-completed';
1819
import useDescribeWorkflow from '../workflow-page/hooks/use-describe-workflow';
1920

2021
import WorkflowSummaryTabDetails from './workflow-summary-tab-details/workflow-summary-tab-details';
@@ -62,6 +63,11 @@ export default function WorkflowSummaryTab({
6263
? formattedCloseEvent.result
6364
: undefined;
6465

66+
const isWorkflowRunning =
67+
!closeEvent ||
68+
!closeEvent.attributes ||
69+
!getWorkflowIsCompleted(closeEvent.attributes);
70+
6571
return (
6672
<PageSection>
6773
<div className={cls.pageContainer}>
@@ -84,6 +90,7 @@ export default function WorkflowSummaryTab({
8490
: []
8591
}
8692
resultJson={resultJson}
93+
isWorkflowRunning={isWorkflowRunning}
8794
/>
8895
</div>
8996
</div>

0 commit comments

Comments
 (0)