From 12a22d24428c8e2a2a7fb300cd0b4a3a16e13b47 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Fri, 15 May 2020 09:57:30 -0400 Subject: [PATCH 1/6] Add basic django app and file serving for ui_next --- MANIFEST.in | 2 ++ awx/settings/defaults.py | 2 ++ awx/ui_next/urls.py | 13 +++++++++++++ awx/urls.py | 1 + 4 files changed, 18 insertions(+) create mode 100644 awx/ui_next/urls.py diff --git a/MANIFEST.in b/MANIFEST.in index 53e1d8eebd..6260b87cea 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -6,6 +6,8 @@ recursive-include awx/templates *.html recursive-include awx/api/templates *.md *.html recursive-include awx/ui/templates *.html recursive-include awx/ui/static * +recursive-include awx/ui_next/build *.html +recursive-include awx/ui_next/build * recursive-include awx/playbooks *.yml recursive-include awx/lib/site-packages * recursive-include awx/plugins *.ps1 diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index 7a477316da..d40c3e5a68 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -94,6 +94,7 @@ USE_TZ = True STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'ui', 'static'), + os.path.join(BASE_DIR, 'ui_next', 'build', 'static'), os.path.join(BASE_DIR, 'static'), ) @@ -253,6 +254,7 @@ TEMPLATES = [ }, 'DIRS': [ os.path.join(BASE_DIR, 'templates'), + os.path.join(BASE_DIR, 'ui_next', 'build'), ], }, ] diff --git a/awx/ui_next/urls.py b/awx/ui_next/urls.py new file mode 100644 index 0000000000..540651730f --- /dev/null +++ b/awx/ui_next/urls.py @@ -0,0 +1,13 @@ +from django.conf.urls import url +from django.views.generic.base import TemplateView + +class IndexView(TemplateView): + + template_name = 'index.html' + + +app_name = 'ui_next' + +urlpatterns = [ + url(r'^next/$', IndexView.as_view(), name='ui_next') +] diff --git a/awx/urls.py b/awx/urls.py index ba0f0ee421..bdcae84bcb 100644 --- a/awx/urls.py +++ b/awx/urls.py @@ -14,6 +14,7 @@ from awx.main.views import ( urlpatterns = [ + url(r'', include('awx.ui_next.urls', namespace='ui_next')), url(r'', include('awx.ui.urls', namespace='ui')), url(r'^api/', include('awx.api.urls', namespace='api')), url(r'^sso/', include('awx.sso.urls', namespace='sso')), From ddadf332cc4881b04c453579c0e93b55fab8c6fd Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Mon, 18 May 2020 09:29:07 -0400 Subject: [PATCH 2/6] Create static dir during bootstrap Co-authored-by: nixocio --- tools/docker-compose/bootstrap_development.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/docker-compose/bootstrap_development.sh b/tools/docker-compose/bootstrap_development.sh index 095d3e0d04..68210a8713 100755 --- a/tools/docker-compose/bootstrap_development.sh +++ b/tools/docker-compose/bootstrap_development.sh @@ -28,3 +28,4 @@ make init mkdir -p /awx_devel/awx/public/static mkdir -p /awx_devel/awx/ui/static +mkdir -p /awx_devel/awx/ui_next/build/static From 41d8edf94a1645bb2a2cb823d5bd13c18b725ed3 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Thu, 21 May 2020 10:20:32 -0400 Subject: [PATCH 3/6] Align imports to django collectstatic locations Co-authored-by: nixocio --- .../public/{images => static/media}/pfbg_2000.jpg | Bin .../public/{images => static/media}/pfbg_576.jpg | Bin .../public/{images => static/media}/pfbg_576@2x.jpg | Bin .../public/{images => static/media}/pfbg_768.jpg | Bin .../public/{images => static/media}/pfbg_768@2x.jpg | Bin 5 files changed, 0 insertions(+), 0 deletions(-) rename awx/ui_next/public/{images => static/media}/pfbg_2000.jpg (100%) rename awx/ui_next/public/{images => static/media}/pfbg_576.jpg (100%) rename awx/ui_next/public/{images => static/media}/pfbg_576@2x.jpg (100%) rename awx/ui_next/public/{images => static/media}/pfbg_768.jpg (100%) rename awx/ui_next/public/{images => static/media}/pfbg_768@2x.jpg (100%) diff --git a/awx/ui_next/public/images/pfbg_2000.jpg b/awx/ui_next/public/static/media/pfbg_2000.jpg similarity index 100% rename from awx/ui_next/public/images/pfbg_2000.jpg rename to awx/ui_next/public/static/media/pfbg_2000.jpg diff --git a/awx/ui_next/public/images/pfbg_576.jpg b/awx/ui_next/public/static/media/pfbg_576.jpg similarity index 100% rename from awx/ui_next/public/images/pfbg_576.jpg rename to awx/ui_next/public/static/media/pfbg_576.jpg diff --git a/awx/ui_next/public/images/pfbg_576@2x.jpg b/awx/ui_next/public/static/media/pfbg_576@2x.jpg similarity index 100% rename from awx/ui_next/public/images/pfbg_576@2x.jpg rename to awx/ui_next/public/static/media/pfbg_576@2x.jpg diff --git a/awx/ui_next/public/images/pfbg_768.jpg b/awx/ui_next/public/static/media/pfbg_768.jpg similarity index 100% rename from awx/ui_next/public/images/pfbg_768.jpg rename to awx/ui_next/public/static/media/pfbg_768.jpg diff --git a/awx/ui_next/public/images/pfbg_768@2x.jpg b/awx/ui_next/public/static/media/pfbg_768@2x.jpg similarity index 100% rename from awx/ui_next/public/images/pfbg_768@2x.jpg rename to awx/ui_next/public/static/media/pfbg_768@2x.jpg From aef382862c560a9ca7778662c0a419866d3c347c Mon Sep 17 00:00:00 2001 From: nixocio Date: Thu, 21 May 2020 12:02:27 -0400 Subject: [PATCH 4/6] Update NavItem to link to new basename Update NavItem to link to the new basename, `next`. Thus avoiding to redirec to the old ui. See: https://www.patternfly.org/v4/documentation/react/components/nav --- awx/ui_next/src/components/AppContainer/NavExpandableGroup.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui_next/src/components/AppContainer/NavExpandableGroup.jsx b/awx/ui_next/src/components/AppContainer/NavExpandableGroup.jsx index 6403e617f7..2b8805d589 100644 --- a/awx/ui_next/src/components/AppContainer/NavExpandableGroup.jsx +++ b/awx/ui_next/src/components/AppContainer/NavExpandableGroup.jsx @@ -41,7 +41,7 @@ class NavExpandableGroup extends Component { groupId={groupId} isActive={this.isActivePath(path)} key={path} - to={`/#${path}`} + to={`/next/#${path}`} > {title} From 01b8087cb38addfd8664a2dd672a4a4571bda046 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Wed, 17 Jun 2020 11:40:09 -0400 Subject: [PATCH 5/6] Align prod and dev routing --- awx/ui_next/src/App.jsx | 6 +++--- .../src/components/AppContainer/AppContainer.test.jsx | 6 +++--- .../src/components/AppContainer/NavExpandableGroup.jsx | 5 ++--- awx/ui_next/urls.py | 3 ++- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/awx/ui_next/src/App.jsx b/awx/ui_next/src/App.jsx index ffafd07dba..9b230ac553 100644 --- a/awx/ui_next/src/App.jsx +++ b/awx/ui_next/src/App.jsx @@ -2,7 +2,7 @@ import React from 'react'; import { useRouteMatch, useLocation, - HashRouter, + BrowserRouter, Route, Switch, Redirect, @@ -76,7 +76,7 @@ function App() { } export default () => ( - + - + ); diff --git a/awx/ui_next/src/components/AppContainer/AppContainer.test.jsx b/awx/ui_next/src/components/AppContainer/AppContainer.test.jsx index c01a7ee6d4..93a7bb5963 100644 --- a/awx/ui_next/src/components/AppContainer/AppContainer.test.jsx +++ b/awx/ui_next/src/components/AppContainer/AppContainer.test.jsx @@ -66,9 +66,9 @@ describe('', () => { // sidebar groups and route links expect(wrapper.find('NavExpandableGroup').length).toBe(2); - expect(wrapper.find('a[href="/#/foo"]').length).toBe(1); - expect(wrapper.find('a[href="/#/bar"]').length).toBe(1); - expect(wrapper.find('a[href="/#/fiz"]').length).toBe(1); + expect(wrapper.find('a[href="/foo"]').length).toBe(1); + expect(wrapper.find('a[href="/bar"]').length).toBe(1); + expect(wrapper.find('a[href="/fiz"]').length).toBe(1); expect(wrapper.find('#group_one').length).toBe(1); expect(wrapper.find('#group_two').length).toBe(1); diff --git a/awx/ui_next/src/components/AppContainer/NavExpandableGroup.jsx b/awx/ui_next/src/components/AppContainer/NavExpandableGroup.jsx index 2b8805d589..370ac52f40 100644 --- a/awx/ui_next/src/components/AppContainer/NavExpandableGroup.jsx +++ b/awx/ui_next/src/components/AppContainer/NavExpandableGroup.jsx @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { withRouter } from 'react-router-dom'; +import { withRouter, Link } from 'react-router-dom'; import { NavExpandable, NavItem } from '@patternfly/react-core'; class NavExpandableGroup extends Component { @@ -41,9 +41,8 @@ class NavExpandableGroup extends Component { groupId={groupId} isActive={this.isActivePath(path)} key={path} - to={`/next/#${path}`} > - {title} + {title} ))} diff --git a/awx/ui_next/urls.py b/awx/ui_next/urls.py index 540651730f..bb288cf625 100644 --- a/awx/ui_next/urls.py +++ b/awx/ui_next/urls.py @@ -1,6 +1,7 @@ from django.conf.urls import url from django.views.generic.base import TemplateView + class IndexView(TemplateView): template_name = 'index.html' @@ -9,5 +10,5 @@ class IndexView(TemplateView): app_name = 'ui_next' urlpatterns = [ - url(r'^next/$', IndexView.as_view(), name='ui_next') + url(r'^next/*', IndexView.as_view(), name='ui_next') ] From 1df91eece1797bb843bf3d6629e2dd9f82a36005 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Thu, 18 Jun 2020 17:28:44 -0400 Subject: [PATCH 6/6] Add devel make targets for ui_next --- .gitignore | 2 +- Makefile | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 37727320b1..2f3635eabe 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,7 @@ awx/ui/templates/ui/index.html awx/ui/templates/ui/installing.html awx/ui_next/node_modules/ awx/ui_next/coverage/ -awx/ui_next/build/locales/_build +awx/ui_next/build rsyslog.pid /tower-license /tower-license/** diff --git a/Makefile b/Makefile index ac2b209b1d..f95bd63257 100644 --- a/Makefile +++ b/Makefile @@ -568,14 +568,25 @@ ui-zuul-lint-and-test: # UI NEXT TASKS # -------------------------------------- -ui-next-lint: +awx/ui_next/node_modules: $(NPM_BIN) --prefix awx/ui_next install - $(NPM_BIN) run --prefix awx/ui_next lint - $(NPM_BIN) run --prefix awx/ui_next prettier-check -ui-next-test: - $(NPM_BIN) --prefix awx/ui_next install - $(NPM_BIN) run --prefix awx/ui_next test +ui-release-next: + mkdir -p awx/ui_next/build/static + touch awx/ui_next/build/static/.placeholder + +ui-devel-next: awx/ui_next/node_modules + $(NPM_BIN) --prefix awx/ui_next run build + mkdir -p awx/public/static/css + mkdir -p awx/public/static/js + mkdir -p awx/public/static/media + cp -r awx/ui_next/build/static/css/* awx/public/static/css + cp -r awx/ui_next/build/static/js/* awx/public/static/js + cp -r awx/ui_next/build/static/media/* awx/public/static/media + +clean-ui-next: + rm -rf awx/ui_next/node_modules + rm -rf awx/ui_next/build ui-next-zuul-lint-and-test: $(NPM_BIN) --prefix awx/ui_next install @@ -594,10 +605,10 @@ dev_build: release_build: $(PYTHON) setup.py release_build -dist/$(SDIST_TAR_FILE): ui-release VERSION +dist/$(SDIST_TAR_FILE): ui-release ui-release-next VERSION $(PYTHON) setup.py $(SDIST_COMMAND) -dist/$(WHEEL_FILE): ui-release +dist/$(WHEEL_FILE): ui-release ui-release-next $(PYTHON) setup.py $(WHEEL_COMMAND) sdist: dist/$(SDIST_TAR_FILE)