From f5e19f9446203c3fbe272f4d735e455d83e63e27 Mon Sep 17 00:00:00 2001 From: Ahmed Awan Date: Fri, 8 Mar 2024 14:30:28 -0600 Subject: [PATCH] prevent keyboard/click select for unowned histories --- .../History/Content/ContentItem.vue | 71 +++++++++++-------- .../History/CurrentHistory/HistoryPanel.vue | 6 +- client/src/components/History/HistoryView.vue | 1 - 3 files changed, 44 insertions(+), 34 deletions(-) diff --git a/client/src/components/History/Content/ContentItem.vue b/client/src/components/History/Content/ContentItem.vue index 0e5497d645cf..70059b96f614 100644 --- a/client/src/components/History/Content/ContentItem.vue +++ b/client/src/components/History/Content/ContentItem.vue @@ -185,41 +185,54 @@ function onKeyDown(event: KeyboardEvent) { if (event.key === "Enter" || event.key === " ") { event.preventDefault(); - onClick(event); - } else if ((event.key === "ArrowUp" || event.key === "ArrowDown") && event.shiftKey) { - event.preventDefault(); - emit("shift-select", event.key); - } else if (event.key === "ArrowUp" || event.key === "ArrowDown") { + onClick(); + } else if ((event.key === "ArrowUp" || event.key === "ArrowDown") && !event.shiftKey) { event.preventDefault(); - emit("init-key-selection"); emit("arrow-navigate", event.key); - } else if (event.key === "Tab") { - emit("init-key-selection"); - } else if (event.key === "Delete" && !props.selected && !props.item.deleted) { - event.preventDefault(); - onDelete(event.shiftKey); - } else if (event.key === "Escape") { - event.preventDefault(); - emit("hide-selection"); - } else if (event.key === "a" && isSelectKey(event)) { - event.preventDefault(); - emit("select-all"); + } + + if (props.writable) { + if (event.key === "Tab") { + emit("init-key-selection"); + } else { + event.preventDefault(); + if ((event.key === "ArrowUp" || event.key === "ArrowDown") && event.shiftKey) { + emit("shift-select", event.key); + } else if (event.key === "ArrowUp" || event.key === "ArrowDown") { + emit("init-key-selection"); + } else if (event.key === "Delete" && !props.selected && !props.item.deleted) { + onDelete(event.shiftKey); + emit("arrow-navigate", "ArrowDown"); + } else if (event.key === "Escape") { + emit("hide-selection"); + } else if (event.key === "a" && isSelectKey(event)) { + emit("select-all"); + } + } } } -function onClick(e: Event) { +function onClick(e?: Event) { const event = e as KeyboardEvent; - if (event && event.shiftKey && isSelectKey(event)) { - emit("selected-to", false); - } else if (event && isSelectKey(event)) { - emit("init-key-selection"); - emit("update:selected", !props.selected); - } else if (event && event.shiftKey) { - emit("selected-to", true); - } else if (props.isPlaceholder) { - emit("init-key-selection"); - } else if (props.isDataset) { - emit("init-key-selection"); + if (event && props.writable) { + if (event.shiftKey && isSelectKey(event)) { + emit("selected-to", false); + return; + } else if (isSelectKey(event)) { + emit("init-key-selection"); + emit("update:selected", !props.selected); + return; + } else if (event.shiftKey) { + emit("selected-to", true); + return; + } else { + emit("init-key-selection"); + } + } + if (props.isPlaceholder) { + return; + } + if (props.isDataset) { emit("update:expand-dataset", !props.expandDataset); } else { emit("view-collection", props.item, props.name); diff --git a/client/src/components/History/CurrentHistory/HistoryPanel.vue b/client/src/components/History/CurrentHistory/HistoryPanel.vue index 7e1d1e53f5c2..3f4e46e534c0 100644 --- a/client/src/components/History/CurrentHistory/HistoryPanel.vue +++ b/client/src/components/History/CurrentHistory/HistoryPanel.vue @@ -50,7 +50,6 @@ interface Props { history: HistorySummary; filter?: string; canEditHistory?: boolean; - shouldShowControls?: boolean; filterable?: boolean; isMultiViewItem?: boolean; } @@ -61,7 +60,6 @@ const props = withDefaults(defineProps(), { listOffset: 0, filter: "", canEditHistory: true, - shouldShowControls: true, filterable: false, isMultiViewItem: false, }); @@ -510,13 +508,13 @@ function setItemDragstart( :history="history" :is-watching="isWatching" :last-checked="lastCheckedTime" - :show-controls="shouldShowControls" + :show-controls="canEditHistory" :filter-text.sync="filterText" :hide-reload="isMultiViewItem" @reloadContents="reloadContents" />