Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PROD] Småfikser for feil lenker #416

Merged
merged 15 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions .eslintrc.cjs

This file was deleted.

6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: "daily"
interval: 'daily'
open-pull-requests-limit: 20
groups:
navikt-aksel:
Expand Down
30 changes: 18 additions & 12 deletions .github/workflows/main-v3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ jobs:
- name: Install bun
uses: oven-sh/setup-bun@v1

- name: Install lint dependencies
run: bun install

- name: Run lint
run: bun run lint

- name: Install dependencies (bun)
working-directory: './packages/internarbeidsflate-decorator-v3'
run: bun install
Expand All @@ -34,20 +40,20 @@ jobs:
if: github.ref == 'refs/heads/dev'
uses: nais/deploy/actions/cdn-upload/v2@master
with:
team: personoversikt
source: ./packages/internarbeidsflate-decorator-v3/dist/
destination: /internarbeidsflate-decorator-v3/dev/latest
no_cache_paths: "internarbeidsflate-decorator-v3/dev/latest/dist/asset-manifest.json,internarbeidsflate-decorator-v3/dev/latest/dist/bundle.js,internarbeidsflate-decorator-v3/dev/latest/dist/index.css"
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
team: personoversikt
source: ./packages/internarbeidsflate-decorator-v3/dist/
destination: /internarbeidsflate-decorator-v3/dev/latest
no_cache_paths: 'internarbeidsflate-decorator-v3/dev/latest/dist/asset-manifest.json,internarbeidsflate-decorator-v3/dev/latest/dist/bundle.js,internarbeidsflate-decorator-v3/dev/latest/dist/index.css'
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}

- name: Upload to CDN prod path
if: github.ref == 'refs/heads/master'
uses: nais/deploy/actions/cdn-upload/v2@master
with:
team: personoversikt
source: ./packages/internarbeidsflate-decorator-v3/dist/
destination: /internarbeidsflate-decorator-v3/prod/latest
no_cache_paths: "internarbeidsflate-decorator-v3/prod/latest/dist/asset-manifest.json,internarbeidsflate-decorator-v3/prod/latest/dist/bundle.js,internarbeidsflate-decorator-v3/prod/latest/dist/index.css"
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
team: personoversikt
source: ./packages/internarbeidsflate-decorator-v3/dist/
destination: /internarbeidsflate-decorator-v3/prod/latest
no_cache_paths: 'internarbeidsflate-decorator-v3/prod/latest/dist/asset-manifest.json,internarbeidsflate-decorator-v3/prod/latest/dist/bundle.js,internarbeidsflate-decorator-v3/prod/latest/dist/index.css'
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
2 changes: 1 addition & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"tabWidth": 2,
"singleQuote": true
}
}
Binary file modified bun.lockb
Binary file not shown.
34 changes: 34 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import prettier from 'eslint-plugin-prettier/recommended';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
{
ignores: ['**/dist/**/*'],
languageOptions: {
parserOptions: {
project: ['./tsconfig.json', './packages/*/tsconfig.json'],
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-misused-promises': [
'error',
{
checksVoidReturn: false,
},
],
},
},
{
files: ['**/*.js', 'vitest.workspace.ts'],
extends: [tseslint.configs.disableTypeChecked],
},
{
ignores: ['**/postcss.config.cjs'],
},
prettier,
);
13 changes: 11 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@
"packages/internarbeidsflate-decorator-v3"
],
"scripts": {
"clean": "rm -rf node_modules packages/dev-server/node_modules packages/internarbeidsflate-decorator-v3/node_modules bun.lockb packages/dev-server/bun.lockb packages/internarbeidsflate-decorator-v3/bun.lockb"
"clean": "rm -rf node_modules packages/dev-server/node_modules packages/internarbeidsflate-decorator-v3/node_modules bun.lockb packages/dev-server/bun.lockb packages/internarbeidsflate-decorator-v3/bun.lockb",
"lint": "eslint",
"format": "prettier . --write"
},
"devDependencies": {
"vite-plugin-dts": "^3.6.4"
"@eslint/js": "^9.2.0",
"eslint": "^9.2.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.6",
"prettier": "^3.2.5",
"typescript-eslint": "^7.8.0"
},
"dependencies": {
"@navikt/navspa": "^6.0.1"
Expand Down
5 changes: 2 additions & 3 deletions packages/dev-server/CustomServer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Serve, Server } from 'bun';
import {
Route,
Expand Down Expand Up @@ -248,9 +247,9 @@ export class CustomServer {
};
}

const hasParam = <T extends Record<string, any>>(
const hasParam = <T extends Record<string, string>>(
key: string,
params: T,
): params is T & { [K in typeof key]: any } => {
): params is T & { [K in typeof key]: string } => {
return key in params && params[key] !== '';
};
27 changes: 14 additions & 13 deletions packages/dev-server/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { CustomServer } from './CustomServer';
import { BadRequestResponse } from './responses/BadRequestResponse';
import { InternalServerErrorResponse } from './responses/InternalServerErrorResponse';
Expand All @@ -8,6 +7,10 @@ import { NotFoundResponse } from './responses/NotFoundResponse';
import { BunServerWebsocket } from './types';

type Metadata = { ident: string };
type Veileder = {
enheter: { enhetId: string }[];
};
type Event = { eventType: 'NY_AKTIV_ENHET' | 'NY_AKTIV_BRUKER'; verdi: string };

const serve = () => {
type Context = {
Expand Down Expand Up @@ -52,7 +55,7 @@ const serve = () => {
return new BadRequestResponse('Missing enhetId');
}

const response = mockMe.enheter.find(
const response = (mockMe as Veileder).enheter.find(
(enhet) => enhet.enhetId === request.params.enhetId,
);

Expand All @@ -68,11 +71,9 @@ const serve = () => {
return new BadRequestResponse('No body provided');
}

const {
eventType,
verdi,
}: { eventType: 'NY_AKTIV_ENHET' | 'NY_AKTIV_BRUKER'; verdi: string } =
await Bun.readableStreamToJSON(request.body);
const { eventType, verdi } = (await Bun.readableStreamToJSON(
request.body,
)) as Event;

if (eventType === 'NY_AKTIV_BRUKER') {
context.aktivBruker = verdi;
Expand All @@ -94,9 +95,9 @@ const serve = () => {
return new BadRequestResponse('No body provided');
}

const { code }: { code: string } = await Bun.readableStreamToJSON(
request.body,
);
const { code } = (await Bun.readableStreamToJSON(request.body)) as {
code: string;
};

const fnr = codeToFnr[code];

Expand All @@ -112,9 +113,9 @@ const serve = () => {
return new BadRequestResponse('No body provided');
}

const { fnr }: { fnr: string } = await Bun.readableStreamToJSON(
request.body,
);
const { fnr } = (await Bun.readableStreamToJSON(request.body)) as {
fnr: string;
};

const code = crypto.randomUUID();

Expand Down
2 changes: 1 addition & 1 deletion packages/dev-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"peerDependencies": {
"typescript": "^5.0.0"
}
}
}
6 changes: 2 additions & 4 deletions packages/dev-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
"allowJs": true,
"types": [
"bun-types" // add Bun global
],
]
},
"references": [
{ "path": "../../tsconfig.json" }
]
"references": [{ "path": "../../tsconfig.json" }]
}
2 changes: 1 addition & 1 deletion packages/dev-server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface WebSocketRoute<T = any> extends BaseRoute {
};
}

export type Params = Record<string, any>;
export type Params = Record<string, string>;
export type BunServerMetadata = BaseRoute & {
metadata?: Record<string, any> | undefined;
};
Expand Down
7 changes: 0 additions & 7 deletions packages/internarbeidsflate-decorator-v3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"dev:fullscreen": "VITE_DECORATOR_MODE=fullscreen bunx --bun vite",
"build": "bunx --bun vite build",
"build:watch": "bunx --bun vite build --watch",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"build-and-preview": "bunx --bun vite build && bunx --bun vite preview",
"preview": "bunx --bun vite preview",
"build:preview": "bunx --bun vite build --config preview.vite.config.ts",
Expand All @@ -29,17 +28,11 @@
"devDependencies": {
"@types/react": "^18.2.75",
"@types/react-dom": "^18.2.24",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.19",
"concurrently": "^8.2.2",
"eslint": "^8.57.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"msw": "^2.2.13",
"postcss": "^8.4.38",
"prettier": "^3.2.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwindcss": "^3.4.3",
Expand Down
7 changes: 2 additions & 5 deletions packages/internarbeidsflate-decorator-v3/postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
module.exports = () => ({
plugins: [
require('tailwindcss')(),
require('autoprefixer')()
]
})
plugins: [require('tailwindcss')(), require('autoprefixer')()],
});
70 changes: 0 additions & 70 deletions packages/internarbeidsflate-decorator-v3/src/App.tsx

This file was deleted.

34 changes: 34 additions & 0 deletions packages/internarbeidsflate-decorator-v3/src/Decorator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React, { PropsWithChildren } from 'react';
import './index.css';
import { AppProps } from './types/AppProps';
import useAppLogic from './hooks/useAppLogic';
import Banner from './components/Banner';
import Menu from './components/Menu';
import NewUserModal from './components/modals/NewUserModal';
import NewEnhetModal from './components/modals/NewEnhetModal';
import ErrorMessage from './components/ErrorMessageDisplay';
import { useOnOutsideClick } from './hooks/useOnOutsideClick';
import { useAppState } from './states/AppState';

const Decorator: React.FC<PropsWithChildren<AppProps>> = (props) => {
useAppLogic(props);
const ref = useOnOutsideClick<HTMLElement>(() =>
useAppState.setState({ open: false }),
);

return (
<>
<div className="dekorator" data-theme="internarbeidsflatedecorator-theme">
<header ref={ref} className="dr-font-arial dr-text-white">
<Banner />
<Menu />
<ErrorMessage />
</header>
</div>
<NewUserModal />
<NewEnhetModal />
</>
);
};

export default Decorator;
Loading
Loading