diff --git a/a2cps_cms/src/taccsite_custom/a2cps_cms/templates/fullwidth.html b/a2cps_cms/src/taccsite_custom/a2cps_cms/templates/fullwidth.html index c0f92047..fcd9df54 100644 --- a/a2cps_cms/src/taccsite_custom/a2cps_cms/templates/fullwidth.html +++ b/a2cps_cms/src/taccsite_custom/a2cps_cms/templates/fullwidth.html @@ -5,4 +5,4 @@ {{ block.super }} {% include "./assets_custom.html" %} -{% endblock assets_custom %} +{% endblock assets_custom %} \ No newline at end of file diff --git a/apcd-cms/Dockerfile b/apcd-cms/Dockerfile index 4ac9a632..003ae508 100644 --- a/apcd-cms/Dockerfile +++ b/apcd-cms/Dockerfile @@ -13,4 +13,5 @@ RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - RUN apt-get install -y nodejs RUN chmod u+x /code/client/build_client.sh && /code/client/build_client.sh -RUN cp /code/client/dist/apcd-components.es.js /code/taccsite_custom/apcd_cms/static/ +RUN cp -R /code/client/dist/static/assets/. /code/taccsite_custom/apcd_cms/static/assets/ +RUN cp -R /code/client/dist/react-assets.html /code/taccsite_custom/apcd_cms/templates/react-asset.html \ No newline at end of file diff --git a/apcd-cms/docker-compose.dev.yml b/apcd-cms/docker-compose.dev.yml index 677f9089..3cb36cef 100644 --- a/apcd-cms/docker-compose.dev.yml +++ b/apcd-cms/docker-compose.dev.yml @@ -15,7 +15,6 @@ services: - ./src/taccsite_cms/settings_custom.py:/code/taccsite_cms/settings_custom.py - ./src/taccsite_cms/settings_local.py:/code/taccsite_cms/settings_local.py - ./src/taccsite_cms/secrets.py:/code/taccsite_cms/secrets.py - - ${PWD}/src/client/dist/:/code/taccsite_custom/apcd_cms/static/ networks: - core_cms_net diff --git a/apcd-cms/src/apps/admin_regis_table/templates/list_registrations.html b/apcd-cms/src/apps/admin_regis_table/templates/list_registrations.html index d7f272af..bf5efe49 100644 --- a/apcd-cms/src/apps/admin_regis_table/templates/list_registrations.html +++ b/apcd-cms/src/apps/admin_regis_table/templates/list_registrations.html @@ -1,19 +1,11 @@ -{% extends "standard.html" %} +{% extends "apcd_cms/templates/standard.html" %} + {% load static %} {% block content %} - - -{% block extra_js %} - -{% endblock %} -
{% include "nav_cms_breadcrumbs.html" %} @@ -40,7 +32,7 @@

List Registrations

{% endif %}
-
+
{% include 'paginator.html' %} -{% endblock %} -
{% include "nav_cms_breadcrumbs.html" %} @@ -24,7 +17,7 @@

View Submissions


All completed submissions by organizations


-
+
{% include 'paginator.html' %}
{% endblock %} diff --git a/apcd-cms/src/apps/view_users/templates/view_users.html b/apcd-cms/src/apps/view_users/templates/view_users.html index 63a5609b..96ebc2e8 100644 --- a/apcd-cms/src/apps/view_users/templates/view_users.html +++ b/apcd-cms/src/apps/view_users/templates/view_users.html @@ -1,4 +1,4 @@ -{% extends "standard.html" %} +{% extends "apcd_cms/templates/standard.html" %} {% load static %} {% block content %} @@ -9,9 +9,7 @@
{% include "nav_cms_breadcrumbs.html" %} -
+
- - {% endblock %} \ No newline at end of file diff --git a/apcd-cms/src/client/react-assets.html b/apcd-cms/src/client/react-assets.html new file mode 100644 index 00000000..7a986e3d --- /dev/null +++ b/apcd-cms/src/client/react-assets.html @@ -0,0 +1 @@ + diff --git a/apcd-cms/src/client/src/components/library.tsx b/apcd-cms/src/client/src/components/library.tsx deleted file mode 100644 index 6f890452..00000000 --- a/apcd-cms/src/client/src/components/library.tsx +++ /dev/null @@ -1,49 +0,0 @@ -// library.tsx -import React from 'react'; -import ReactDOM from 'react-dom'; -import { BrowserRouter } from 'react-router-dom'; -import { AdminRegistrations } from './Admin/Registrations'; -import { ViewUsers } from './Admin/ViewUsers'; -import { AdminSubmissions } from './Admin/Submissions'; -import { QueryClient, QueryClientProvider } from 'react-query'; - -const queryClient = new QueryClient(); - -function setupAdminRegistrations(): void { - const root = document.getElementById('admin-registrations-root'); - if (root) { - ReactDOM.render( - - - - - , - root - ); - } -} - -function setupViewUsers(): void { - const root = document.getElementById('react-root'); - if (root) { - ReactDOM.render( - - - - - , - root - ); - } -} - -function setupAdminSubmissions(): void { - ReactDOM.render( - - - , - document.getElementById('react-root') - ); -} - -export { setupAdminRegistrations, setupAdminSubmissions, setupViewUsers }; diff --git a/apcd-cms/src/client/src/main.tsx b/apcd-cms/src/client/src/main.tsx new file mode 100644 index 00000000..a62d94dc --- /dev/null +++ b/apcd-cms/src/client/src/main.tsx @@ -0,0 +1,43 @@ +// library.tsx +import React from 'react'; +import ReactDOM from 'react-dom'; +import { BrowserRouter } from 'react-router-dom'; +import { AdminRegistrations } from './components/Admin/Registrations'; +import { ViewUsers } from './components/Admin/ViewUsers'; +import { AdminSubmissions } from './components/Admin/Submissions'; +import { QueryClient, QueryClientProvider } from 'react-query'; + +const queryClient = new QueryClient(); + +function setupComponent(rootId: string, Component: React.ComponentType): void { + const root = document.getElementById(rootId); + if (root) { + ReactDOM.render( + + + + + , + root + ); + } +} + +// Mapping of element IDs to components +const componentMap: { [key: string]: React.ComponentType } = { + 'list-registrations-root': AdminRegistrations, + 'view-users-root': ViewUsers, + 'list-admin-submissions': AdminSubmissions, + // Add new components with html id in the list above. +}; + +function setupApp(): void { + Object.keys(componentMap).forEach(id => { + const elem = document.getElementById(id); + if (elem) { + setupComponent(id, componentMap[id]); + } + }); +} + +document.addEventListener('DOMContentLoaded', setupApp); \ No newline at end of file diff --git a/apcd-cms/src/client/tsconfig.json b/apcd-cms/src/client/tsconfig.json index 2bbf5891..da2f1d74 100644 --- a/apcd-cms/src/client/tsconfig.json +++ b/apcd-cms/src/client/tsconfig.json @@ -37,5 +37,5 @@ "src/**/*.spec.jsx", "src/**/*.test.jsx" ], - "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] + "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx", "main.tsx"] } diff --git a/apcd-cms/src/client/vite.config.ts b/apcd-cms/src/client/vite.config.ts index 3690b67a..f71ace9b 100644 --- a/apcd-cms/src/client/vite.config.ts +++ b/apcd-cms/src/client/vite.config.ts @@ -1,18 +1,23 @@ import eslint from '@rollup/plugin-eslint'; import { defineConfig, type PluginOption } from 'vite'; import react from '@vitejs/plugin-react'; -import {resolve} from 'path'; +import path, {resolve} from 'path'; export default defineConfig({ css: { preprocessorOptions: { scss: { charset: false } } }, build: { outDir: 'dist', - lib: { - entry: resolve(__dirname, 'src/components/library.tsx'), - name: 'APCDComponents', - fileName: 'apcd-components' - } + rollupOptions: { + input: { + imports: path.resolve(__dirname, 'react-assets.html'), + }, + output: { + entryFileNames: 'static/assets/[name].[hash].js', + chunkFileNames: 'static/assets/[name].[hash].js', + assetFileNames: 'static/assets/[name].[hash].[ext]' + } + }, }, resolve: { alias: { diff --git a/apcd-cms/src/taccsite_cms/custom_app_settings.py b/apcd-cms/src/taccsite_cms/custom_app_settings.py index f27eab60..5ee9b090 100644 --- a/apcd-cms/src/taccsite_cms/custom_app_settings.py +++ b/apcd-cms/src/taccsite_cms/custom_app_settings.py @@ -1,4 +1,4 @@ CUSTOM_APPS = ['apps.admin_regis_table', 'apps.apcd_login', 'apps.registrations', 'apps.submissions', 'apps.exception', 'apps.admin_submissions', 'apps.admin_extension', 'apps.admin_exception', 'apps.extension', 'apps.submitter_renewals_listing', 'apps.view_users', 'apps.components.paginator', 'apps.utils'] CUSTOM_MIDDLEWARE = [] -STATICFILES_DIRS = ('taccsite_custom/apcd-cms', 'apps/admin_regis_table', 'apps/submissions', 'apps/exception', 'apps/extension', 'apps/submitter_renewals_listing', 'apps/view_users', 'apps/components/paginator', 'apps/utils', 'client/dist') +STATICFILES_DIRS = ('taccsite_custom/apcd_cms', 'apps/admin_regis_table', 'apps/submissions', 'apps/exception', 'apps/extension', 'apps/submitter_renewals_listing', 'apps/view_users', 'apps/components/paginator', 'apps/utils', 'client/dist') diff --git a/apcd-cms/src/taccsite_custom/apcd_cms/static/apcd-cms/apcd-components.es.js b/apcd-cms/src/taccsite_custom/apcd_cms/static/apcd-cms/apcd-components.es.js deleted file mode 100755 index e69de29b..00000000 diff --git a/apcd-cms/src/taccsite_custom/apcd_cms/templates/standard.html b/apcd-cms/src/taccsite_custom/apcd_cms/templates/standard.html new file mode 100644 index 00000000..910d7f15 --- /dev/null +++ b/apcd-cms/src/taccsite_custom/apcd_cms/templates/standard.html @@ -0,0 +1,23 @@ + +{% extends "standard.html" %} +{% load cms_tags %} + +{% block assets_custom %} + {{ block.super }} + + {% include "./assets_custom.html" %} + + {% if settings.DEBUG %} + + + + {% else %} + {% include "./react-assets.html" %} + {% endif %} +{% endblock assets_custom %}