Skip to content

Commit

Permalink
enabled configuration option added
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Bonomi committed Mar 23, 2022
1 parent fab2f10 commit 139a04f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions airflow_code_editor/airflow_code_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from flask import Blueprint
from airflow.plugins_manager import AirflowPlugin
from airflow_code_editor.commons import STATIC, VERSION
from airflow_code_editor.utils import is_enabled
from airflow_code_editor.flask_admin_view import admin_view
from airflow_code_editor.app_builder_view import appbuilder_view

Expand All @@ -44,6 +45,6 @@ class CodeEditorPlugin(AirflowPlugin):
flask_blueprints = [code_editor_plugin_blueprint]
hooks = []
executors = []
admin_views = [admin_view] if admin_view is not None else []
admin_views = [admin_view] if (is_enabled() and admin_view is not None) else []
menu_links = []
appbuilder_views = [appbuilder_view]
appbuilder_views = [appbuilder_view] if is_enabled() else []
1 change: 1 addition & 0 deletions airflow_code_editor/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
'unstage',
]
PLUGIN_DEFAULT_CONFIG = {
'enabled': True,
'git_enabled': True,
'git_cmd': 'git',
'git_default_args': '-c color.ui=true',
Expand Down
6 changes: 6 additions & 0 deletions airflow_code_editor/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
'get_plugin_config',
'get_plugin_boolean_config',
'get_plugin_int_config',
'is_enabled',
'git_enabled',
'get_root_folder',
'git_absolute_path',
Expand Down Expand Up @@ -92,6 +93,11 @@ def get_plugin_int_config(key: str) -> int:
) # type: ignore


def is_enabled() -> bool:
"Return true if the plugin is enabled in the configuration"
return get_plugin_boolean_config('enabled')


def git_enabled() -> bool:
"Return true if git is enabled in the configuration"
return get_plugin_boolean_config('git_enabled')
Expand Down

0 comments on commit 139a04f

Please sign in to comment.