Skip to content

Commit

Permalink
fix bug where variables arent injected correctly (#213)
Browse files Browse the repository at this point in the history
* fix bug where variables arent injected correctly
  • Loading branch information
ssb-jnk authored Apr 9, 2024
1 parent 7445ae6 commit ccba344
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 21 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ COPY package*.json .
COPY server.js .

RUN npm i --save-exact express vite-express
WORKDIR /usr/local/app/dist
RUN cp -R /usr/local/app/dist/* .

ENV PORT 8080
EXPOSE 8080

ENTRYPOINT sh -c "./vite-envs.sh && npm run prod"
ENTRYPOINT ["sh", "-c", "./vite-envs.sh && npm run prod"]
77 changes: 65 additions & 12 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"prepare": "npx vite-envs update-types",
"dev": "nodemon server.js -w server.js",
"prod": "NODE_ENV=production node server.js",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint:fix": "eslint ./src --ext .jsx,.js,.ts,.tsx --quiet --fix --ignore-path ./.gitignore",
"lint:format": "prettier --loglevel warn --write \"./**/*.{js,jsx,ts,tsx,css,md,json}\" ",
"preview": "vite preview",
"prepare": "npx vite-envs update-types"
"preview": "vite preview"
},
"dependencies": {
"@emotion/react": "^11.11.4",
Expand Down Expand Up @@ -48,6 +48,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"typescript": "^5.4.4",
"vite-envs": "^4.0.6",
"vite": "^5.2.8"
}
}
6 changes: 5 additions & 1 deletion src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ const Header = () => {
</h2>
<div className={styles.navigation}>
<div className={styles.links}>
<Link href={import.meta.env.DAPLA_CTRL_DOCUMENTATION_URL} isExternal={true} icon={<BookOpen size='20' />}>
<Link
href={import.meta.env.DAPLA_CTRL_DOCUMENTATION_URL ?? ''}
isExternal={true}
icon={<BookOpen size='20' />}
>
Dokumentasjon
</Link>
<Link href='/teammedlemmer'>Teammedlemmer</Link>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/TeamOverview/TeamOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const TeamOverview = () => {
title='Teamoversikt'
content={renderContent()}
button={
<Button onClick={() => window.open(import.meta.env.DAPLA_CTRL_DAPLA_START_URL, 'noopener')}>
<Button onClick={() => window.open(import.meta.env.DAPLA_CTRL_DAPLA_START_URL ?? '', 'noopener')}>
+ Opprett team
</Button>
}
Expand Down
7 changes: 4 additions & 3 deletions src/utils/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ const fetchGroupMembership = async (groupUniformName: string): Promise<Group> =>
}

export const isDaplaAdmin = async (userPrincipalName: string): Promise<boolean> => {
const daplaAdminGroups = import.meta.env.DAPLA_CTRL_ADMIN_GROUPS.split(',')
if (daplaAdminGroups.length === 0) return false
const adminGroups = import.meta.env.DAPLA_CTRL_ADMIN_GROUPS ?? ''
const daplaAdminGroupsSeperated = adminGroups.split(',')
if (daplaAdminGroupsSeperated.length === 0) return false

try {
const adminGroupUsers = await Promise.all(
daplaAdminGroups.map((groupUniformName) => fetchGroupMembership(groupUniformName))
daplaAdminGroupsSeperated.map((groupUniformName) => fetchGroupMembership(groupUniformName))
)

return adminGroupUsers.some(
Expand Down
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default defineConfig({
plugins: [
react(),
viteEnvs({
declarationFile: '.env',
computedEnv: async ({ resolvedConfig }) => {
const path = await import('path')
const fs = await import('fs/promises')
Expand Down

0 comments on commit ccba344

Please sign in to comment.