From 729414d5fae195a173ee23dace7466db3f72e70d Mon Sep 17 00:00:00 2001 From: Hao Liu Date: Mon, 27 Feb 2023 15:23:46 -0500 Subject: [PATCH] WIP --- .gitignore | 2 +- MANIFEST.in | 2 +- Makefile | 4 +- awx/settings/defaults.py | 4 +- awx/ui-next/Makefile | 80 ------------------------------ awx/ui-next/package.json | 9 ---- awx/ui_next/Makefile | 80 ++++++++++++++++++++++++++++++ awx/{ui-next => ui_next}/README.md | 0 awx/{ui-next => ui_next}/urls.py | 5 +- awx/urls.py | 3 +- 10 files changed, 90 insertions(+), 99 deletions(-) delete mode 100644 awx/ui-next/Makefile delete mode 100644 awx/ui-next/package.json create mode 100644 awx/ui_next/Makefile rename awx/{ui-next => ui_next}/README.md (100%) rename awx/{ui-next => ui_next}/urls.py (92%) diff --git a/.gitignore b/.gitignore index d2766fcca1..30acd82ad9 100644 --- a/.gitignore +++ b/.gitignore @@ -162,4 +162,4 @@ use_dev_supervisor.txt /_build_kube_dev/ /Dockerfile.kube-dev -awx/ui-next/ansible-ui +awx/ui_next/src diff --git a/MANIFEST.in b/MANIFEST.in index 751b09db59..61e42bfcde 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -6,7 +6,7 @@ recursive-include awx/templates *.html recursive-include awx/api/templates *.md *.html *.yml recursive-include awx/ui/build *.html recursive-include awx/ui/build * -recursive-include awx/ui-next/ansible-ui/build * +recursive-include awx/ui_next/src/build * recursive-include awx/playbooks *.yml recursive-include awx/lib/site-packages * recursive-include awx/plugins *.ps1 diff --git a/Makefile b/Makefile index ef3c655464..52cef26da6 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -include awx/ui-next/Makefile +include awx/ui_next/Makefile PYTHON ?= python3.9 OFFICIAL ?= no @@ -460,7 +460,7 @@ HEADLESS ?= no ifeq ($(HEADLESS), yes) dist/$(SDIST_TAR_FILE): else -dist/$(SDIST_TAR_FILE): $(UI_BUILD_FLAG_FILE) awx/ui-next/ansible-ui/build +dist/$(SDIST_TAR_FILE): $(UI_BUILD_FLAG_FILE) awx/ui_next/src/build endif $(PYTHON) -m build -s ln -sf $(SDIST_TAR_FILE) dist/awx.tar.gz diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index 968a2e39bf..a98c8a3b11 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -85,7 +85,7 @@ USE_TZ = True STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'ui', 'build', 'static'), - os.path.join(BASE_DIR, 'ui-next', 'ansible-ui', 'build'), + os.path.join(BASE_DIR, 'ui_next', 'src', 'build'), os.path.join(BASE_DIR, 'static'), ] @@ -298,7 +298,7 @@ TEMPLATES = [ os.path.join(BASE_DIR, 'templates'), os.path.join(BASE_DIR, 'ui', 'build'), os.path.join(BASE_DIR, 'ui', 'public'), - os.path.join(BASE_DIR, 'ui-next', 'ansible-ui', 'build', 'controller'), + os.path.join(BASE_DIR, 'ui_next', 'src', 'build', 'awx'), ], }, ] diff --git a/awx/ui-next/Makefile b/awx/ui-next/Makefile deleted file mode 100644 index b4fe199821..0000000000 --- a/awx/ui-next/Makefile +++ /dev/null @@ -1,80 +0,0 @@ -ui_next_mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) -ui_next_dir := $(shell realpath --relative-to $(CURDIR) $(dir $(ui_next_mkfile_path))) - -ANSIBLE_UI_DIR ?= $(ui_next_dir)/src - -ANSIBLE_UI_GIT_REPO_HTTPS ?= -ANSIBLE_UI_GIT_REPO_SSH ?= -ANSIBLE_UI_GIT_BRANCH ?= main - -ANSIBLE_UI_LOCAL ?= - -.PHONY: ui-next/clone-https -## Shallow clone the ui-next repo via https skip if ANSIBLE_UI_GIT_REPO_HTTPS is undefined -ui-next/clone-https: - @if [ -z "$(ANSIBLE_UI_GIT_REPO_HTTPS)" ]; then \ - echo "SKIP: ui-next/clone-https. ANSIBLE_UI_GIT_REPO_HTTPS is not set."; \ - elif [ -d "$(ANSIBLE_UI_DIR)" ]; then \ - echo "SKIP: ui-next/clone-https. $(ANSIBLE_UI_DIR) already exists."; \ - else \ - git clone --depth 1 --branch $(ANSIBLE_UI_GIT_BRANCH) $(ANSIBLE_UI_GIT_REPO_HTTPS) $(ANSIBLE_UI_DIR) || true; \ - fi - -.PHONY: ui-next/clone-ssh -## Shallow clone the ui-next repo via ssh. -ui-next/clone-ssh: - @if [ -z "$(ANSIBLE_UI_GIT_REPO_SSH)" ]; then \ - echo "SKIP: ui-next/clone-ssh. ANSIBLE_UI_GIT_REPO_SSH is not set."; \ - elif [ -d "$(ANSIBLE_UI_DIR)" ]; then \ - echo "SKIP: ui-next/clone-ssh. $(ANSIBLE_UI_DIR) already exists."; \ - else \ - git clone --depth 1 --branch $(ANSIBLE_UI_GIT_BRANCH) $(ANSIBLE_UI_GIT_REPO_SSH) $(ANSIBLE_UI_DIR) || true; \ - fi - -.PHONY: ui-next/link-local -## Link to a existing local clone of ui-next repo. -ui-next/link-local: - @if [ -z "$(ANSIBLE_UI_LOCAL)" ]; then \ - echo "SKIP: ui-next/link-local. ANSIBLE_UI_LOCAL is not set."; \ - elif [ -d "$(ANSIBLE_UI_DIR)" ]; then \ - echo "SKIP: ui-next/link-local. $(ANSIBLE_UI_DIR) already exists."; \ - else \ - ln -s $(ANSIBLE_UI_LOCAL) $(ANSIBLE_UI_DIR); \ - fi - -.PHONY: ui-next -## Try to link to a local clone of ui-next repo if it exist otherwise clone via ssh than https. -ui-next: - @if [ -d "$(ANSIBLE_UI_DIR)" ]; then \ - echo "SKIP: ui-next. $(ANSIBLE_UI_DIR) already exists."; \ - else \ - $(MAKE) ui-next/link-local ui-next/clone-ssh ui-next/clone-https; \ - fi - -## Alias for ui-next, will not run if ui-next already exist -$(ANSIBLE_UI_DIR): - $(MAKE) ui-next - -.PHONY: ui-next/build -## Build ui-next -ui-next/build: ui-next - cd $(ANSIBLE_UI_DIR) && \ - npm install webpack && \ - npm run build:controller - -## Alias for ui-next/build, will not run if build already exist -$(ANSIBLE_UI_DIR)/build: - $(MAKE) ui-next/build - -.PHONY: ui-next/clean -## Clean ui-next -ui-next/clean: - rm -rf $(UI_NEXT_BUILD_FLAG_FILE) - rm -rf $(ANSIBLE_UI_DIR) - -.PHONY: ui-next/clean/build -## Clean ui-next build -ui-next/clean/build: - rm -rf $(UI_NEXT_BUILD_FLAG_FILE) - rm -rf $(ANSIBLE_UI_DIR)/build - diff --git a/awx/ui-next/package.json b/awx/ui-next/package.json deleted file mode 100644 index 7870df4f20..0000000000 --- a/awx/ui-next/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "ui-next", - "homepage": ".", - "private": true, - "engines": { - "node": ">=16.13.1" - }, - -} \ No newline at end of file diff --git a/awx/ui_next/Makefile b/awx/ui_next/Makefile new file mode 100644 index 0000000000..1ad28e460d --- /dev/null +++ b/awx/ui_next/Makefile @@ -0,0 +1,80 @@ +ui_next_mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) +ui_next_dir := $(shell realpath --relative-to $(CURDIR) $(dir $(ui_next_mkfile_path))) + +ANSIBLE_UI_DIR ?= $(ui_next_dir)/src + +ANSIBLE_UI_GIT_REPO_HTTPS ?= +ANSIBLE_UI_GIT_REPO_SSH ?= +ANSIBLE_UI_GIT_BRANCH ?= main + +ANSIBLE_UI_LOCAL ?= + +.PHONY: ui_next/clone-https +## Shallow clone the ui_next repo via https skip if ANSIBLE_UI_GIT_REPO_HTTPS is undefined +ui_next/clone-https: + @if [ -z "$(ANSIBLE_UI_GIT_REPO_HTTPS)" ]; then \ + echo "SKIP: ui_next/clone-https. ANSIBLE_UI_GIT_REPO_HTTPS is not set."; \ + elif [ -d "$(ANSIBLE_UI_DIR)" ]; then \ + echo "SKIP: ui_next/clone-https. $(ANSIBLE_UI_DIR) already exists."; \ + else \ + git clone --depth 1 --branch $(ANSIBLE_UI_GIT_BRANCH) $(ANSIBLE_UI_GIT_REPO_HTTPS) $(ANSIBLE_UI_DIR) || true; \ + fi + +.PHONY: ui_next/clone-ssh +## Shallow clone the ui_next repo via ssh. +ui_next/clone-ssh: + @if [ -z "$(ANSIBLE_UI_GIT_REPO_SSH)" ]; then \ + echo "SKIP: ui_next/clone-ssh. ANSIBLE_UI_GIT_REPO_SSH is not set."; \ + elif [ -d "$(ANSIBLE_UI_DIR)" ]; then \ + echo "SKIP: ui_next/clone-ssh. $(ANSIBLE_UI_DIR) already exists."; \ + else \ + git clone --depth 1 --branch $(ANSIBLE_UI_GIT_BRANCH) $(ANSIBLE_UI_GIT_REPO_SSH) $(ANSIBLE_UI_DIR) || true; \ + fi + +.PHONY: ui_next/link-local +## Link to a existing local clone of ui_next repo. +ui_next/link-local: + @if [ -z "$(ANSIBLE_UI_LOCAL)" ]; then \ + echo "SKIP: ui_next/link-local. ANSIBLE_UI_LOCAL is not set."; \ + elif [ -d "$(ANSIBLE_UI_DIR)" ]; then \ + echo "SKIP: ui_next/link-local. $(ANSIBLE_UI_DIR) already exists."; \ + else \ + ln -s $(ANSIBLE_UI_LOCAL) $(ANSIBLE_UI_DIR); \ + fi + +.PHONY: ui_next +## Try to link to a local clone of ui_next repo if it exist otherwise clone via ssh than https. +ui_next: + @if [ -d "$(ANSIBLE_UI_DIR)" ]; then \ + echo "SKIP: ui_next. $(ANSIBLE_UI_DIR) already exists."; \ + else \ + $(MAKE) ui_next/link-local ui_next/clone-ssh ui_next/clone-https; \ + fi + +## Alias for ui_next, will not run if ui_next already exist +$(ANSIBLE_UI_DIR): + $(MAKE) ui_next + +.PHONY: ui_next/build +## Build ui_next +ui_next/build: ui_next + cd $(ANSIBLE_UI_DIR) && \ + npm install webpack && \ + npm run build:awx + +## Alias for ui_next/build, will not run if build already exist +$(ANSIBLE_UI_DIR)/build: + $(MAKE) ui_next/build + +.PHONY: ui_next/clean +## Clean ui_next +ui_next/clean: + rm -rf $(UI_NEXT_BUILD_FLAG_FILE) + rm -rf $(ANSIBLE_UI_DIR) + +.PHONY: ui_next/clean/build +## Clean ui_next build +ui_next/clean/build: + rm -rf $(UI_NEXT_BUILD_FLAG_FILE) + rm -rf $(ANSIBLE_UI_DIR)/build + diff --git a/awx/ui-next/README.md b/awx/ui_next/README.md similarity index 100% rename from awx/ui-next/README.md rename to awx/ui_next/README.md diff --git a/awx/ui-next/urls.py b/awx/ui_next/urls.py similarity index 92% rename from awx/ui-next/urls.py rename to awx/ui_next/urls.py index 36bebdd81b..c96994091c 100644 --- a/awx/ui-next/urls.py +++ b/awx/ui_next/urls.py @@ -6,9 +6,10 @@ from awx.main.utils.licensing import server_product_name class IndexView(TemplateView): - template_name = 'index_controller.html' + template_name = 'index_awx.html' +# TODO: Hao fix this class MigrationsNotran(TemplateView): template_name = 'installing.html' @@ -23,7 +24,7 @@ class MigrationsNotran(TemplateView): return context -app_name = 'ui-next' +app_name = 'ui_next' urlpatterns = [ re_path(r'^$', IndexView.as_view(), name='index'), diff --git a/awx/urls.py b/awx/urls.py index af30cf361e..ea4248f7db 100644 --- a/awx/urls.py +++ b/awx/urls.py @@ -9,8 +9,7 @@ from awx.main.views import handle_400, handle_403, handle_404, handle_500, handl urlpatterns = [ re_path(r'', include('awx.ui.urls', namespace='ui')), - re_path(r'^controller/.*$', include('awx.ui-next.urls', namespace='controller')), - # re_path(r'^ui-next/', include('awx.ui-next.urls', namespace='ui-next')), + re_path(r'^ui_next/.*$', include('awx.ui_next.urls', namespace='ui_next')), re_path(r'^api/', include('awx.api.urls', namespace='api')), re_path(r'^sso/', include('awx.sso.urls', namespace='sso')), re_path(r'^sso/', include('social_django.urls', namespace='social')),