Skip to content

Commit

Permalink
### Changed
Browse files Browse the repository at this point in the history
- Migrate from Vue 2 to Vue 3
- Refactor History View
- Refactor Workspace View
- Refactor Files and Editor components
- Refactor CSS
- Replace Bootstap Modals with Vue-universal-modal
- Replace Font Awesome with Material Icons

### Fix

- Raise the correct exception at file loading and show the error in the editor
- Fix exception related to axios/axios#811
  • Loading branch information
admin admin committed Aug 12, 2022
1 parent c2ba85d commit 0c680ad
Show file tree
Hide file tree
Showing 75 changed files with 5,860 additions and 13,466 deletions.
1 change: 1 addition & 0 deletions .ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
airflow_code_editor/static/airflow_code_editor.js
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16.16.0
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ npm-build:
@npm run build

npm-watch:
@NODE_OPTIONS=--openssl-legacy-provider npm run watch
@npm run watch
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ Example:
* Vue.js - https://github.com/vuejs/vue
* Vue-good-table, data table for VueJS - https://github.com/xaksis/vue-good-table
* Vue-tree, TreeView control for VueJS - https://github.com/grapoza/vue-tree
* Vue-universal-modal Universal modal plugin for Vue@3 - https://github.com/hoiheart/vue-universal-modal
* Splitpanes - https://github.com/antoniandre/splitpanes
* Axios, Promise based HTTP client for the browser and node.js - https://github.com/axios/axios
* PyFilesystem2, Python's Filesystem abstraction layer - https://github.com/PyFilesystem/pyfilesystem2
Expand Down
2 changes: 1 addition & 1 deletion airflow_code_editor/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0.0
7.0.0
15 changes: 9 additions & 6 deletions airflow_code_editor/code_editor_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import logging
import mimetypes
from flask import abort, request
from flask import request, make_response
from flask_wtf.csrf import generate_csrf
from airflow.version import version
from airflow_code_editor.commons import HTTP_404_NOT_FOUND
Expand Down Expand Up @@ -79,14 +79,14 @@ def _git_repo_get(self, path):
try:
# Download git blob - path = '<hash>/<name>'
path, attachment_filename = path.split('/', 1)
except:
except Exception:
# No attachment filename
attachment_filename = None
response = execute_git_command(["cat-file", "-p", path])
if attachment_filename:
response.headers["Content-Disposition"] = (
'attachment; filename="{0}"'.format(attachment_filename)
)
response.headers[
"Content-Disposition"
] = 'attachment; filename="{0}"'.format(attachment_filename)
try:
content_type = mimetypes.guess_type(attachment_filename)[0]
if content_type:
Expand Down Expand Up @@ -114,7 +114,10 @@ def _load(self, path):
return root_fs.path(path).send_file(as_attachment=True)
except Exception as ex:
logging.error(ex)
abort(HTTP_404_NOT_FOUND)
strerror = getattr(ex, 'strerror', str(ex))
errno = getattr(ex, 'errno', 0)
message = prepare_api_response(error_message=strerror, errno=errno)
return make_response(message, HTTP_404_NOT_FOUND)

def _format(self):
"Format code"
Expand Down
15 changes: 15 additions & 0 deletions airflow_code_editor/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
'PLUGIN_DEFAULT_CONFIG',
'ROOT_MOUNTPOUNT',
'JS_FILES',
'ICON_HOME',
'ICON_GIT',
'ICON_TAGS',
'FILE_ICON',
'FOLDER_ICON',
'ICON_LOCAL_BRANCHES',
'ICON_REMOTE_BRANCHES',
'VERSION_FILE',
'VERSION',
'Args',
Expand Down Expand Up @@ -100,6 +107,14 @@
'airflow_code_editor.js',
]

ICON_HOME = 'home'
ICON_GIT = 'work'
ICON_TAGS = 'style'
FILE_ICON = 'file'
FOLDER_ICON = 'folder'
ICON_LOCAL_BRANCHES = 'fork_right'
ICON_REMOTE_BRANCHES = 'public'

VERSION_FILE = Path(__file__).parent / "VERSION"
VERSION = VERSION_FILE.read_text().strip()

Expand Down
6 changes: 3 additions & 3 deletions airflow_code_editor/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
# limitations under the Licens

import os
import errno
import fs
from fs.mountfs import MountFS, MountError
from fs.multifs import MultiFS
from fs.path import abspath, forcedir, normpath
from typing import Any, List, Union
from flask import abort, send_file, stream_with_context, Response
from flask import send_file, stream_with_context, Response
from airflow_code_editor.utils import read_mount_points_config
from airflow_code_editor.commons import HTTP_404_NOT_FOUND

__all__ = [
'RootFS',
Expand Down Expand Up @@ -197,7 +197,7 @@ def read_file_chunks(self, chunk_size: int = SEND_FILE_CHUNK_SIZE):
def send_file(self, as_attachment: bool):
"Send the contents of a file to the client"
if not self.exists():
abort(HTTP_404_NOT_FOUND)
raise FileNotFoundError(errno.ENOENT, 'File not found', self.path)
elif self.root_fs.hassyspath(self.path):
# Local filesystem
return send_file(
Expand Down
4 changes: 3 additions & 1 deletion airflow_code_editor/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,9 @@ def git_call(


def get_default_branch() -> str:
stdout = git_call(['config', '--global', 'init.defaultBranch'], capture_output=True)[1]
stdout = git_call(
['config', '--global', 'init.defaultBranch'], capture_output=True
)[1]
default_branch = stdout.decode('utf8').strip('\n')
return default_branch or DEFAULT_GIT_BRANCH

Expand Down
1 change: 1 addition & 0 deletions airflow_code_editor/static/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index.html
20 changes: 18 additions & 2 deletions airflow_code_editor/static/airflow_code_editor.js

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions airflow_code_editor/static/airflow_code_editor.js.LICENSE.txt

This file was deleted.

1 change: 1 addition & 0 deletions airflow_code_editor/static/airflow_code_editor.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion airflow_code_editor/static/css/bootstrap-dialog.css

This file was deleted.

2 changes: 1 addition & 1 deletion airflow_code_editor/static/css/editor_v2.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ body {
}
.cm-footer {
border-top: 1px solid #eee;
padding: 0.2em 1em;
padding: 0.5em 0.5em;
background-color: #f5f5f5;
}
.CodeMirror {
Expand Down
4 changes: 0 additions & 4 deletions airflow_code_editor/static/css/font-awesome.css

This file was deleted.

Loading

0 comments on commit 0c680ad

Please sign in to comment.