Skip to content

Commit

Permalink
Merge pull request #695 from digitalfabrik/whitelabel-administration
Browse files Browse the repository at this point in the history
Prepare Administration for Nürnberg
  • Loading branch information
michael-markl authored Jan 10, 2023
2 parents 50558ca + 20381c2 commit aa3e6e8
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 30 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 8 additions & 5 deletions administration/src/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ const Router = () => {
<Routes>
<Route path={'/forgot-password'} element={<ForgotPasswordController />} />
<Route path={'/data-privacy-policy'} element={<DataPrivacyPolicy />} />
{projectConfig.projectId === 'bayern.ehrenamtskarte.app' ? (
<Route path={'/beantragen'} element={<ApplyController />} />
) : null}
{projectConfig.applicationFeatureEnabled ? <Route path={'/beantragen'} element={<ApplyController />} /> : null}
<Route path={'/reset-password/:passwordResetKey'} element={<ResetPasswordController />} />
<Route
path={'*'}
Expand All @@ -47,8 +45,13 @@ const Router = () => {
<Navigation onSignOut={signOut} />
<Main>
<Routes>
<Route path={'/applications'} element={<ApplicationsController token={authData.token} />} />
<Route path={'/region'} element={<RegionsController />} />
{projectConfig.applicationFeatureEnabled ? (
<>
<Route path={'/applications'} element={<ApplicationsController token={authData.token} />} />
{/*Currently, '/region' only allows to set the data privacy text for the application form*/}
<Route path={'/region'} element={<RegionsController />} />
</>
) : null}
<Route path={'/create-cards'} element={<CreateCardsController />} />
<Route path={'/users'} element={<ManageUsersController />} />
<Route path={'/user-settings'} element={<UserSettingsController />} />
Expand Down
41 changes: 23 additions & 18 deletions administration/src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,38 @@ const Navigation = (props: Props) => {
return (
<Navbar style={{ height: 'auto' }}>
<Navbar.Group>
<Navbar.Heading>{config.name} Verwaltung</Navbar.Heading>
<Navbar.Heading>
<NavLink to={'/'} style={{ color: 'black', textDecoration: 'none', display: 'block' }}>
<div style={{ flexDirection: 'column' }}>{config.name} Verwaltung</div>
{region === null ? null : (
<span>
{region.prefix} {region.name}
</span>
)}
</NavLink>
</Navbar.Heading>
<Navbar.Divider />
{region == null ? null : (
<>
<span>{region?.name ?? ''}</span>
<Navbar.Divider />
</>
)}
<NavLink to={'/'}>
<Button minimal icon='home' text='Home' />
</NavLink>
{role === Role.RegionAdmin || role === Role.RegionManager ? (
<>
<NavLink to={'/applications'}>
<Button minimal icon='form' text='Eingehende Anträge' />
</NavLink>
{config.applicationFeatureEnabled ? (
<NavLink to={'/applications'}>
<Button minimal icon='form' text='Eingehende Anträge' />
</NavLink>
) : null}
<NavLink to={'/create-cards'}>
<Button minimal icon='id-number' text='Karten erstellen' />
</NavLink>
</>
) : null}
{role === Role.ProjectAdmin || role === Role.RegionAdmin ? (
<>
<NavLink to={'/users'}>
<Button minimal icon='people' text='Benutzer verwalten' />
</NavLink>
</>
<NavLink to={'/users'}>
<Button minimal icon='people' text='Benutzer verwalten' />
</NavLink>
) : null}
{role === Role.RegionAdmin && config.applicationFeatureEnabled ? (
<NavLink to={'/region'}>
<Button minimal icon='path-search' text='Region verwalten' />
</NavLink>
) : null}
</Navbar.Group>
<Navbar.Group align={Alignment.RIGHT}>
Expand Down
12 changes: 8 additions & 4 deletions administration/src/components/home/HomeController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Role } from '../../generated/graphql'
import { AuthContext } from '../../AuthProvider'
import { NavLink } from 'react-router-dom'
import styled from 'styled-components'
import { ProjectConfigContext } from '../../project-configs/ProjectConfigContext'

const StyledButton = styled(Button)`
margin: 10px;
Expand All @@ -16,16 +17,19 @@ const Container = styled.div`
`

const HomeController = () => {
const { applicationFeatureEnabled } = useContext(ProjectConfigContext)
const role = useContext(AuthContext).data?.administrator.role

return (
<Container>
<H3>Wählen Sie eine Aktion aus:</H3>
{role === Role.RegionAdmin || role === Role.RegionManager ? (
<>
<NavLink to={'/applications'}>
<StyledButton icon='form' text='Eingehende Anträge' />
</NavLink>
{applicationFeatureEnabled ? (
<NavLink to={'/applications'}>
<StyledButton icon='form' text='Eingehende Anträge' />
</NavLink>
) : null}
<NavLink to={'/create-cards'}>
<StyledButton icon='id-number' text='Karten erstellen' />
</NavLink>
Expand All @@ -38,7 +42,7 @@ const HomeController = () => {
</NavLink>
</>
) : null}
{role === Role.RegionAdmin ? (
{role === Role.RegionAdmin && applicationFeatureEnabled ? (
<NavLink to={'/region'}>
<StyledButton icon='path-search' text='Region verwalten' />
</NavLink>
Expand Down
1 change: 1 addition & 0 deletions administration/src/project-configs/bayern/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ProjectConfig } from '../getProjectConfig'
const config: ProjectConfig = {
name: 'Ehrenamtskarte Bayern',
projectId: 'bayern.ehrenamtskarte.app',
applicationFeatureEnabled: true,
}

export default config
1 change: 1 addition & 0 deletions administration/src/project-configs/getProjectConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import showcaseConfig from './showcase/config'
export interface ProjectConfig {
name: string
projectId: string
applicationFeatureEnabled: boolean
}

const getProjectConfig = (hostname: string): ProjectConfig => {
Expand Down
3 changes: 2 additions & 1 deletion administration/src/project-configs/nuernberg/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ProjectConfig } from '../getProjectConfig'

const config: ProjectConfig = {
name: 'Sozialpass Nürnberg',
name: 'Digitaler Nürnberg-Pass',
projectId: 'nuernberg.sozialpass.app',
applicationFeatureEnabled: false,
}

export default config
1 change: 1 addition & 0 deletions administration/src/project-configs/showcase/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ProjectConfig } from '../getProjectConfig'
const config: ProjectConfig = {
name: 'Showcase Berechtigungskarte',
projectId: 'showcase.entitlementcard.app',
applicationFeatureEnabled: true,
}

export default config
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package app.ehrenamtskarte.backend.common.webservice

const val EAK_BAYERN_PROJECT = "bayern.ehrenamtskarte.app"
const val NUERNBERG_PASS_PROJECT = "nuernberg.sozialpass.app"
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package app.ehrenamtskarte.backend.regions.database

import app.ehrenamtskarte.backend.common.webservice.EAK_BAYERN_PROJECT
import app.ehrenamtskarte.backend.common.webservice.NUERNBERG_PASS_PROJECT
import app.ehrenamtskarte.backend.projects.database.ProjectEntity
import org.jetbrains.exposed.sql.SchemaUtils
import org.jetbrains.exposed.sql.transactions.transaction
Expand All @@ -18,7 +19,7 @@ fun setupDatabase() {
val eakProject = projects.firstOrNull { it.project == EAK_BAYERN_PROJECT }
?: throw Error("Required project '$EAK_BAYERN_PROJECT' not found!")
EAK_BAYERN_REGIONS.forEach { eakRegion ->
val dbRegion = dbRegions.find { it.regionIdentifier == eakRegion[2] }
val dbRegion = dbRegions.find { it.regionIdentifier == eakRegion[2] && it.projectId == eakProject.id }
if (dbRegion == null) {
RegionEntity.new {
projectId = eakProject.id
Expand All @@ -33,5 +34,23 @@ fun setupDatabase() {
dbRegion.website = eakRegion[3]
}
}

// Create or update nuernberg region in database
val nuernbergPassProject = projects.firstOrNull { it.project == NUERNBERG_PASS_PROJECT }
?: throw Error("Required project '$NUERNBERG_PASS_PROJECT' not found!")
val nuernbergRegion = dbRegions.singleOrNull { it.projectId == nuernbergPassProject.id }
if (nuernbergRegion == null) {
RegionEntity.new {
projectId = nuernbergPassProject.id
name = "Nürnberg"
prefix = "Stadt"
regionIdentifier = null
website = "https://nuernberg.de"
}
} else {
nuernbergRegion.name = "Nürnberg"
nuernbergRegion.prefix = "Stadt"
nuernbergRegion.website = "https://nuernberg.de"
}
}
}
2 changes: 1 addition & 1 deletion backend/src/main/resources/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ projects:
importUrl: https://example.com
pipelineName: SozialpassNuernberg
administrationBaseUrl: https://nuernberg.sozialpass.app
administrationName: Sozialpass-Nürnberg-Verwaltung
administrationName: Nürnberg-Pass-Verwaltung
timezone: "Europe/Berlin"
- id: showcase.entitlementcard.app
importUrl: https://example.com
Expand Down

0 comments on commit aa3e6e8

Please sign in to comment.