Skip to content

Commit 05d3c9d

Browse files
committed
Context menu
1 parent e2f91c7 commit 05d3c9d

File tree

4 files changed

+26
-20
lines changed

4 files changed

+26
-20
lines changed

airflow_code_editor/static/airflow_code_editor.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

airflow_code_editor/static/airflow_code_editor.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Files.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
@dragenter.stop.prevent="isDragEnter = true"
1414
@dragover.stop.prevent="() => {}"
1515
@dragleave.stop.prevent="isDragEnter = false"
16-
@drop.stop.prevent="handleDrop">
16+
@drop.stop.prevent="handleDrop"
17+
@contextmenu.prevent.stop="showMenu($event, null)">
1718
<vue-good-table
1819
:fixed-header="true"
1920
max-height="100%"
@@ -297,7 +298,7 @@ export default defineComponent({
297298
},
298299
showMenu(event, item) {
299300
// Prepare the menu
300-
this.options = prepareMenuOptions(item);
301+
this.options = prepareMenuOptions(item, this.isGit);
301302
// Show menu
302303
this.$refs.filesMenu.showMenu(event, item);
303304
},

src/tree_entry.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,28 @@ export class TreeEntry {
8383
}
8484
}
8585

86-
export function prepareMenuOptions(item) {
86+
export function prepareMenuOptions(item, isGit) {
8787
// Prepare the menu
88-
let options = [{
89-
name: '<span class="material-icons">file_open</span> Open',
90-
slug: 'open'
91-
}];
92-
if (item.type == 'blob') {
88+
let options = []
89+
if (item) {
90+
options.push({
91+
name: '<span class="material-icons">file_open</span> Open',
92+
slug: 'open'
93+
});
94+
}
95+
if (item && item.type == 'blob') {
9396
options.push({
9497
name: '<span class="material-icons">file_download</span> Download',
9598
slug: 'download'
9699
});
97100
}
98-
if ((!item.isGit) && (item.type == 'blob' || item.size == 0)) {
101+
if ((!isGit) && item && (item.type == 'blob' || item.size == 0)) {
99102
options.push({
100103
name: '<span class="material-icons">delete</span> Delete',
101104
slug: 'delete'
102105
});
103106
}
104-
if ((!item.isGit) && (item.name != '..')) {
107+
if ((!isGit) && item && (item.name != '..')) {
105108
options.push({
106109
name: '<span class="material-icons">drive_file_rename_outline</span> Move/Rename',
107110
slug: 'rename'
@@ -111,10 +114,12 @@ export function prepareMenuOptions(item) {
111114
slug: 'open_in_new'
112115
});
113116
}
114-
if (!item.isGit) {
115-
options.push({
116-
type: 'divider'
117-
});
117+
if (!isGit) {
118+
if (item) {
119+
options.push({
120+
type: 'divider'
121+
});
122+
}
118123
options.push({
119124
name: '<span class="material-icons">add_circle</span> New',
120125
slug: 'new'

0 commit comments

Comments
 (0)