Skip to content

Commit

Permalink
Context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
andreax79 committed Nov 30, 2022
1 parent e2f91c7 commit 05d3c9d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
10 changes: 5 additions & 5 deletions airflow_code_editor/static/airflow_code_editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion airflow_code_editor/static/airflow_code_editor.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/components/Files.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
@dragenter.stop.prevent="isDragEnter = true"
@dragover.stop.prevent="() => {}"
@dragleave.stop.prevent="isDragEnter = false"
@drop.stop.prevent="handleDrop">
@drop.stop.prevent="handleDrop"
@contextmenu.prevent.stop="showMenu($event, null)">
<vue-good-table
:fixed-header="true"
max-height="100%"
Expand Down Expand Up @@ -297,7 +298,7 @@ export default defineComponent({
},
showMenu(event, item) {
// Prepare the menu
this.options = prepareMenuOptions(item);
this.options = prepareMenuOptions(item, this.isGit);
// Show menu
this.$refs.filesMenu.showMenu(event, item);
},
Expand Down
29 changes: 17 additions & 12 deletions src/tree_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,25 +83,28 @@ export class TreeEntry {
}
}

export function prepareMenuOptions(item) {
export function prepareMenuOptions(item, isGit) {
// Prepare the menu
let options = [{
name: '<span class="material-icons">file_open</span> Open',
slug: 'open'
}];
if (item.type == 'blob') {
let options = []
if (item) {
options.push({
name: '<span class="material-icons">file_open</span> Open',
slug: 'open'
});
}
if (item && item.type == 'blob') {
options.push({
name: '<span class="material-icons">file_download</span> Download',
slug: 'download'
});
}
if ((!item.isGit) && (item.type == 'blob' || item.size == 0)) {
if ((!isGit) && item && (item.type == 'blob' || item.size == 0)) {
options.push({
name: '<span class="material-icons">delete</span> Delete',
slug: 'delete'
});
}
if ((!item.isGit) && (item.name != '..')) {
if ((!isGit) && item && (item.name != '..')) {
options.push({
name: '<span class="material-icons">drive_file_rename_outline</span> Move/Rename',
slug: 'rename'
Expand All @@ -111,10 +114,12 @@ export function prepareMenuOptions(item) {
slug: 'open_in_new'
});
}
if (!item.isGit) {
options.push({
type: 'divider'
});
if (!isGit) {
if (item) {
options.push({
type: 'divider'
});
}
options.push({
name: '<span class="material-icons">add_circle</span> New',
slug: 'new'
Expand Down

0 comments on commit 05d3c9d

Please sign in to comment.