Skip to content

Commit 2010733

Browse files
committed
work in progress on deleting snapshots
1 parent 767e397 commit 2010733

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

src/packages/frontend/project/explorer/action-bar.tsx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,17 @@ export function ActionBar({
165165
}
166166
}
167167

168-
function render_action_button(name: FileAction): React.JSX.Element {
169-
const disabled =
170-
isDisabledSnapshots(name) &&
171-
(current_path != null
172-
? current_path.startsWith(SNAPSHOTS)
173-
: undefined);
168+
function render_action_button(name: FileAction) {
169+
if (isSnapshotPath(current_path) && isDisabledSnapshots(name)) {
170+
return null;
171+
}
174172
const obj = file_actions[name];
175173
const handle_click = (_e: React.MouseEvent) => {
176174
actions.set_file_action(name);
177175
};
178176

179177
return (
180-
<Button onClick={handle_click} disabled={disabled} key={name}>
178+
<Button onClick={handle_click} key={name}>
181179
<Icon name={obj.icon} />{" "}
182180
<VisibleMDLG>{`${intl.formatMessage(obj.name)}...`}</VisibleMDLG>
183181
</Button>
@@ -297,13 +295,18 @@ export const ACTION_BUTTONS_MULTI = [
297295
"copy",
298296
] as const;
299297

298+
const DISABLED_SNAPSHOT_ACTIONS = new Set([
299+
"move",
300+
"compress",
301+
"rename",
302+
"share",
303+
"duplicate",
304+
]);
305+
300306
export function isDisabledSnapshots(name: string) {
301-
return [
302-
"move",
303-
"compress",
304-
"rename",
305-
"delete",
306-
"share",
307-
"duplicate",
308-
].includes(name);
307+
return DISABLED_SNAPSHOT_ACTIONS.has(name);
308+
}
309+
310+
export function isSnapshotPath(path?: string) {
311+
return path == SNAPSHOTS || path?.startsWith(SNAPSHOTS + "/");
309312
}

src/packages/frontend/project/explorer/action-box.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export function ActionBox({
171171
actions.open_directory(SNAPSHOTS);
172172
}}
173173
>
174-
~/.snapshots
174+
{SNAPSHOTS}
175175
</a>{" "}
176176
directory.
177177
</div>

0 commit comments

Comments
 (0)