diff --git a/.github/workflows/build-and-deploy.yaml b/.github/workflows/build-and-deploy.yaml new file mode 100644 index 00000000..e2706523 --- /dev/null +++ b/.github/workflows/build-and-deploy.yaml @@ -0,0 +1,72 @@ +name: Bygg og deploy AAP Søknad +on: + workflow_dispatch: + push: + branches: + - main + paths-ignore: + - '**.md' +jobs: + buildDev: + uses: navikt/aap-workflows/.github/workflows/frontend-next-build.yml@main + permissions: + contents: read + id-token: write + packages: write + secrets: inherit + with: + cluster: dev-gcp + appname: 'aap-soknad' + playwright: false + cdn: true + buildProd: + uses: navikt/aap-workflows/.github/workflows/frontend-next-build.yml@main + permissions: + contents: read + id-token: write + packages: write + secrets: inherit + if: github.ref == 'refs/heads/main' + with: + cluster: prod-gcp + appname: 'aap-soknad' + playwright: true + cdn: true + deployDev: + needs: buildDev + uses: navikt/aap-workflows/.github/workflows/deploy.yml@main + permissions: + contents: read + id-token: write + secrets: inherit + with: + cluster: dev-gcp + manifest: .nais/nais.yaml + imageSuffix: -dev-gcp + vars: .nais/dev.yaml + deployProd: + needs: buildProd + uses: navikt/aap-workflows/.github/workflows/deploy.yml@main + permissions: + contents: read + id-token: write + if: github.ref == 'refs/heads/main' + secrets: inherit + with: + cluster: prod-gcp + manifest: .nais/nais.yaml,.nais/prod-alerts.yaml + imageSuffix: -prod-gcp + vars: .nais/prod.yaml + deployAlertsProd: + name: Deploy alerts to prod + needs: buildProd + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + steps: + - uses: actions/checkout@v4 + - name: Deploy alerts + uses: nais/deploy/actions/deploy@v1 + env: + APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} + CLUSTER: prod-gcp + RESOURCE: .nais/prod-alerts.yaml diff --git a/.github/workflows/build-dev-mock-historisk.yaml b/.github/workflows/build-dev-mock-historisk.yaml new file mode 100644 index 00000000..660fc419 --- /dev/null +++ b/.github/workflows/build-dev-mock-historisk.yaml @@ -0,0 +1,64 @@ +name: "Labs: historisk snapshot" +on: + workflow_dispatch: + push: + branches: + - "labs-historisk-**" +env: + "IMAGE": "ghcr.io/${{ github.repository }}-labs-historisk:${{ github.sha }}" +jobs: + buildMock: + name: build + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + env: + NPM_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} + SKIP_YARN_COREPACK_CHECK: true + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://npm.pkg.github.com + cache: yarn + - name: Enable Corepack + run: corepack enable + - name: Cache client node_modules + id: cache-node-modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - name: install dependencies Yarn + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: yarn install --immutable + - name: Copy env-file # TODO: Se om vi kan finne en bedre løsning her på sikt + run: cp .nais/dev-mock.env .env + - name: run build + run: yarn run build + - uses: nais/docker-build-push@v0 + with: + team: aap + identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} + project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} + image_suffix: -dev-gcp-mock-historisk + tag: ${{ github.sha }} + "deployAppToLabsHistorisk": + name: "Deploy branch to dev" + needs: "buildMock" + runs-on: "ubuntu-latest" + steps: + - uses: "actions/checkout@v3" + - uses: gacts/github-slug@v1 + id: slug + with: + to-slug: aap-soknad-${{ github.ref_name }} + - name: "Deploy historisk søknad til dev" + uses: "nais/deploy/actions/deploy@v1" + env: + "APIKEY": "${{ secrets.NAIS_DEPLOY_APIKEY }}" + "CLUSTER": "dev-gcp" + "RESOURCE": ".nais/historisk-dev-mock.yaml" + "VAR": image=${{ env.IMAGE }},ingress=https://${{ steps.slug.outputs.slug }}.ekstern.dev.nav.no,appname=${{ steps.slug.outputs.slug }},replicas=1,branchState=alive diff --git a/.github/workflows/build-dev-mock.yaml b/.github/workflows/build-dev-mock.yaml new file mode 100644 index 00000000..62b40d65 --- /dev/null +++ b/.github/workflows/build-dev-mock.yaml @@ -0,0 +1,60 @@ +name: Build and deploy mocket versjon av aap-soknad +on: + workflow_dispatch: + push: + branches: + - main + paths-ignore: + - '**.md' +env: + IMAGE_SUFFIX: dev-gcp-mock +jobs: + buildMock: + name: build + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + env: + NPM_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} + SKIP_YARN_COREPACK_CHECK: true + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://npm.pkg.github.com + cache: yarn + - name: Enable Corepack + run: corepack enable + - name: Cache client node_modules + id: cache-node-modules + uses: actions/cache@v4 + with: + path: node_modules + key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} + - name: install dependencies Yarn + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: yarn install --immutable + - name: Copy env-file # TODO: Se om vi kan finne en bedre løsning her på sikt + run: cp .nais/dev-mock.env .env + - name: run build + run: yarn run build + - uses: nais/docker-build-push@v0 + with: + team: aap + identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} + project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} + image_suffix: dev-gcp-mock + tag: ${{ github.sha }} + deployMock: + needs: buildMock + uses: navikt/aap-workflows/.github/workflows/deploy.yml@main + permissions: + contents: read + id-token: write + secrets: inherit + with: + cluster: dev-gcp + manifest: .nais/dev-mock.yaml + imageSuffix: -dev-gcp-mock diff --git a/.github/workflows/build-labs-historisk.yaml b/.github/workflows/build-labs-historisk.yaml deleted file mode 100644 index 0d16c779..00000000 --- a/.github/workflows/build-labs-historisk.yaml +++ /dev/null @@ -1,64 +0,0 @@ -name: "Labs: historisk snapshot" -on: - workflow_dispatch: - push: - branches: - - "labs-historisk-**" -env: - "IMAGE": "ghcr.io/${{ github.repository }}-labs-historisk:${{ github.sha }}" -jobs: - "build": - name: "build" - runs-on: "ubuntu-latest" - steps: - - uses: "actions/checkout@v3" - - uses: "actions/setup-node@v3" - with: - node-version: "20" - registry-url: "https://npm.pkg.github.com" - cache: "yarn" - - name: "install dependencies Yarn" - run: "yarn install --frozen-lockfile" - env: - NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} - - name: Copy env-file for labs - run: cp .nais/labs.env .env.local - - name: "client tests" - run: "yarn test" - - name: "Bygg klient(yarn run build)" - run: "yarn run build" - - name: "Set up Docker Buildx" - id: "buildx" - uses: "docker/setup-buildx-action@v1" - - name: "Login to GitHub Docker Registry" - uses: "docker/login-action@v1" - with: - "registry": "ghcr.io" - "username": "${{ github.actor }}" - "password": "${{ secrets.GITHUB_TOKEN }}" - - name: "Build and push Docker" - uses: "docker/build-push-action@v2" - with: - context: . - file: DockerfileLabs - tags: "${{ env.IMAGE }}" - push: "true" - cache-from: "type=gha" - cache-to: "type=gha,mode=max" - "deployAppToLabsHistorisk": - name: "Deploy branch to labs" - needs: "build" - runs-on: "ubuntu-latest" - steps: - - uses: "actions/checkout@v3" - - uses: gacts/github-slug@v1 - id: slug - with: - to-slug: aap-soknad-${{ github.ref_name }} - - name: "Deploy to LABS" - uses: "nais/deploy/actions/deploy@v1" - env: - "APIKEY": "${{ secrets.NAIS_DEPLOY_APIKEY }}" - "CLUSTER": "dev-gcp" - "RESOURCE": ".nais/historisk-labs.yaml" - "VAR": image=${{ env.IMAGE }},ingress=https://${{ steps.slug.outputs.slug }}.ekstern.dev.nav.no,appname=${{ steps.slug.outputs.slug }},replicas=1,branchState=alive diff --git a/.github/workflows/build-labs-mock.yaml b/.github/workflows/build-labs-mock.yaml deleted file mode 100644 index 2d6e0ecc..00000000 --- a/.github/workflows/build-labs-mock.yaml +++ /dev/null @@ -1,96 +0,0 @@ -name: Build and deploy aap-soknad to labs -on: - workflow_dispatch: - push: - branches: - - main - paths-ignore: - - '**.md' -env: - IMAGE_BASE: europe-north1-docker.pkg.dev/${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}/aap/${{ github.event.repository.name }} -jobs: - build: - name: build - runs-on: ubuntu-latest - outputs: - image: ${{ steps.image.outputs.image }} - permissions: - contents: read - id-token: write - packages: write - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: 20 - registry-url: https://npm.pkg.github.com - cache: yarn - - - name: Cache client node_modules - id: cache-node-modules - uses: actions/cache@v3 - with: - path: node_modules - key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} - - - name: install dependencies Yarn - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: yarn install --frozen-lockfile - env: - NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} - - - name: Copy env-file for labs - run: cp .nais/labs.env .env.local - - - name: client tests - run: yarn test - - - name: Bygg klient(yarn run build) - run: yarn run build - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: Setter tag-navn - run: echo "TAG=$(date +%Y.%m.%d.%H%M%S)-$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV - - - name: Setter image-navn - id: image - run: | - echo "IMAGE=$(echo $IMAGE_BASE)-$(echo $TAG)" >> $GITHUB_ENV - echo "image=$(echo $IMAGE_BASE)-$(echo $TAG)" >> $GITHUB_OUTPUT - - - name: Login GAR - uses: nais/login@v0 - with: - project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} - identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} - team: aap - - - name: Build and push Docker - uses: docker/build-push-action@v2 - with: - context: . - file: DockerfileLabs - tags: ${{ env.IMAGE }} - push: true - cache-from: type=gha - cache-to: type=gha,mode=max - - deployAppToLabs: - name: Deploy app to labs - needs: build - runs-on: ubuntu-latest - steps: - - - uses: actions/checkout@v3 - - - name: Deploy to LABS - uses: nais/deploy/actions/deploy@v1 - env: - IMAGE: ${{needs.build.outputs.image}} - APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} - CLUSTER: dev-gcp - RESOURCE: .nais/labs-gcp.yaml diff --git a/.github/workflows/labs-delete-historisk.yaml b/.github/workflows/dev-mock-delete-historisk.yaml similarity index 82% rename from .github/workflows/labs-delete-historisk.yaml rename to .github/workflows/dev-mock-delete-historisk.yaml index 27734fb1..23445f8f 100644 --- a/.github/workflows/labs-delete-historisk.yaml +++ b/.github/workflows/dev-mock-delete-historisk.yaml @@ -9,11 +9,11 @@ jobs: name: Delete branch labs-gcp runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Scale down labs-gcp + - uses: actions/checkout@v4 + - name: Scale down dev-gcp-mock-historisk uses: nais/deploy/actions/deploy@v1 env: APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} CLUSTER: dev-gcp - RESOURCE: ".nais/historisk-labs.yaml" + RESOURCE: ".nais/historisk-dev-mock.yaml" VAR: image=${{ env.IMAGE }},appname=${{env.APP_NAME}},ingress=https://${{env.APP_NAME}}.ekstern.dev.nav.no,replicas=0,branchState=deleted diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml deleted file mode 100644 index 43a53aee..00000000 --- a/.github/workflows/dev.yaml +++ /dev/null @@ -1,122 +0,0 @@ -name: Build and deploy aap-soknad to dev -on: - workflow_dispatch: - push: - branches: - - main - paths-ignore: - - '**.md' -env: - IMAGE_BASE: europe-north1-docker.pkg.dev/${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}/aap/${{ github.event.repository.name }} -jobs: - build: - name: build - runs-on: ubuntu-latest - outputs: - image: ${{ steps.image.outputs.image }} - permissions: - contents: write - id-token: write - packages: write - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: 20 - registry-url: https://npm.pkg.github.com - cache: yarn - - - name: Cache node_modules - id: cache-node-modules - uses: actions/cache@v3 - with: - path: node_modules - key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} - - - name: install dependencies Yarn - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: yarn install --frozen-lockfile - env: - NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} - - - name: Copy env-file for dev - run: cp .nais/dev.env .env.local - -# - name: client tests -# run: yarn test - - - name: check diff on translations - run: yarn intl:diff - - - name: Bygg klient(yarn run build) - run: | - npx browserslist@latest --update-db - yarn run build - - - name: Upload static files to NAV CDN dev - uses: navikt/frontend/actions/cdn-upload/v1@main - with: - cdn-team-name: aap - source: ./.next/static - destination: /aap-soknad/_next - -# - name: Install Playwright Browsers -# run: npx playwright install --with-deps - -# - name: Run Playwright tests -# run: yarn playwright test - -# - uses: actions/upload-artifact@v3 -# with: -# name: playwright-report -# path: playwright-report/ -# retention-days: 30 - - - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: Setter tag-navn - run: echo "TAG=$(date +%Y.%m.%d.%H%M%S)-$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV - - - name: Setter image-navn - id: image - run: | - echo "IMAGE=$(echo $IMAGE_BASE)-$(echo $TAG)" >> $GITHUB_ENV - echo "image=$(echo $IMAGE_BASE)-$(echo $TAG)" >> $GITHUB_OUTPUT - - - name: Login GAR - uses: nais/login@v0 - with: - project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} - identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} - team: aap - - - name: Build and push Docker - uses: docker/build-push-action@v4 - with: - context: . - file: Dockerfile - tags: ${{ env.IMAGE }}:latest - push: true - cache-from: type=gha - cache-to: type=gha,mode=max - - - deployAppToDev: - name: Deploy app to dev - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Deploy to DEV - uses: nais/deploy/actions/deploy@v1 - env: - IMAGE: ${{needs.build.outputs.image}} - APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} - CLUSTER: dev-gcp - RESOURCE: .nais/nais.yaml - VARS: .nais/dev.yaml diff --git a/.github/workflows/prod.yaml b/.github/workflows/prod.yaml deleted file mode 100644 index 340c9a9b..00000000 --- a/.github/workflows/prod.yaml +++ /dev/null @@ -1,124 +0,0 @@ -name: Build and deploy aap-soknad to prod -on: - workflow_dispatch: - push: - branches: - - main - paths-ignore: - - '**.md' -env: - IMAGE_BASE: europe-north1-docker.pkg.dev/${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}/aap/${{ github.event.repository.name }} -jobs: - build: - name: build - runs-on: ubuntu-latest - outputs: - image: ${{ steps.image.outputs.image }} - permissions: - contents: write - id-token: write - packages: write - steps: - - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: 20 - registry-url: https://npm.pkg.github.com - cache: yarn - - - name: Cache node_modules - id: cache-node-modules - uses: actions/cache@v3 - with: - path: node_modules - key: ${{ runner.os }}-modules-${{ hashFiles('yarn.lock') }} - - - name: install dependencies Yarn - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: yarn install --frozen-lockfile - env: - NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} - - - name: Copy env-file for prod - run: cp .nais/prod.env .env.local - - - name: client tests - run: yarn test - - - name: check diff on translations - run: yarn intl:diff - - - name: Bygg klient(yarn run build) - run: yarn run build - - - name: Upload static files to NAV CDN prod - uses: navikt/frontend/actions/cdn-upload/v1@main - with: - cdn-team-name: aap - source: ./.next/static - destination: /aap-soknad/_next - - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - - name: Run Playwright tests - run: yarn playwright test - - - uses: actions/upload-artifact@v3 - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: Setter tag-navn - run: echo "TAG=$(date +%Y.%m.%d.%H%M%S)-$(echo $GITHUB_SHA | cut -c1-7)" >> $GITHUB_ENV - - - name: Setter image-navn - id: image - run: | - echo "IMAGE=$(echo $IMAGE_BASE)-$(echo $TAG)" >> $GITHUB_ENV - echo "image=$(echo $IMAGE_BASE)-$(echo $TAG)" >> $GITHUB_OUTPUT - - - name: Login GAR - uses: nais/login@v0 - with: - project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} - identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} - team: aap - - - name: Build and push Docker - uses: docker/build-push-action@v4 - with: - context: . - file: Dockerfile - tags: ${{ env.IMAGE }}:latest - push: true - cache-from: type=gha - cache-to: type=gha,mode=max - - deployAppToProd: - name: Deploy app to prod - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Deploy to PROD - uses: nais/deploy/actions/deploy@v1 - env: - IMAGE: ${{needs.build.outputs.image}} - APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} - CLUSTER: prod-gcp - RESOURCE: .nais/nais.yaml - VARS: .nais/prod.yaml - - name: Deploy alerts - uses: nais/deploy/actions/deploy@v1 - env: - APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }} - CLUSTER: prod-gcp - RESOURCE: .nais/prod-alerts.yaml diff --git a/.gitignore b/.gitignore index 3fcfda68..35d69fef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,13 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # local env file +tsconfig.tsbuildinfo .env.local +#yarn berry +.yarn/install-state.gz + # dependencies -.yarn/ /node_modules /.pnp .pnp.js diff --git a/.nais/dev.env b/.nais/dev-gcp.env similarity index 100% rename from .nais/dev.env rename to .nais/dev-gcp.env diff --git a/.nais/labs.env b/.nais/dev-mock.env similarity index 82% rename from .nais/labs.env rename to .nais/dev-mock.env index d24741ea..94521b2f 100644 --- a/.nais/labs.env +++ b/.nais/dev-mock.env @@ -1,4 +1,5 @@ -RUNTIME_ENVIRONMENT="labs" +RUNTIME_ENVIRONMENT="localhost" +FUNCTIONAL_TESTS=enabled DECORATOR_ENV="dev" SOKNAD_API_URL="https://aap-soknad-api.dev.intern.nav.no" SOKNAD_API_AUDIENCE="dev-gcp:aap:soknad-api" diff --git a/.nais/labs-gcp.yaml b/.nais/dev-mock.yaml similarity index 86% rename from .nais/labs-gcp.yaml rename to .nais/dev-mock.yaml index f17c356d..fc6f1738 100644 --- a/.nais/labs-gcp.yaml +++ b/.nais/dev-mock.yaml @@ -19,9 +19,9 @@ spec: initialDelay: 20 timeout: 60 replicas: - min: 2 - max: 2 + min: 1 + max: 1 accessPolicy: outbound: external: - - host: "dekoratoren.ekstern.dev.nav.no" \ No newline at end of file + - host: "dekoratoren.ekstern.dev.nav.no" diff --git a/.nais/frozen-labs.yaml b/.nais/frozen-labs.yaml deleted file mode 100644 index 215f7b94..00000000 --- a/.nais/frozen-labs.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: "nais.io/v1alpha1" -kind: "Application" -metadata: - name: "aap-soknad-frozen" - namespace: "aap" - labels: - "team": "aap" -spec: - image: {{image}} - port: 3000 - ingresses: - - "https://aap-soknad-v1.labs.nais.io/" - liveness: - path: "/aap/soknad/api/internal/isAlive" - initialDelay: 20 - timeout: 60 - readiness: - path: "/aap/soknad/api/internal/isReady" - initialDelay: 20 - timeout: 60 - replicas: - min: 2 - max: 2 diff --git a/.nais/historisk-labs.yaml b/.nais/historisk-dev-mock.yaml similarity index 100% rename from .nais/historisk-labs.yaml rename to .nais/historisk-dev-mock.yaml diff --git a/.nais/prod.env b/.nais/prod-gcp.env similarity index 100% rename from .nais/prod.env rename to .nais/prod-gcp.env diff --git a/.npmrc b/.npmrc deleted file mode 100644 index 9503b6e6..00000000 --- a/.npmrc +++ /dev/null @@ -1 +0,0 @@ -@navikt:registry=https://npm.pkg.github.com \ No newline at end of file diff --git a/.yarnrc.yml b/.yarnrc.yml new file mode 100644 index 00000000..1499c502 --- /dev/null +++ b/.yarnrc.yml @@ -0,0 +1,7 @@ +nodeLinker: node-modules + +npmScopes: + navikt: + npmAlwaysAuth: true + npmAuthToken: "${NPM_AUTH_TOKEN:-}" + npmRegistryServer: "https://npm.pkg.github.com" diff --git a/Dockerfile b/Dockerfile index 082bc415..5258fb18 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,6 @@ RUN addgroup --system --gid 1069 nodejs RUN adduser --system --uid 1069 nextjs WORKDIR /app -COPY --chown=nextjs:nodejs .env.local ./ COPY --chown=nextjs:nodejs .next/standalone ./ COPY --chown=nextjs:nodejs .next/static ./.next/static diff --git a/DockerfileLabs b/DockerfileLabs deleted file mode 100644 index 082bc415..00000000 --- a/DockerfileLabs +++ /dev/null @@ -1,19 +0,0 @@ -FROM node:20-alpine - -ENV NODE_ENV production - -RUN addgroup --system --gid 1069 nodejs -RUN adduser --system --uid 1069 nextjs - -WORKDIR /app -COPY --chown=nextjs:nodejs .env.local ./ -COPY --chown=nextjs:nodejs .next/standalone ./ -COPY --chown=nextjs:nodejs .next/static ./.next/static - -USER nextjs - -EXPOSE 3000 - -ENV PORT 3000 - -CMD ["node", "server.js"] diff --git a/README.md b/README.md index 13c61486..0d52ce98 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,21 @@ Kom i gang: https://aap-team-innbygger.intern.nav.no/docs/Komme%20i%20gang/komme-i-gang-med-utvikling/ +## Bygge app lokalt + +### Github package registry + +Vi bruker Github sitt package registry for npm pakker, siden flere av Nav sine pakker kun blir publisert her. + +For å kunne kjøre `yarn install` lokalt må du logge inn mot Github package registry. Legg til følgende i .bashrc eller .zshrc lokalt på din maskin: +I .bashrc eller .zshrc: + +`export NPM_AUTH_TOKEN=github_pat` + +Hvor github_pat er din personal access token laget på github(settings -> developer settings). Husk read:packages rettighet og enable sso når du oppdaterer/lager PAT. + +--- + # Henvendelser --- diff --git a/auth/beskyttetApi.ts b/auth/beskyttetApi.ts index 61405028..95f3fbf8 100644 --- a/auth/beskyttetApi.ts +++ b/auth/beskyttetApi.ts @@ -1,8 +1,8 @@ import { NextApiRequest, NextApiResponse } from 'next'; import { isMock } from '../utils/environments'; import { verifyIdportenAccessToken } from './verifyIdPortenAccessToken'; -import { logger } from '@navikt/aap-felles-utils'; import { ErrorMedStatus } from './ErrorMedStatus'; +import { logError, logInfo, logWarning } from '@navikt/aap-felles-utils'; type ApiHandler = (req: NextApiRequest, res: NextApiResponse) => void | Promise; @@ -17,27 +17,27 @@ export function beskyttetApi(handler: ApiHandler): ApiHandler { try { if (isMock()) { - logger.warn('handling request for mocked environment, should not happen in production'); + logWarning('handling request for mocked environment, should not happen in production'); return handler(req, res); } const bearerToken: string | null | undefined = req.headers['authorization']; if (!bearerToken) { - logger.warn({ message: 'ingen bearer token', path: req?.url }); + logWarning(`ingen bearer token, path: ${req?.url}`); return send401(); } try { await verifyIdportenAccessToken(bearerToken); } catch (e) { - logger.error(e, 'kunne ikke validere idportentoken i beskyttetApi'); + logError('kunne ikke validere idportentoken i beskyttetApi', e); return send401(); } return handler(req, res); } catch (e) { - logger.error(e); - logger.info('handling error in beskyttetApi'); + logError('beskyttetApi', e); + logInfo('handling error in beskyttetApi'); if (e instanceof ErrorMedStatus) { - logger.info(`sending error with status ${e.status} and message ${e.message}`); + logInfo(`sending error with status ${e.status} and message ${e.message}`); return res.status(e.status).json({ message: e.message, navCallId: e.navCallId }); } } diff --git a/auth/beskyttetSide.ts b/auth/beskyttetSide.ts index d307b865..3cf6d66f 100644 --- a/auth/beskyttetSide.ts +++ b/auth/beskyttetSide.ts @@ -1,8 +1,8 @@ import { NextPageContext, GetServerSidePropsResult } from 'next'; -import { isMock } from '../utils/environments'; +import { isMock } from 'utils/environments'; import { getAccessToken } from './accessToken'; import { verifyIdportenAccessToken } from './verifyIdPortenAccessToken'; -import { logger } from '@navikt/aap-felles-utils'; +import { logError } from '@navikt/aap-felles-utils'; type PageHandler = (context: NextPageContext) => void | Promise>; @@ -15,7 +15,7 @@ const wonderwallRedirect = { export function beskyttetSide(handler: PageHandler) { return async function withBearerTokenHandler( - context: NextPageContext + context: NextPageContext, ): Promise> { if (isMock()) { return handler(context); @@ -30,7 +30,7 @@ export function beskyttetSide(handler: PageHandler) { try { await verifyIdportenAccessToken(bearerToken); } catch (e) { - logger.error(e, 'kunne ikke validere idportentoken i beskyttetSide'); + logError('kunne ikke validere idportentoken i beskyttetSide', e); return wonderwallRedirect; } return handler(context); @@ -42,5 +42,5 @@ export const beskyttetSideUtenProps = beskyttetSide( return { props: {}, }; - } + }, ); diff --git a/components/ButtonPanel/ButtonPanel.module.css b/components/ButtonPanel/ButtonPanel.module.css deleted file mode 100644 index 3c61e04d..00000000 --- a/components/ButtonPanel/ButtonPanel.module.css +++ /dev/null @@ -1,12 +0,0 @@ -.buttonPanel { - background: none; - border: none; - cursor: pointer; - box-shadow: 0 1px 1px rgba(0, 0, 0, 0.14), 0 2px 1px rgba(38, 38, 38, 0.12), - 0 1px 3px rgba(38, 38, 38, 0.2); - border-radius: 4px; - padding: var(--a-spacing-10); - display: flex; - flex-direction: row; - justify-content: space-between; -} diff --git a/components/ButtonPanel/ButtonPanel.tsx b/components/ButtonPanel/ButtonPanel.tsx deleted file mode 100644 index 4af84dfb..00000000 --- a/components/ButtonPanel/ButtonPanel.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import { Expand } from '@navikt/ds-icons'; -import * as classes from './ButtonPanel.module.css'; - -interface Props { - children?: React.ReactChild | React.ReactChild[]; - onClick: () => void; -} - -const ButtonPanel = ({ children, onClick }: Props) => { - return ( - - ); -}; -export default ButtonPanel; diff --git a/components/SoknadFormWrapper/LagreModal.tsx b/components/SoknadFormWrapper/LagreModal.tsx index 60a20ce8..eec7c324 100644 --- a/components/SoknadFormWrapper/LagreModal.tsx +++ b/components/SoknadFormWrapper/LagreModal.tsx @@ -11,7 +11,11 @@ interface Props { const LagreModal = ({ isOpen, onClose }: Props) => { const { formatMessage } = useIntl(); return ( - onClose(false)}> + onClose(false)} + aria-label={formatMessage({ id: 'lagreModal.heading' })} + > {formatMessage({ id: 'lagreModal.heading' })} diff --git a/components/SoknadFormWrapper/SlettModal.tsx b/components/SoknadFormWrapper/SlettModal.tsx index 7309e461..1831d91e 100644 --- a/components/SoknadFormWrapper/SlettModal.tsx +++ b/components/SoknadFormWrapper/SlettModal.tsx @@ -44,6 +44,7 @@ const SlettModal = ({ isOpen, onClose }: Props) => { e.preventDefault(); } }} + aria-label={formatMessage({ id: 'avbrytOgSlettModal.heading' })} > {!slettSøknadSuccess && ( diff --git a/components/pageComponents/standard/AndreUtbetalinger/AndreUtbetalinger.tsx b/components/pageComponents/standard/AndreUtbetalinger/AndreUtbetalinger.tsx index 6d4da3ba..e479d2c6 100644 --- a/components/pageComponents/standard/AndreUtbetalinger/AndreUtbetalinger.tsx +++ b/components/pageComponents/standard/AndreUtbetalinger/AndreUtbetalinger.tsx @@ -1,10 +1,9 @@ import { Alert, BodyShort, - Cell, Checkbox, CheckboxGroup, - Grid, + HGrid, Heading, Radio, RadioGroup, @@ -288,26 +287,24 @@ export const AndreUtbetalinger = ({ onBackClick }: Props) => { {StønadAlternativer.AFP} {søknadState.søknad?.andreUtbetalinger?.stønad?.includes(StønadType.AFP) && ( - - - - updateSøknadData(søknadDispatch, { - andreUtbetalinger: { - ...søknadState.søknad?.andreUtbetalinger, - afp: { - hvemBetaler: e.target.value, - }, + + + updateSøknadData(søknadDispatch, { + andreUtbetalinger: { + ...søknadState.søknad?.andreUtbetalinger, + afp: { + hvemBetaler: e.target.value, }, - }) - } - label={formatMessage({ id: 'søknad.andreUtbetalinger.hvemBetalerAfp.label' })} - error={errors?.find((e) => e.path === 'afp.hvemBetaler')?.message} - /> - - + }, + }) + } + label={formatMessage({ id: 'søknad.andreUtbetalinger.hvemBetalerAfp.label' })} + error={errors?.find((e) => e.path === 'afp.hvemBetaler')?.message} + /> + )} {StønadAlternativer.LÅN} diff --git a/components/pageComponents/standard/Barnetillegg/AddBarnModal.tsx b/components/pageComponents/standard/Barnetillegg/AddBarnModal.tsx index f201530b..4b752d26 100644 --- a/components/pageComponents/standard/Barnetillegg/AddBarnModal.tsx +++ b/components/pageComponents/standard/Barnetillegg/AddBarnModal.tsx @@ -124,6 +124,7 @@ export const AddBarnModal = ({ clearErrors(); onCloseClick(); }} + aria-label={formatMessage({ id: 'søknad.barnetillegg.leggTilBarn.modal.title' })} > diff --git a/components/pageComponents/standard/Behandlere/EndreEllerLeggTilBehandlerModal.tsx b/components/pageComponents/standard/Behandlere/EndreEllerLeggTilBehandlerModal.tsx index dabc4a9e..8c001f1f 100644 --- a/components/pageComponents/standard/Behandlere/EndreEllerLeggTilBehandlerModal.tsx +++ b/components/pageComponents/standard/Behandlere/EndreEllerLeggTilBehandlerModal.tsx @@ -25,7 +25,7 @@ export const getBehandlerSchema = (formatMessage: IntlFormatters['formatMessage' lastname: yup .string() .required( - formatMessage({ id: 'søknad.helseopplysninger.modal.etternavn.validation.required' }) + formatMessage({ id: 'søknad.helseopplysninger.modal.etternavn.validation.required' }), ) .nullable(), }); @@ -54,6 +54,7 @@ export const EndreEllerLeggTilBehandlerModal = ({ clearErrors(); onCloseClick(); }} + aria-label={formatMessage({ id: 'søknad.helseopplysninger.modal.title' })} > diff --git a/components/pageComponents/standard/Kvittering/Kvittering.tsx b/components/pageComponents/standard/Kvittering/Kvittering.tsx index fbac1aa3..ee3fa06d 100644 --- a/components/pageComponents/standard/Kvittering/Kvittering.tsx +++ b/components/pageComponents/standard/Kvittering/Kvittering.tsx @@ -3,24 +3,27 @@ import React from 'react'; import * as classes from './Kvittering.module.css'; import { KontaktInfoView, SøkerView } from 'context/sokerOppslagContext'; import { SuccessStroke } from '@navikt/ds-icons'; -import { SøknadApiType } from 'pages/api/oppslag/soeknader'; -import { clientSideIsLabs, clientSideIsProd } from 'utils/environments'; +import { clientSideIsProd, isFunctionalTest } from 'utils/environments'; import { FormattedMessage, useIntl } from 'react-intl'; interface StudentProps { søker: SøkerView; kontaktinformasjon?: KontaktInfoView; - søknad?: SøknadApiType; } -const Kvittering = ({ søker, kontaktinformasjon, søknad }: StudentProps) => { +const Kvittering = ({ søker, kontaktinformasjon }: StudentProps) => { const { formatMessage } = useIntl(); - const mineAapUrl = clientSideIsLabs() - ? process.env.NEXT_PUBLIC_MINE_AAP_URL - : clientSideIsProd() - ? 'https://nav.no/aap/mine-aap' - : 'https://aap-mine-aap.intern.dev.nav.no/aap/mine-aap'; + const mineAapUrl = () => { + if (clientSideIsProd()) { + return 'https://nav.no/aap/mine-aap'; + } + if (isFunctionalTest()) { + return process.env.NEXT_PUBLIC_MINE_AAP_URL; + } + return 'https://aap-mine-aap.intern.dev.nav.no/aap/mine-aap'; + }; + const dittNavUrl = clientSideIsProd() ? 'https://www.nav.no/person/dittnav/' : 'https://www.dev.nav.no/person/dittnav/'; @@ -43,7 +46,7 @@ const Kvittering = ({ søker, kontaktinformasjon, søknad }: StudentProps) => { - + {formatMessage({ id: 'søknad.kvittering.vedlegg.ettersendelseLink' })} @@ -89,7 +92,7 @@ const Kvittering = ({ søker, kontaktinformasjon, søknad }: StudentProps) => { )}
-
diff --git a/components/pageComponents/standard/Medlemskap/Medlemskap.tsx b/components/pageComponents/standard/Medlemskap/Medlemskap.tsx index 68e335a8..f7c03955 100644 --- a/components/pageComponents/standard/Medlemskap/Medlemskap.tsx +++ b/components/pageComponents/standard/Medlemskap/Medlemskap.tsx @@ -1,13 +1,4 @@ -import { - BodyShort, - Button, - Cell, - Grid, - Heading, - Radio, - RadioGroup, - ReadMore, -} from '@navikt/ds-react'; +import { BodyShort, Button, HGrid, Heading, Radio, RadioGroup, ReadMore } from '@navikt/ds-react'; import React, { useEffect, useState } from 'react'; import { JaEllerNei } from 'types/Generic'; import { Add } from '@navikt/ds-icons'; @@ -291,25 +282,23 @@ export const Medlemskap = ({ onBackClick }: Props) => { arbeidEllerBodd={arbeidEllerBodd} /> )} - - - - - + + + {utenlandsOppholdErrorMessage && (
diff --git a/components/pageComponents/standard/Medlemskap/UtenlandsOppholdTabell.tsx b/components/pageComponents/standard/Medlemskap/UtenlandsOppholdTabell.tsx index 020a0e6b..4edd3027 100644 --- a/components/pageComponents/standard/Medlemskap/UtenlandsOppholdTabell.tsx +++ b/components/pageComponents/standard/Medlemskap/UtenlandsOppholdTabell.tsx @@ -81,14 +81,7 @@ const UtenlandsOppholdTabell = ({ } }} onClick={() => remove(utenlandsPeriode.id)} - icon={ - - } + icon={} iconPosition={'left'} > Fjern diff --git a/components/pageComponents/standard/Oppsummering/AccordianItemOppsummering/AccordianItemOppsummering.tsx b/components/pageComponents/standard/Oppsummering/AccordianItemOppsummering/AccordianItemOppsummering.tsx index 997bbe3f..7cf78232 100644 --- a/components/pageComponents/standard/Oppsummering/AccordianItemOppsummering/AccordianItemOppsummering.tsx +++ b/components/pageComponents/standard/Oppsummering/AccordianItemOppsummering/AccordianItemOppsummering.tsx @@ -1,8 +1,7 @@ -import { Accordion, Alert, BodyShort, Cell, Grid, Link } from '@navikt/ds-react'; -import React, { useState } from 'react'; +import { Accordion, Alert, BodyShort, HGrid, Link } from '@navikt/ds-react'; +import React, { ReactNode, useEffect, useState } from 'react'; import * as classes from './AccordianItemOppsummering.module.css'; import { Back } from '@navikt/ds-icons'; -import { useEffect } from 'react'; type SummaryAccordianItemProps = { title: string; @@ -11,7 +10,7 @@ type SummaryAccordianItemProps = { toggleAll: boolean | undefined; showEdit?: boolean; editText?: string; - children?: React.ReactChild | React.ReactChild[]; + children?: ReactNode; hasError?: boolean; }; const AccordianItemOppsummering = ({ @@ -52,14 +51,12 @@ const AccordianItemOppsummering = ({ )} {showEdit && ( - - - - - {editText} - - - + + + + {editText} + + )}
diff --git a/components/pageComponents/standard/Oppsummering/Oppsummering.tsx b/components/pageComponents/standard/Oppsummering/Oppsummering.tsx index 9658ac97..c96efb51 100644 --- a/components/pageComponents/standard/Oppsummering/Oppsummering.tsx +++ b/components/pageComponents/standard/Oppsummering/Oppsummering.tsx @@ -82,7 +82,7 @@ const Oppsummering = ({ .oneOf([true], formatMessage({ id: 'søknad.oppsummering.confirmation.required' })), }); - const [toggleAll, setToggleAll] = useState(undefined); + const [toggleAll, setToggleAll] = useState(true); const [startDatoHasErrors] = useState( !getStartDatoSchema(formatMessage).isValidSync({ sykepenger: søknadState.søknad?.sykepenger, diff --git a/components/pageComponents/standard/Oppsummering/OppsummeringKontaktinfo/OppsummeringKontaktinfo.tsx b/components/pageComponents/standard/Oppsummering/OppsummeringKontaktinfo/OppsummeringKontaktinfo.tsx index 27c84d4b..027923f8 100644 --- a/components/pageComponents/standard/Oppsummering/OppsummeringKontaktinfo/OppsummeringKontaktinfo.tsx +++ b/components/pageComponents/standard/Oppsummering/OppsummeringKontaktinfo/OppsummeringKontaktinfo.tsx @@ -17,12 +17,6 @@ const OppsummeringKontaktinfo = ({ kontaktinformasjon }: Props) => { {søker?.fulltNavn} -
- - {søker?.fødselsnummer} -
{søker?.fullAdresse && (
- + void; + onDelete: (vedlegg: Vedlegg) => void; + brukFileInputInnsending: boolean; +}) => { + if (brukFileInputInnsending) { + return ( + onUpload(vedlegg)} + onDelete={(vedlegg) => onDelete(vedlegg)} + deleteUrl={deleteUrl} + uploadUrl={uploadUrl} + readAttachmentUrl={readAttachmentUrl} + files={files} + /> + ); + } + return ( + onUpload(vedlegg)} + onDelete={(vedlegg) => onDelete(vedlegg)} + deleteUrl={deleteUrl} + uploadUrl={uploadUrl} + readAttachmentUrl={readAttachmentUrl} + files={files} + /> + ); +}; diff --git a/components/pageComponents/standard/Vedlegg/Vedlegg.tsx b/components/pageComponents/standard/Vedlegg/Vedlegg.tsx index 83ffa0af..5ca9b94f 100644 --- a/components/pageComponents/standard/Vedlegg/Vedlegg.tsx +++ b/components/pageComponents/standard/Vedlegg/Vedlegg.tsx @@ -4,7 +4,7 @@ import { Alert, BodyLong, BodyShort, Heading, Label, Textarea } from '@navikt/ds import { completeAndGoToNextStep } from 'context/stepWizardContext'; import { useStepWizard } from 'hooks/StepWizardHook'; import { useDebounceLagreSoknad } from 'hooks/useDebounceLagreSoknad'; -import { FileInputInnsending, LucaGuidePanel } from '@navikt/aap-felles-react'; +import { LucaGuidePanel } from '@navikt/aap-felles-react'; import { useIntl } from 'react-intl'; import SoknadFormWrapperNew from 'components/SoknadFormWrapper/SoknadFormWrapper'; import { SøknadValidationError } from 'components/schema/FormErrorSummary'; @@ -13,15 +13,12 @@ import { setFocusOnErrorSummary } from '../../../schema/FormErrorSummary'; import { ScanningGuide } from './scanningguide/ScanningGuide'; import { addVedlegg, deleteVedlegg, updateSøknadData } from 'context/soknadcontext/actions'; import { useSoknad } from 'hooks/SoknadHook'; +import { FileInputWrapper } from 'components/pageComponents/standard/Vedlegg/FileInputWrapper'; interface Props { onBackClick: () => void; } -const deleteUrl = '/aap/soknad/api/vedlegginnsending/slett/?uuid='; -const uploadUrl = '/aap/soknad/api/vedlegginnsending/lagre/'; -const readAttachmentUrl = '/aap/soknad/vedlegg/'; - const Vedlegg = ({ onBackClick }: Props) => { const { formatMessage, locale } = useIntl(); const { søknadState, søknadDispatch } = useSoknad(); @@ -45,6 +42,11 @@ const Vedlegg = ({ onBackClick }: Props) => { const harPåkrevdeVedlegg = søknadState.requiredVedlegg.length > 0; + const deleteUrl = '/aap/soknad/api/vedlegginnsending/slett/?uuid='; + const uploadUrl = '/aap/soknad/api/vedlegginnsending/lagre/'; + + const readAttachmentUrl = '/aap/soknad/vedlegg/'; + return ( { @@ -90,7 +92,7 @@ const Vedlegg = ({ onBackClick }: Props) => { {søknadState?.requiredVedlegg?.find((e) => e.type === 'AVBRUTT_STUDIE') && ( - { uploadUrl={uploadUrl} readAttachmentUrl={readAttachmentUrl} files={søknadState.søknad?.vedlegg?.AVBRUTT_STUDIE || []} + brukFileInputInnsending={true} /> )} {søknadState?.requiredVedlegg?.find((e) => e.type === 'OMSORGSSTØNAD') && ( - { uploadUrl={uploadUrl} readAttachmentUrl={readAttachmentUrl} files={søknadState.søknad?.vedlegg?.OMSORGSSTØNAD || []} + brukFileInputInnsending={true} /> )} {søknadState?.requiredVedlegg?.find((e) => e.type === 'LØNN_OG_ANDRE_GODER') && ( - { uploadUrl={uploadUrl} readAttachmentUrl={readAttachmentUrl} files={søknadState.søknad?.vedlegg?.LØNN_OG_ANDRE_GODER || []} + brukFileInputInnsending={true} /> )} {søknadState?.requiredVedlegg?.find((e) => e.type === 'UTLANDSSTØNAD') && ( - { uploadUrl={uploadUrl} readAttachmentUrl={readAttachmentUrl} files={søknadState.søknad?.vedlegg?.UTLANDSSTØNAD || []} + brukFileInputInnsending={true} /> )} {søknadState.requiredVedlegg?.find((e) => e.type === 'LÅN') && ( - { uploadUrl={uploadUrl} readAttachmentUrl={readAttachmentUrl} files={søknadState.søknad?.vedlegg?.LÅN || []} + brukFileInputInnsending={true} /> )} {søknadState.requiredVedlegg?.find((e) => e.type === 'SYKESTIPEND') && ( - { uploadUrl={uploadUrl} readAttachmentUrl={readAttachmentUrl} files={søknadState.søknad?.vedlegg?.SYKESTIPEND || []} + brukFileInputInnsending={true} /> )} {søknadState?.søknad?.manuelleBarn?.map((barn) => { const requiredVedlegg = søknadState?.requiredVedlegg.find((e) => e?.type === barn.internId); return ( - { uploadUrl={uploadUrl} readAttachmentUrl={readAttachmentUrl} files={søknadState.søknad?.vedlegg?.[barn.internId] || []} + brukFileInputInnsending={true} /> ); })} - { uploadUrl={uploadUrl} readAttachmentUrl={readAttachmentUrl} files={søknadState.søknad?.vedlegg?.ANNET || []} + brukFileInputInnsending={true} />