Skip to content

Commit

Permalink
add menu link to REST API reference
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Bonomi committed Jun 12, 2024
1 parent 5536f81 commit c06d9f1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion airflow_code_editor/airflow_code_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
except Exception:
api_blueprint = None

from airflow_code_editor.app_builder_view import appbuilder_view
from airflow_code_editor.app_builder_view import api_reference_menu, appbuilder_view
from airflow_code_editor.commons import STATIC, VERSION
from airflow_code_editor.flask_admin_view import admin_view
from airflow_code_editor.utils import is_enabled
Expand Down Expand Up @@ -56,4 +56,5 @@ class CodeEditorPlugin(AirflowPlugin):
executors = []
admin_views = [admin_view] if (is_enabled() and admin_view is not None) else []
menu_links = []
appbuilder_menu_items = [api_reference_menu] if (is_enabled() and api_blueprint is not None) else []
appbuilder_views = [appbuilder_view] if is_enabled() else []
9 changes: 8 additions & 1 deletion airflow_code_editor/app_builder_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@

from airflow_code_editor.code_editor_view import AbstractCodeEditorView
from airflow_code_editor.commons import (
API_REFERENCE_LABEL,
API_REFERENCE_MENU_CATEGORY,
JS_FILES,
MENU_CATEGORY,
MENU_LABEL,
ROUTE,
VERSION,
)

__all__ = ["appbuilder_view"]
__all__ = ["appbuilder_view", "api_reference_menu"]

try:
from airflow.security import permissions
Expand Down Expand Up @@ -188,3 +190,8 @@ def _render(self, template, *args, **kargs):
"name": MENU_LABEL,
"view": appbuilder_code_editor_view,
}
api_reference_menu = {
"name": API_REFERENCE_LABEL,
"category": API_REFERENCE_MENU_CATEGORY,
"href": ROUTE + "/api/",
}
5 changes: 5 additions & 0 deletions airflow_code_editor/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
'PLUGIN_NAME',
'MENU_CATEGORY',
'MENU_LABEL',
'API_REFERENCE_MENU_CATEGORY',
'API_REFERENCE_LABEL',
'ROUTE',
'STATIC',
'CONFIG_SECTION',
Expand Down Expand Up @@ -52,6 +54,8 @@
PLUGIN_NAME = 'code_editor'
MENU_CATEGORY = 'Admin'
MENU_LABEL = 'DAGs Code Editor'
API_REFERENCE_MENU_CATEGORY = 'Docs'
API_REFERENCE_LABEL = 'Airflow Code Editor REST API Reference'
ROUTE = '/' + PLUGIN_NAME
STATIC = '/static/' + PLUGIN_NAME
CONFIG_SECTION = PLUGIN_NAME + '_plugin'
Expand All @@ -67,6 +71,7 @@
'checkout',
'commit',
'diff',
'for-each-ref',
'log',
'ls-tree',
'pull',
Expand Down
2 changes: 1 addition & 1 deletion airflow_code_editor/static/airflow_code_editor.js.map

Large diffs are not rendered by default.

0 comments on commit c06d9f1

Please sign in to comment.