diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-04-06 15:35:09 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-06 15:35:09 +0200 |
| commit | 0d4f19003324e196fffae3f252786e30197dfa4c (patch) | |
| tree | 08ba4eb3b0e067ae933c636ca3967c45058fd69f /opendc-web/opendc-web-ui/src/pages | |
| parent | af87540d49d58c465f0847c016814d58cfeb44fc (diff) | |
| parent | 9f0b7ddd0d62e4dc43a69ea8fafd06be1a663f9f (diff) | |
merge: Integrate UI into Quarkus web application (#69)
This pull request adds a Quarkus extension that integrates with the existing Quarkus web application to provide access to the OpenDC web UI. The benefit of this approach is that in this way, OpenDC can be distributed as a single JVM application to the user, which can host its own web UI directly.
Furthermore, this pull request also adds support for unauthenticated access to the API when accessing in dev mode, so that users do not have to setup Auth0 in order to use OpenDC locally.
## Implementation Notes :hammer_and_pick:
* Do not use next/image
* Migrate to next-global-css
* Update PatternFly to latest version
* Add Gradle integration with Next.js project
* Build web UI via Gradle
* Support building WebJar for OpenDC web UI
* Add extension for serving OpenDC web UI
* Include web UI in development mode
* Add workaround for Quarkus Gradle build issues
* Add support for unauthenticated user access
## External Dependencies :four_leaf_clover:
* [node-gradle](https://github.com/node-gradle/gradle-node-plugin)
Diffstat (limited to 'opendc-web/opendc-web-ui/src/pages')
| -rw-r--r-- | opendc-web/opendc-web-ui/src/pages/_app.js | 18 | ||||
| -rw-r--r-- | opendc-web/opendc-web-ui/src/pages/projects/index.js | 17 |
2 files changed, 12 insertions, 23 deletions
diff --git a/opendc-web/opendc-web-ui/src/pages/_app.js b/opendc-web/opendc-web-ui/src/pages/_app.js index 4861f5c1..bac9a5af 100644 --- a/opendc-web/opendc-web-ui/src/pages/_app.js +++ b/opendc-web/opendc-web-ui/src/pages/_app.js @@ -30,6 +30,7 @@ import { AuthProvider, useRequireAuth } from '../auth' import * as Sentry from '@sentry/react' import { Integrations } from '@sentry/tracing' import { QueryClientProvider } from 'react-query' +import { sentryDsn } from '../config' import '@patternfly/react-core/dist/styles/base.css' import '@patternfly/react-styles/css/utilities/Alignment/alignment.css' @@ -67,17 +68,14 @@ Inner.propTypes = { }).isRequired, } -const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN // Initialize Sentry if the user has configured a DSN -if (process.browser && dsn) { - if (dsn) { - Sentry.init({ - environment: process.env.NODE_ENV, - dsn: dsn, - integrations: [new Integrations.BrowserTracing()], - tracesSampleRate: 0.1, - }) - } +if (process.browser && sentryDsn) { + Sentry.init({ + environment: process.env.NODE_ENV, + dsn: sentryDsn, + integrations: [new Integrations.BrowserTracing()], + tracesSampleRate: 0.1, + }) } export default function App(props) { diff --git a/opendc-web/opendc-web-ui/src/pages/projects/index.js b/opendc-web/opendc-web-ui/src/pages/projects/index.js index bb1fbd69..40792275 100644 --- a/opendc-web/opendc-web-ui/src/pages/projects/index.js +++ b/opendc-web/opendc-web-ui/src/pages/projects/index.js @@ -23,38 +23,29 @@ import React, { useMemo, useState } from 'react' import Head from 'next/head' import ProjectFilterPanel from '../../components/projects/FilterPanel' -import { useAuth } from '../../auth' import { AppPage } from '../../components/AppPage' import { PageSection, PageSectionVariants, Text, TextContent } from '@patternfly/react-core' import { useProjects, useDeleteProject } from '../../data/project' import ProjectTable from '../../components/projects/ProjectTable' import NewProject from '../../components/projects/NewProject' -const getVisibleProjects = (projects, filter, userId) => { +const getVisibleProjects = (projects, filter) => { switch (filter) { case 'SHOW_ALL': return projects case 'SHOW_OWN': - return projects.filter((project) => - project.authorizations.some((a) => a.userId === userId && a.level === 'OWN') - ) + return projects.filter((project) => project.role === 'OWNER') case 'SHOW_SHARED': - return projects.filter((project) => - project.authorizations.some((a) => a.userId === userId && a.level !== 'OWN') - ) + return projects.filter((project) => project.role !== 'OWNER') default: return projects } } function Projects() { - const { user } = useAuth() const { status, data: projects } = useProjects() const [filter, setFilter] = useState('SHOW_ALL') - const visibleProjects = useMemo( - () => getVisibleProjects(projects ?? [], filter, user?.sub), - [projects, filter, user?.sub] - ) + const visibleProjects = useMemo(() => getVisibleProjects(projects ?? [], filter), [projects, filter]) const { mutate: deleteProject } = useDeleteProject() |
