Skip to content

Commit

Permalink
prevent keyboard/click select for unowned histories
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Mar 8, 2024
1 parent 23f2ae1 commit f5e19f9
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 34 deletions.
71 changes: 42 additions & 29 deletions client/src/components/History/Content/ContentItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions client/src/components/History/CurrentHistory/HistoryPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ interface Props {
history: HistorySummary;
filter?: string;
canEditHistory?: boolean;
shouldShowControls?: boolean;
filterable?: boolean;
isMultiViewItem?: boolean;
}
Expand All @@ -61,7 +60,6 @@ const props = withDefaults(defineProps<Props>(), {
listOffset: 0,
filter: "",
canEditHistory: true,
shouldShowControls: true,
filterable: false,
isMultiViewItem: false,
});
Expand Down Expand Up @@ -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" />

<HistoryOperations
v-if="shouldShowControls"
v-if="canEditHistory"
:history="history"
:show-selection="showSelection"
:expanded-count="expandedCount"
Expand Down
1 change: 0 additions & 1 deletion client/src/components/History/HistoryView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
v-else
:history="history"
:can-edit-history="canEditHistory"
:should-show-controls="false"
filterable
@view-collection="onViewCollection" />

Expand Down

0 comments on commit f5e19f9

Please sign in to comment.