Skip to content

Commit

Permalink
Show/hide hidden files
Browse files Browse the repository at this point in the history
  • Loading branch information
andreax79 committed Jun 30, 2023
1 parent 08b25ed commit 12145ec
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 20 deletions.
2 changes: 1 addition & 1 deletion airflow_code_editor/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.2.1
7.3.0
8 changes: 6 additions & 2 deletions airflow_code_editor/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,19 @@ def execute_git_command(git_args: List[str]) -> CompletedGitCommand:

def git_ls_local(git_args: List[str]) -> str:
"'git ls-tree' like output for local folders"
long_ = False
long_ = False # long format
if '-l' in git_args or '--long' in git_args:
git_args = [arg for arg in git_args if arg not in ('-l', '--long')]
long_ = True
all_ = False # do not ignore entries
if '-a' in git_args:
git_args = [arg for arg in git_args if arg not in ('-a')]
all_ = True
path = git_args[1] if len(git_args) > 1 else ''
path = normalize_path(path.split('#', 1)[0])
result = []
root_fs = RootFS()
for item in root_fs.path(path).iterdir():
for item in root_fs.path(path).iterdir(show_ignored_entries=all_):
if item.is_dir():
type_ = 'tree'
else:
Expand Down
18 changes: 9 additions & 9 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.

6 changes: 4 additions & 2 deletions airflow_code_editor/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ def get_root_node(path: Optional[str], args: Args) -> TreeOutput:
def get_files_node(path: Optional[str], args: Args) -> TreeOutput:
"Get tree files node"
result = []
long_ = 'long' in args
for item in RootFS().path(path).iterdir():
long_ = 'long' in args # long format
all_ = 'all' in args # do not ignore entries

for item in RootFS().path(path).iterdir(show_ignored_entries=all_):
s = item.stat()
leaf = not item.is_dir()
if long_: # Long format
Expand Down
8 changes: 8 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,11 @@
### Fix

- Fix "Permission denied" error renaming/removing files when git is not installed

## 7.3.0

2023-06-30

### Added

- Show/hide hidden files
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "airflow-code-editor",
"version": "7.2.2",
"version": "7.3.0",
"description": "A plugin for [Apache Airflow](https://github.com/apache/airflow) that allows you to edit DAGs in browser. It provides a file managing interface within specified directories and it can be used to edit and download your files. If git support is enabled, the DAGs are stored in a Git repository. You may use it to view Git history, review local changes and commit.",
"private": true,
"repository": {
Expand Down
1 change: 1 addition & 0 deletions src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export default defineComponent({
config: {
theme: localStorage.getItem('airflow_code_editor_theme') || 'default', // editor theme
mode: localStorage.getItem('airflow_code_editor_mode') || 'default', // edit mode (default, vim, etc...)
showHiddenFiles: localStorage.getItem('airflow_code_editor_show_hidden_files') == 'true',
singleTab: false,
},
sidebarSize: 190 * 100 / jQuery(document).width(), // sidebar size (percentage)
Expand Down
10 changes: 8 additions & 2 deletions src/components/Files.vue
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ export default defineComponent({
}
// Get tree items
try {
const response = await axios.get(prepareHref(path), { params: { long: true }});
const params = this.config.showHiddenFiles ? { long: true, all: true } : { long : true };
const response = await axios.get(prepareHref(path), { params: params });
let blobs = []; // files
let trees = []; // directories
response.data.value.forEach((part) => {
Expand Down Expand Up @@ -298,7 +299,7 @@ export default defineComponent({
},
showMenu(event, item) {
// Prepare the menu
this.options = prepareMenuOptions(item, this.isGit);
this.options = prepareMenuOptions(item, this.isGit, this.config.showHiddenFiles);
// Show menu
this.$refs.filesMenu.showMenu(event, item);
},
Expand All @@ -315,6 +316,11 @@ export default defineComponent({
window.open(event.item.href, '_blank');
} else if (event.option.slug == 'refresh') {
this.refresh();
} else if (event.option.slug == 'show_hidden') {
// Save setting on the local storage
this.config.showHiddenFiles = !this.config.showHiddenFiles;
localStorage.setItem('airflow_code_editor_show_hidden_files', this.config.showHiddenFiles);
this.refresh();
} else if (event.option.slug == 'new') {
this.newAction();
} else if (event.option.slug == 'upload') {
Expand Down
4 changes: 3 additions & 1 deletion src/components/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ export default defineComponent({
},
async loadChildrenAsync(parent) {
const self = this;
const response = await axios.get(prepareHref('tree/' + parent.id));
const path = 'tree/' + parent.id;
const params = this.config.showHiddenFiles ? { all: true } : {};
const response = await axios.get(prepareHref(path), { params: params });
return response.data.value.map((node) => self.prepareTreeNode(node, parent));
},
async showMenu(event, item) {
Expand Down
13 changes: 12 additions & 1 deletion src/tree_entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class TreeEntry {
}
}

export function prepareMenuOptions(item, isGit) {
export function prepareMenuOptions(item, isGit, showHiddenFiles) {
// Prepare the menu
let options = []
if (item) {
Expand Down Expand Up @@ -132,6 +132,17 @@ export function prepareMenuOptions(item, isGit) {
name: '<span class="material-icons">refresh</span> Refresh',
slug: 'refresh'
});
if (showHiddenFiles) {
options.push({
name: '<span class="material-icons">lens_blur</span> Hide Hidden Files',
slug: 'show_hidden'
});
} else {
options.push({
name: '<span class="material-icons">lens_blur</span> Show Hidden Files',
slug: 'show_hidden'
});
}
}
return options;
}

0 comments on commit 12145ec

Please sign in to comment.