Skip to content

Commit

Permalink
improved distinction between createSet and saveSet (overwrite) in the…
Browse files Browse the repository at this point in the history
… code and ensured that the confirm dialogue is always shown upon overwrite
  • Loading branch information
fde31 committed Jan 8, 2025
1 parent c4534b6 commit 0fc9807
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions src/components/sets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import { mdiEraser, mdiGroup } from "@mdi/js";
export type SetsDrawerProps = {
onClose: () => any;
onClearSet: () => any;
onCreateSet: (name: string) => any;
onDeleteSet: (set: GraphSetRecord) => any;
onLoadSet: (set: GraphSetRecord) => any;
onRenameSet: (set: GraphSetRecord, name: string) => any;
onSaveSet: (name: string) => any;
onSaveSetAs: (set: GraphSetRecord) => any;
onSaveSet: (set: GraphSetRecord) => any;
open: boolean;
sets: Seq.Indexed<GraphSetRecord>;
}
Expand All @@ -28,11 +28,11 @@ const SetsDrawer: FunctionComponent<SetsDrawerProps> = memo(function WrappedSets
sets,

onClearSet,
onCreateSet,
onDeleteSet,
onLoadSet,
onRenameSet,
onSaveSet,
onSaveSetAs
onSaveSet

}) {

Expand Down Expand Up @@ -86,7 +86,7 @@ const SetsDrawer: FunctionComponent<SetsDrawerProps> = memo(function WrappedSets
</Drawer.Header>
<Drawer.Body style={{ flex: 1 }} >
<Flex direction="column" style={{ height: "100%" }} gap="lg" >
<SaveGraphSetForm onSave={ onSaveSet } />
<SaveGraphSetForm onSave={ onCreateSet } />
<Divider />
<Flex className={ classes.setListWrapper } direction="column">
<DrawerSectionTitle>Saved Graph Sets</DrawerSectionTitle>
Expand All @@ -99,7 +99,7 @@ const SetsDrawer: FunctionComponent<SetsDrawerProps> = memo(function WrappedSets
onRename={ onRenameSet }
onLoad={ onLoadSet }
onDelete={ onTriggerDeleteSet }
onSave={ onSaveSetAs }
onSave={ onSaveSet }
validateUniqueName={ validateUniqueSetName }
/>
))
Expand Down
3 changes: 2 additions & 1 deletion src/components/sets/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ export const GraphSetItem: FunctionComponent<GraphSetItemProps> = memo(function
</Menu.Target>
<Menu.Dropdown>
<Menu.Label>Graph Set Actions</Menu.Label>
<Menu.Item leftSection={ <IconElement path={ mdiContentSave } /> } onClick={ onSaveSet } >{ set.latest ? "Save Changes" : "Overwrite" }</Menu.Item>
<Menu.Item leftSection={ <IconElement path={ mdiContentSave } /> } onClick={ onSaveSet } >Overwrite</Menu.Item>
<Menu.Item leftSection={ <IconElement path={ mdiPencil } /> } onClick={ toggleEditing } >Rename</Menu.Item>
<Menu.Divider />
<Menu.Item color="red" leftSection={ <IconElement path={ mdiTrashCan } /> } onClick={ onDeleteSet } >Delete</Menu.Item>
</Menu.Dropdown>
</Menu>
Expand Down
6 changes: 3 additions & 3 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ const Index: FunctionComponent<Record<string, never>> = () => {
dispatch(renameGraphSetOnRemote(set, name));
}, [dispatch]);

const onSaveSet = useCallback((name: string) => {
const onCreateSet = useCallback((name: string) => {
dispatch(saveGraphSetOnRemote(name));
}, [dispatch]);

const onSaveSetAs = useCallback((set: GraphSetRecord) => {
const onSaveSet = useCallback((set: GraphSetRecord) => {
if (set.latest) {
dispatch(saveGraphSetOnRemote(set.name));
} else {
Expand Down Expand Up @@ -268,8 +268,8 @@ const Index: FunctionComponent<Record<string, never>> = () => {
onDeleteSet={ onDeleteSet }
onLoadSet={ onLoadSet }
onRenameSet={ onRenameSet }
onCreateSet={ onCreateSet }
onSaveSet={ onSaveSet }
onSaveSetAs={ onSaveSetAs }
open={ setDrawerIsOpen }
sets={ graphSets }
/>
Expand Down

0 comments on commit 0fc9807

Please sign in to comment.