Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit 39c147b

Browse files
authored
UX improvement delete dashboard modal (#368)
1 parent 1e97253 commit 39c147b

File tree

4 files changed

+87
-58
lines changed

4 files changed

+87
-58
lines changed

src/pages/Dashboards/Dashboard.tsx

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ import { useAppStore } from '@/layouts/MainLayout/providers/AppProvider';
2323
import { EditTileType, ImportDashboardType, Tile as TileType } from '@/@types/parseable/api/dashboards';
2424
import { templates } from './assets/templates';
2525

26-
const { toggleCreateDashboardModal, toggleCreateTileModal, toggleDuplicateTileModal, toggleDeleteTileModal, handlePaging, toggleImportDashboardModal } =
27-
dashboardsStoreReducers;
26+
const {
27+
toggleCreateDashboardModal,
28+
toggleCreateTileModal,
29+
toggleDuplicateTileModal,
30+
toggleDeleteTileModal,
31+
handlePaging,
32+
toggleImportDashboardModal,
33+
} = dashboardsStoreReducers;
2834

2935
const TilesView = (props: { onLayoutChange: (layout: Layout[]) => void }) => {
3036
const [activeDashboard, setDashbaordsStore] = useDashboardsStore((store) => store.activeDashboard);
@@ -66,7 +72,7 @@ const TilesView = (props: { onLayoutChange: (layout: Layout[]) => void }) => {
6672
if (showNoTilesView) return <NoTilesView />;
6773

6874
return (
69-
<Stack ref={scrollRef} className={classes.tilesViewConatiner} style={{ overflowY: 'scroll' }}>
75+
<Stack ref={scrollRef} className={classes.tilesViewContainer} style={{ overflowY: 'scroll' }}>
7076
<GridLayout
7177
className="layout"
7278
layout={layout}
@@ -151,7 +157,10 @@ const DeleteTileModal = () => {
151157
);
152158
};
153159

154-
const DashboardTemplates = (props: {onImport: (template: ImportDashboardType) => void; isImportingDashboard: boolean}) => {
160+
const DashboardTemplates = (props: {
161+
onImport: (template: ImportDashboardType) => void;
162+
isImportingDashboard: boolean;
163+
}) => {
155164
return (
156165
<Stack gap={0} mt={6}>
157166
{_.map(templates, (template) => {
@@ -174,12 +183,12 @@ const DashboardTemplates = (props: {onImport: (template: ImportDashboardType) =>
174183
})}
175184
</Stack>
176185
);
177-
}
186+
};
178187

179188
const ImportDashboardModal = () => {
180189
const [importDashboardModalOpen, setDashboardStore] = useDashboardsStore((store) => store.importDashboardModalOpen);
181190
const [activeDashboard] = useDashboardsStore((store) => store.activeDashboard);
182-
const [isStandAloneMode] = useAppStore(store => store.isStandAloneMode)
191+
const [isStandAloneMode] = useAppStore((store) => store.isStandAloneMode);
183192
const [file, setFile] = useState<File | null>(null);
184193
const closeModal = useCallback(() => {
185194
setDashboardStore((store) => toggleImportDashboardModal(store, false));
@@ -208,9 +217,9 @@ const ImportDashboardModal = () => {
208217
const newDashboard: ImportDashboardType = JSON.parse(target.result);
209218
if (_.isEmpty(newDashboard)) return;
210219

211-
return makePostCall(newDashboard)
220+
return makePostCall(newDashboard);
212221
} catch (error) {
213-
console.log("error", error)
222+
console.log('error', error);
214223
}
215224
};
216225
reader.readAsText(file);
@@ -336,13 +345,13 @@ const InvalidDashboardView = () => {
336345
};
337346

338347
const findTileByTileId = (tiles: TileType[], tileId: string | null) => {
339-
return _.find(tiles, tile => tile.tile_id === tileId)
340-
}
348+
return _.find(tiles, (tile) => tile.tile_id === tileId);
349+
};
341350

342351
const DuplicateTileModal = () => {
343-
const [duplicateTileModalOpen, setDashboardsStore] = useDashboardsStore(store => store.duplicateTileModalOpen)
344-
const [editTileId] = useDashboardsStore(store => store.editTileId);
345-
const [activeDashboard] = useDashboardsStore(store => store.activeDashboard)
352+
const [duplicateTileModalOpen, setDashboardsStore] = useDashboardsStore((store) => store.duplicateTileModalOpen);
353+
const [editTileId] = useDashboardsStore((store) => store.editTileId);
354+
const [activeDashboard] = useDashboardsStore((store) => store.activeDashboard);
346355
const [inputValue, setInputValue] = useState<string>('');
347356
const onClose = useCallback(() => {
348357
setDashboardsStore((store) => toggleDuplicateTileModal(store, false, null));
@@ -399,7 +408,9 @@ const DuplicateTileModal = () => {
399408
</Button>
400409
</Box>
401410
<Box>
402-
<Button onClick={handleSubmit} loading={isUpdatingDashboard} disabled={_.isEmpty(inputValue)}>Done</Button>
411+
<Button onClick={handleSubmit} loading={isUpdatingDashboard} disabled={_.isEmpty(inputValue)}>
412+
Done
413+
</Button>
403414
</Box>
404415
</Stack>
405416
</Stack>
@@ -422,9 +433,9 @@ const Dashboard = () => {
422433
return (
423434
<Stack style={{ flex: 1 }} gap={0}>
424435
<DeleteTileModal />
425-
<DuplicateTileModal/>
436+
<DuplicateTileModal />
426437
<Toolbar layoutRef={layoutRef} />
427-
<ImportDashboardModal/>
438+
<ImportDashboardModal />
428439
{activeDashboard ? <TilesView onLayoutChange={onLayoutChange} /> : <InvalidDashboardView />}
429440
</Stack>
430441
);

src/pages/Dashboards/Toolbar.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,15 @@ const DeleteDashboardModal = () => {
158158
<Text className={classes.deleteWarningText}>
159159
Are you sure want to delete this dashboard and its contents ?
160160
</Text>
161+
<Text className={classes.deleteConfirmationText}>
162+
Please type <span className={classes.deleteConfirmationTextHighlight}>{`"${activeDashboard.name}"`}</span>{' '}
163+
to confirm deletion.
164+
</Text>
165+
161166
<TextInput
162167
value={confirmText}
163168
onChange={onChangeHandler}
164-
placeholder={'Type the dashboard name to confirm. ie ' + activeDashboard.name}
169+
placeholder={'Type the dashboard name to confirm.'}
165170
/>
166171
</Stack>
167172
<Stack style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-end' }}>

src/pages/Dashboards/styles/DashboardView.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
align-self: center;
1717
}
1818

19+
.tilesViewContainer {
20+
margin-bottom: 1rem;
21+
}
22+
1923
.dashboardIcon {
2024
color: var(--mantine-color-brandPrimary-4);
2125
}
Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,80 @@
11
.editLayoutBtn {
2-
color: var(--mantine-color-gray-7);
3-
border: 1px #e9ecef solid;
4-
border-radius: rem(8px);
5-
font-size: 0.65rem;
2+
color: var(--mantine-color-gray-7);
3+
border: 1px #e9ecef solid;
4+
border-radius: rem(8px);
5+
font-size: 0.65rem;
66

7-
&:hover {
8-
color: black;
9-
background-color: white;
10-
}
7+
&:hover {
8+
color: black;
9+
background-color: white;
10+
}
1111

12-
&.active {
13-
color: white;
12+
&.active {
13+
color: white;
1414

15-
&:hover {
16-
background-color: var(--mantine-color-brandPrimary-4);
17-
color: white;
18-
}
19-
}
15+
&:hover {
16+
background-color: var(--mantine-color-brandPrimary-4);
17+
color: white;
18+
}
19+
}
2020
}
2121

2222
.addTileBtn {
23-
background-color: white;
24-
color: var(--mantine-color-gray-7);
25-
border: 1px #e9ecef solid;
26-
border-radius: rem(8px);
27-
font-size: 0.65rem;
23+
background-color: white;
24+
color: var(--mantine-color-gray-7);
25+
border: 1px #e9ecef solid;
26+
border-radius: rem(8px);
27+
font-size: 0.65rem;
2828

29-
&:hover {
30-
color: black;
31-
}
29+
&:hover {
30+
color: black;
31+
}
3232
}
3333

3434
.addTileBtn:hover {
35-
background-color: #E0E0E0;
35+
background-color: #e0e0e0;
3636
}
3737

3838
.editLayoutBtn:hover {
39-
background-color: #E0E0E0;
39+
background-color: #e0e0e0;
4040
}
4141

4242
.toolbarContainer {
43-
padding: 0.4rem 0.8rem;
44-
border-bottom: 1px solid var(--mantine-color-gray-1);
43+
padding: 0.4rem 0.8rem;
44+
border-bottom: 1px solid var(--mantine-color-gray-1);
4545
}
4646

4747
.dashboardTitle {
48-
font-size: 0.8rem;
49-
font-weight: 500;
48+
font-size: 0.8rem;
49+
font-weight: 500;
5050
}
5151

5252
.dashboardDescription {
53-
font-size: 0.7rem;
54-
color: var(--mantine-color-gray-6);
53+
font-size: 0.7rem;
54+
color: var(--mantine-color-gray-6);
5555
}
5656

5757
.editIcon {
58-
padding: 0.25rem;
59-
cursor: pointer;
60-
border-radius: 50%;
61-
margin-left: 0.2rem;
58+
padding: 0.25rem;
59+
cursor: pointer;
60+
border-radius: 50%;
61+
margin-left: 0.2rem;
6262

63-
&:hover {
64-
background-color: var(--mantine-color-gray-1);
65-
}
63+
&:hover {
64+
background-color: var(--mantine-color-gray-1);
65+
}
6666
}
6767

6868
.deleteWarningText {
69-
font-size: 0.7rem;
70-
color: var(--mantine-color-gray-6);
71-
}
69+
font-size: 0.7rem;
70+
color: var(--mantine-color-gray-7);
71+
}
72+
73+
.deleteConfirmationText {
74+
font-size: 0.7rem;
75+
color: var(--mantine-color-gray-6);
76+
}
77+
78+
.deleteConfirmationTextHighlight {
79+
font-weight: 500;
80+
}

0 commit comments

Comments
 (0)