Skip to content

Commit

Permalink
Merge branch 'main' into feature/nytt-filter-design
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikpe committed Dec 13, 2023
2 parents 81c9130 + 9414e5f commit d7fb6bd
Show file tree
Hide file tree
Showing 56 changed files with 1,253 additions and 1,103 deletions.
13 changes: 0 additions & 13 deletions common/ktor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,12 @@ dependencies {
implementation(libs.ktor.server.core)
implementation(libs.ktor.server.metricsMicrometer)
implementation(libs.ktor.server.netty)
constraints {
implementation("io.netty:netty-codec-http2:4.1.101.Final") {
because("sikkerhetshull i transitiv avhengighet rapportert via dependabot. kan fjernes etter at vi har versjon av ktor > 2.3.6")
}
}
implementation(libs.ktor.server.statusPages)
implementation(libs.ktor.server.auth)
implementation(libs.ktor.server.authJwt)

// Audit-logging
implementation(libs.nav.common.auditLog)
constraints {
implementation(libs.logback.core) {
because("sikkerhetshull i transitiv avhengighet rapportert via snyk")
}
implementation(libs.logback.classic) {
because("sikkerhetshull i transitiv avhengighet rapportert via snyk")
}
}

// Cache
implementation(libs.caffeine)
Expand Down
8 changes: 4 additions & 4 deletions frontend/arena-adapter-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
"react-router-dom": "6.20.1"
},
"devDependencies": {
"@types/react": "18.2.42",
"@types/react": "18.2.43",
"@types/react-dom": "18.2.17",
"@typescript-eslint/eslint-plugin": "6.11.0",
"@typescript-eslint/eslint-plugin": "6.14.0",
"@vitejs/plugin-react": "4.2.1",
"eslint": "8.53.0",
"eslint": "8.55.0",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-react-refresh": "0.4.4",
"eslint-plugin-react-refresh": "0.4.5",
"typescript": "5.3.3",
"vite": "5.0.7"
}
Expand Down
18 changes: 9 additions & 9 deletions frontend/mr-admin-flate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
"playwright:codegen": "playwright codegen playwright.dev"
},
"dependencies": {
"@grafana/faro-web-sdk": "1.3.2",
"@grafana/faro-web-sdk": "1.3.4",
"@eik/rollup-plugin": "4.0.60",
"@hookform/resolvers": "3.3.2",
"@navikt/aksel-icons": "5.11.4",
"@navikt/ds-css": "5.11.4",
"@navikt/ds-react": "5.11.4",
"@portabletext/react": "3.0.11",
"@portabletext/types": "2.0.8",
"@tanstack/react-query": "5.12.2",
"@tanstack/react-query-devtools": "5.13.3",
"@tanstack/react-query": "5.13.4",
"@tanstack/react-query-devtools": "5.13.5",
"@types/is-url": "1.2.32",
"classnames": "2.3.2",
"debounce": "2.0.0",
Expand All @@ -42,7 +42,7 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"react-error-boundary": "4.0.11",
"react-hook-form": "7.48.2",
"react-hook-form": "7.49.0",
"react-router-dom": "6.20.1",
"react-select": "5.8.0",
"react-toastify": "9.1.3",
Expand All @@ -58,22 +58,22 @@
"@axe-core/playwright": "4.8.2",
"@playwright/test": "1.40.1",
"@rollup/plugin-terser": "0.4.4",
"@types/react": "18.2.42",
"@types/react": "18.2.43",
"@types/react-dom": "18.2.17",
"@typescript-eslint/eslint-plugin": "6.13.2",
"@typescript-eslint/eslint-plugin": "6.14.0",
"@vitejs/plugin-react": "4.2.1",
"axe-core": "4.8.2",
"cross-env": "7.0.3",
"eslint-config-prettier": "9.1.0",
"eslint-config-standard": "17.1.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-n": "16.3.1",
"eslint-plugin-n": "16.4.0",
"eslint-plugin-prettier": "5.0.1",
"eslint-plugin-promise": "6.1.1",
"eslint-plugin-react": "7.33.2",
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-react-refresh": "0.4.4",
"msw": "2.0.10",
"eslint-plugin-react-refresh": "0.4.5",
"msw": "2.0.11",
"rollup-plugin-import-map": "3.0.0",
"typescript": "5.3.3",
"vite": "5.0.7",
Expand Down
9 changes: 6 additions & 3 deletions frontend/mr-admin-flate/src/api/QueryKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ export const QueryKeys = {
tiltaksgjennomforingfilter?: TiltaksgjennomforingfilterProps,
) => ["tiltaksgjennomforinger", page, { ...tiltaksgjennomforingfilter }] as const,
tiltaksgjennomforing: (id?: string) => ["tiltaksgjennomforing", id] as const,
tiltaksgjennomforingHistorikk: (id?: string) =>
["tiltaksgjennomforing", id, "historikk"] as const,
tiltaksgjennomforingerByEnhet: (enhet: string = "enhet", page?: number) =>
[enhet, page, "tiltaksgjennomforinger"] as const,
veilederflateTiltaksgjennomforing: (id: string) => [id, "tiltaksgjennomforing"] as const,
ansatt: () => ["ansatt"] as const,
avtaler: (avtaleFilter: AvtaleFilterProps, page: number) =>
["avtaler", page, { ...avtaleFilter }] as const,
avtale: (avtaleId: string) => ["avtale", avtaleId],
avtaler: (mine?: boolean, page?: number, avtaleFilter?: AvtaleFilterProps) =>
["avtaler", mine, page, { ...avtaleFilter }] as const,
avtale: (id: string) => ["avtale", id],
avtaleHistorikk: (id?: string) => ["avtale", id, "historikk"] as const,
enheter: () => ["enheter"],
virksomheter: (til?: VirksomhetTil) => ["virksomheter", til],
antallUlesteNotifikasjoner: () => ["antallUlesteNotifikasjoner"],
Expand Down
16 changes: 12 additions & 4 deletions frontend/mr-admin-flate/src/api/avtaler/useAvbrytAvtale.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { mulighetsrommetClient } from "../clients";
import { ApiError } from "mulighetsrommet-api-client";
import { QueryKeys } from "../QueryKeys";

export function useAvbrytAvtale() {
const client = useQueryClient();

return useMutation<unknown, ApiError, string>({
mutationFn: (id: string) => {
return mulighetsrommetClient.avtaler.avbrytAvtale({ id });
},
onSuccess: () => {
client.invalidateQueries({
queryKey: ["avtale"],
});
onSuccess: (_, id) => {
return Promise.all([
client.invalidateQueries({
queryKey: QueryKeys.avtale(id),
}),

client.invalidateQueries({
queryKey: QueryKeys.avtaler(),
}),
]);
},
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useSuspenseQuery } from "@tanstack/react-query";
import { QueryKeys } from "../QueryKeys";
import { mulighetsrommetClient } from "../clients";

export function useAvtaleEndringshistorikk(id: string) {
return useSuspenseQuery({
queryKey: QueryKeys.avtaleHistorikk(id),
queryFn() {
return mulighetsrommetClient.avtaler.getAvtaleEndringshistorikk({
id,
});
},
});
}
4 changes: 2 additions & 2 deletions frontend/mr-admin-flate/src/api/avtaler/useAvtaler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useQuery } from "@tanstack/react-query";
import { WritableAtom, useAtom } from "jotai";
import { useAtom, WritableAtom } from "jotai";
import { useDebounce } from "mulighetsrommet-frontend-common";
import { QueryKeys } from "../QueryKeys";
import { AvtaleFilterProps, avtalePaginationAtomAtom } from "../atoms";
Expand All @@ -24,7 +24,7 @@ export function useAvtaler(
};

return useQuery({
queryKey: QueryKeys.avtaler({ ...filter, sok: debouncedSok }, page),
queryKey: QueryKeys.avtaler(filter.visMineAvtaler, page, { ...filter, sok: debouncedSok }),

queryFn: () => {
return filter.visMineAvtaler
Expand Down
17 changes: 16 additions & 1 deletion frontend/mr-admin-flate/src/api/avtaler/useUpsertAvtale.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import { useMutation } from "@tanstack/react-query";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { ApiError, Avtale, AvtaleRequest } from "mulighetsrommet-api-client";
import { mulighetsrommetClient } from "../clients";
import { QueryKeys } from "../QueryKeys";

export function useUpsertAvtale() {
const queryClient = useQueryClient();

return useMutation<Avtale, ApiError, AvtaleRequest>({
mutationFn: (requestBody: AvtaleRequest) =>
mulighetsrommetClient.avtaler.upsertAvtale({ requestBody }),

onSuccess(_, request) {
return Promise.all([
queryClient.invalidateQueries({
queryKey: QueryKeys.avtale(request.id),
}),

queryClient.invalidateQueries({
queryKey: QueryKeys.avtaler(),
}),
]);
},
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useSuspenseQuery } from "@tanstack/react-query";
import { QueryKeys } from "../QueryKeys";
import { mulighetsrommetClient } from "../clients";

export function useTiltaksgjennomforingEndringshistorikk(id: string) {
return useSuspenseQuery({
queryKey: QueryKeys.tiltaksgjennomforingHistorikk(id),
queryFn() {
return mulighetsrommetClient.tiltaksgjennomforinger.getTiltaksgjennomforingEndringshistorikk({
id,
});
},
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React, { ReactElement, useRef, useState } from "react";
import { ClockDashedIcon } from "@navikt/aksel-icons";
import { Button, Loader, Popover } from "@navikt/ds-react";
import { ErrorBoundary } from "react-error-boundary";
import { ErrorFallback } from "../../main";

export interface EndringshistorikkPopoverProps {
children: ReactElement;
}

export function EndringshistorikkPopover({ children }: EndringshistorikkPopoverProps) {
const [open, setOpen] = useState(false);
const buttonRef = useRef<HTMLButtonElement>(null);

return (
<>
<Button
ref={buttonRef}
onClick={() => setOpen(!open)}
aria-expanded={open}
variant="tertiary-neutral"
type="button"
size="small"
title="Trykk for å se endringshistorikk"
>
<ClockDashedIcon height={25} width={25} title="Endringshistorikk" />
</Button>

<Popover
open={open}
onClose={() => setOpen(false)}
anchorEl={buttonRef.current}
placement="bottom-end"
>
<Popover.Content>
<React.Suspense fallback={<Loader title="Laster endringshistorikk" />}>
<ErrorBoundary FallbackComponent={ErrorFallback}>{children}</ErrorBoundary>
</React.Suspense>
</Popover.Content>
</Popover>
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.endringshistorikkList {
list-style-type: none;
padding: 0;
margin: 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type {
Endringshistorikk,
EndringshistorikkNavAnsatt,
EndringshistorikkUser,
} from "mulighetsrommet-api-client";
import { formaterDatoTid } from "../../utils/Utils";
import styles from "./ViewEndringshistorikk.module.scss";

export interface ViewEndringshistorikkProps {
historikk: Endringshistorikk;
}

export function ViewEndringshistorikk(props: ViewEndringshistorikkProps) {
const { historikk } = props;

if (historikk.entries.length === 0) {
return <div>Endringshistorikken er tom</div>;
}

return (
<ul className={styles.endringshistorikkList}>
{historikk.entries.map(({ operation, editedAt, editedBy }) => {
const user = isNavAnsatt(editedBy)
? `${editedBy.navn} (${editedBy.navIdent})`
: editedBy.navn;

return (
<li key={editedAt}>
{formaterDatoTid(editedAt)} - <b>{operation}</b> - {user}
</li>
);
})}
</ul>
);
}

function isNavAnsatt(user: EndringshistorikkUser): user is EndringshistorikkNavAnsatt {
return "navIdent" in user;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ExclamationmarkTriangleFillIcon } from "@navikt/aksel-icons";
import { Button, ErrorSummary, Popover } from "@navikt/ds-react";
import PopoverContent from "@navikt/ds-react/esm/popover/PopoverContent";
import { useRef, useState } from "react";
import { useFormContext } from "react-hook-form";
import styles from "./ValideringsfeilOppsummering.module.scss";
Expand Down Expand Up @@ -51,7 +50,7 @@ export function ValideringsfeilOppsummering() {
onClose={() => setVisValideringsfeil(false)}
anchorEl={visValideringsFeilTrekantRef.current}
>
<PopoverContent>
<Popover.Content>
<ErrorSummary
className={styles.valideringsfeil}
heading="Det er valideringsfeil i skjema"
Expand All @@ -64,7 +63,7 @@ export function ValideringsfeilOppsummering() {
);
})}
</ErrorSummary>
</PopoverContent>
</Popover.Content>
</Popover>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export function fremmoteTidFromTidspunkt(fremmoteTidspunkt?: string): string | u
if (!fremmoteTidspunkt) return undefined;
const d = new Date(fremmoteTidspunkt);

return `${d.getHours()}:${d.getMinutes()}`;
return `${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`;
}

export function utkastDataEllerDefault(
Expand Down
13 changes: 13 additions & 0 deletions frontend/mr-admin-flate/src/pages/avtaler/AvtaleKnapperad.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Avtale } from "mulighetsrommet-api-client";
import { Lenkeknapp } from "../../components/lenkeknapp/Lenkeknapp";
import styles from "../DetaljerInfo.module.scss";
import { useAvtaleEndringshistorikk } from "../../api/avtaler/useAvtaleEndringshistorikk";
import { ViewEndringshistorikk } from "../../components/endringshistorikk/ViewEndringshistorikk";
import { EndringshistorikkPopover } from "../../components/endringshistorikk/EndringshistorikkPopover";

interface Props {
avtale: Avtale;
Expand All @@ -9,9 +12,19 @@ interface Props {
export function AvtaleKnapperad({ avtale }: Props) {
return (
<div className={styles.knapperad}>
<EndringshistorikkPopover>
<AvtaleEndringshistorikk id={avtale.id} />
</EndringshistorikkPopover>

<Lenkeknapp size="small" to={`/avtaler/${avtale.id}/skjema`} variant="primary">
Rediger avtale
</Lenkeknapp>
</div>
);
}

function AvtaleEndringshistorikk({ id }: { id: string }) {
const historikk = useAvtaleEndringshistorikk(id);

return <ViewEndringshistorikk historikk={historikk.data} />;
}
Loading

0 comments on commit d7fb6bd

Please sign in to comment.