chore(nimbus): move new ui into nimbus_ui_new (#10544)

Because

* We're starting a new UI for Nimbus using Django Views/Forms/Templates
* Let's collect all the templates, static assets, views, tests in one
folder so it's easier to collect and find things

This commit

* Moves all the new UI folders into nimbus_ui_new

fixes #10542
This commit is contained in:
Jared Lockhart 2024-04-15 14:06:14 -04:00 коммит произвёл GitHub
Родитель efec47b136
Коммит 14a9536a9d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
34 изменённых файлов: 53 добавлений и 69 удалений

Просмотреть файл

@ -18,7 +18,7 @@ services:
- media_volume:/experimenter/experimenter/media
- /experimenter/experimenter/legacy/legacy-ui/core/.cache/
- /experimenter/experimenter/legacy/legacy-ui/core/node_modules/
- /experimenter/experimenter/theme/static_src/node_modules/
- /experimenter/experimenter/nimbus_ui_new/theme/static_src/node_modules/
- /experimenter/experimenter/nimbus-ui/node_modules/
- /experimenter/experimenter/served/
- /experimenter/node_modules/
@ -31,8 +31,8 @@ services:
tty: true
volumes:
- ./experimenter:/experimenter
- /experimenter/experimenter/theme/static_src/node_modules/
command: "yarn --cwd /experimenter/experimenter/theme/static_src run dev"
- /experimenter/experimenter/nimbus_ui_new/theme/static_src/node_modules/
command: "yarn --cwd /experimenter/experimenter/nimbus_ui_new/theme/static_src run dev"
yarn-nimbus-ui:
image: experimenter:dev

Просмотреть файл

@ -68,9 +68,9 @@ COPY --from=file-loader /experimenter/experimenter/nimbus-ui/package.json /exper
RUN yarn install --frozen-lockfile
# Node packages for htmx ui
COPY --from=file-loader /experimenter/experimenter/theme/static_src/package.json /experimenter/experimenter/theme/static_src/package.json
COPY --from=file-loader /experimenter/experimenter/theme/static_src/yarn.lock /experimenter/experimenter/theme/static_src/yarn.lock
RUN yarn install --frozen-lockfile --cwd /experimenter/experimenter/theme/static_src
COPY --from=file-loader /experimenter/experimenter/nimbus_ui_new/theme/static_src/package.json /experimenter/experimenter/nimbus_ui_new/theme/static_src/package.json
COPY --from=file-loader /experimenter/experimenter/nimbus_ui_new/theme/static_src/yarn.lock /experimenter/experimenter/nimbus_ui_new/theme/static_src/yarn.lock
RUN yarn install --frozen-lockfile --cwd /experimenter/experimenter/nimbus_ui_new/theme/static_src
# Dev image
@ -88,7 +88,7 @@ COPY --from=python-builder /usr/local/lib/python3.11/site-packages/ /usr/local/l
# Node packages
COPY --from=node-builder /experimenter/experimenter/legacy/legacy-ui/core/node_modules/ /experimenter/experimenter/legacy/legacy-ui/core/node_modules/
COPY --from=node-builder /experimenter/experimenter/theme/static_src/node_modules/ /experimenter/experimenter/theme/static_src/node_modules/
COPY --from=node-builder /experimenter/experimenter/nimbus_ui_new/theme/static_src/node_modules/ /experimenter/experimenter/nimbus_ui_new/theme/static_src/node_modules/
COPY --from=node-builder /experimenter/experimenter/nimbus-ui/node_modules/ /experimenter/experimenter/nimbus-ui/node_modules/
COPY --from=node-builder /experimenter/node_modules/ /experimenter/node_modules/
@ -122,9 +122,9 @@ COPY --from=file-loader /experimenter/experimenter/nimbus-ui/ /experimenter/expe
RUN yarn workspace @experimenter/nimbus-ui build
# Build static assets
COPY --from=file-loader /experimenter/experimenter/theme/ /experimenter/experimenter/theme/
COPY --from=file-loader /experimenter/experimenter/templates/ /experimenter/experimenter/templates/
RUN yarn --cwd /experimenter/experimenter/theme/static_src build
COPY --from=file-loader /experimenter/experimenter/nimbus_ui_new/theme/ /experimenter/experimenter/nimbus_ui_new/theme/
COPY --from=file-loader /experimenter/experimenter/nimbus_ui_new/templates/ /experimenter/experimenter/nimbus_ui_new/templates/
RUN yarn --cwd /experimenter/experimenter/nimbus_ui_new/theme/static_src build
# Deploy image
@ -154,6 +154,6 @@ COPY --from=file-loader /experimenter/experimenter/ /experimenter/experimenter/
COPY --from=file-loader /experimenter/manifesttool/ /experimenter/manifesttool/
COPY --from=ui /experimenter/experimenter/legacy/legacy-ui/assets/ /experimenter/experimenter/legacy/legacy-ui/assets/
COPY --from=ui /experimenter/experimenter/nimbus-ui/build/ /experimenter/experimenter/nimbus-ui/build/
COPY --from=ui /experimenter/experimenter/theme/static/ /experimenter/experimenter/theme/static/
COPY --from=ui /experimenter/experimenter/static/scripts/ /experimenter/experimenter/static/scripts/
COPY --from=ui /experimenter/experimenter/nimbus_ui_new/theme/static/ /experimenter/experimenter/nimbus_ui_new/theme/static/
COPY --from=ui /experimenter/experimenter/nimbus_ui_new/static/scripts/ /experimenter/experimenter/nimbus_ui_new/static/scripts/
ENV PYTHONPATH=$PYTHONPATH:/application-services/

Просмотреть файл

@ -1,40 +0,0 @@
from django.test import RequestFactory, TestCase
from django.urls import reverse
from experimenter.changelog.views import NimbusChangeLogsView
from experimenter.experiments.tests.factories import (
NimbusChangeLogFactory,
NimbusExperimentFactory,
)
from experimenter.openidc.tests.factories import UserFactory
class NimbusChangeLogsViewTest(TestCase):
def setUp(self):
self.factory = RequestFactory()
self.user = UserFactory.create()
self.experiment = NimbusExperimentFactory.create(slug="test-experiment")
self.changelog1 = NimbusChangeLogFactory.create(
experiment=self.experiment, message="Change log 1"
)
self.changelog2 = NimbusChangeLogFactory.create(
experiment=self.experiment, message="Change log 2"
)
self.view = NimbusChangeLogsView.as_view()
def test_render_to_response(self):
request = self.factory.get(
reverse("changelogs-by-slug", kwargs={"slug": self.experiment.slug})
)
request.user = self.user
response = self.view(request, slug=self.experiment.slug)
self.assertEqual(response.status_code, 200)
def test_get_context_data(self):
request = self.factory.get(
reverse("changelogs-by-slug", kwargs={"slug": self.experiment.slug})
)
request.user = self.user
response = self.view(request, slug=self.experiment.slug)
context = response.context_data
self.assertEqual(context["experiment"], self.experiment)

Просмотреть файл

@ -1,9 +0,0 @@
from django.urls import re_path
from experimenter.changelog.views import NimbusChangeLogsView
urlpatterns = [
re_path(
r"^(?P<slug>[\w-]+)/$", NimbusChangeLogsView.as_view(), name="changelogs-by-slug"
),
]

Просмотреть файл

@ -197,7 +197,7 @@ export const AppLayoutSidebarLaunched = ({
/>
<LinkNav
route={`/history/${slug}`}
route={`/nimbus_new/${slug}/history/`}
testid={`history-page-${slug}`}
relativeToRoot
useButton

Просмотреть файл

@ -36,7 +36,7 @@ describe("AppLayoutWithSidebar", () => {
);
expect(
screen.getByTestId("history-page-my-special-slug"),
).toHaveAttribute("href", `/history/my-special-slug`);
).toHaveAttribute("href", `/nimbus_new/my-special-slug/history/`);
});
it("renders information about missing experiment details", async () => {

Просмотреть файл

@ -100,7 +100,7 @@ export const AppLayoutWithSidebar = ({
/>
<LinkNav
route={`/history/${slug}`}
route={`/nimbus_new/${slug}/history/`}
testid={`history-page-${slug}`}
relativeToRoot
useButton

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

Просмотреть файл

@ -0,0 +1,20 @@
from django.conf import settings
from django.test import TestCase
from django.urls import reverse
from experimenter.experiments.tests.factories import NimbusExperimentFactory
class NimbusChangeLogsViewTest(TestCase):
def test_render_to_response(self):
user_email = "user@example.com"
experiment = NimbusExperimentFactory.create(slug="test-experiment")
response = self.client.get(
reverse(
"nimbus-history",
kwargs={"slug": experiment.slug},
),
**{settings.OPENIDC_EMAIL_HEADER: user_email},
)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.context["experiment"], experiment)

Просмотреть файл

@ -0,0 +1 @@
default_app_config = "experimenter.nimbus_ui_new.theme.apps.ThemeConfig"

Просмотреть файл

@ -2,4 +2,4 @@ from django.apps import AppConfig
class ThemeConfig(AppConfig):
name = "experimenter.theme"
name = "experimenter.nimbus_ui_new.theme"

Просмотреть файл

@ -0,0 +1,11 @@
from django.urls import re_path
from experimenter.nimbus_ui_new.views import NimbusChangeLogsView
urlpatterns = [
re_path(
r"^(?P<slug>[\w-]+)/history/$",
NimbusChangeLogsView.as_view(),
name="nimbus-history",
),
]

Просмотреть файл

@ -104,7 +104,8 @@ INSTALLED_APPS = [
"experimenter.reporting",
"fontawesomefree",
"tailwind",
"experimenter.theme",
"experimenter.nimbus_ui_new",
"experimenter.nimbus_ui_new.theme",
]
TAILWIND_APP_NAME = "theme"
@ -130,8 +131,8 @@ TEMPLATES = [
"DIRS": [
BASE_DIR / "legacy" / "legacy-ui" / "templates",
BASE_DIR / "nimbus-ui" / "templates",
BASE_DIR / "nimbus_ui_new" / "templates",
BASE_DIR / "docs",
BASE_DIR / "templates",
],
"APP_DIRS": True,
"OPTIONS": {

Просмотреть файл

@ -1 +0,0 @@
default_app_config = "experimenter.theme.apps.ThemeConfig"

Просмотреть файл

@ -23,8 +23,8 @@ urlpatterns = [
re_path(r"^api/v5/", include("experimenter.experiments.api.v5.urls")),
re_path(r"^api/v6/", include("experimenter.experiments.api.v6.urls")),
re_path(r"^admin/", admin.site.urls),
re_path(r"^history/", include("experimenter.changelog.urls")),
re_path(r"^experiments/", include("experimenter.legacy.legacy_experiments.urls")),
re_path(r"^nimbus_new/", include("experimenter.nimbus_ui_new.urls")),
re_path(r"^nimbus/", NimbusUIView.as_view(), name="nimbus-list"),
re_path(r"^nimbus/(?P<slug>[\w-]+)/", NimbusUIView.as_view(), name="nimbus-detail"),
re_path(r"^legacy/$", ExperimentListView.as_view(), name="home"),