From 45afc4e27e6547d9dc29d8532527b43626dd6268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristen=20H=C3=A6rum?= Date: Tue, 27 Feb 2024 22:09:41 +0100 Subject: [PATCH 01/10] =?UTF-8?q?Remove=20Sikkerhetstiltak=20related=20fil?= =?UTF-8?q?es=20and=20functionalities=20#deploy-tps=E2=80=A6=20(#3426)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove Sikkerhetstiltak related files and functionalities --- .../TpsMessagingClient.java | 39 +------- .../TpsMessagingConsumer.java | 17 ---- .../SikkerhetstiltakDeleteCommand.java | 53 ---------- .../dto/SikkerhetstiltakRequest.java | 58 ----------- .../dto/SikkerhetstiltakResponse.java | 20 ---- .../mapper/S610PersonMappingStrategy.java | 2 +- .../SikkerhetstiltakMappingStrategy.java | 40 -------- .../provider/v1/PersonController.java | 18 ---- .../service/IdentService.java | 15 ++- .../service/SikkerhetstiltakService.java | 96 ------------------- 10 files changed, 10 insertions(+), 348 deletions(-) delete mode 100644 apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/command/SikkerhetstiltakDeleteCommand.java delete mode 100644 apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/dto/SikkerhetstiltakRequest.java delete mode 100644 apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/dto/SikkerhetstiltakResponse.java delete mode 100644 apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/SikkerhetstiltakService.java diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/TpsMessagingClient.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/TpsMessagingClient.java index 8d15508e5b5..550e2ef5200 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/TpsMessagingClient.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/TpsMessagingClient.java @@ -14,7 +14,6 @@ import no.nav.dolly.domain.resultset.dolly.DollyPerson; import no.nav.dolly.errorhandling.ErrorStatusDecoder; import no.nav.dolly.util.TransactionHelperService; -import no.nav.testnav.libs.data.pdlforvalter.v1.SikkerhetstiltakDTO; import no.nav.testnav.libs.data.tpsmessagingservice.v1.SpraakDTO; import no.nav.testnav.libs.data.tpsmessagingservice.v1.TpsMeldingResponseDTO; import org.apache.commons.lang3.StringUtils; @@ -26,7 +25,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -98,15 +96,7 @@ public Flux gjenopprett(RsDollyUtvidetBestilling bestilling, Dolly sendEgenansattSlett(bestilling, dollyPerson.getIdent()) .map(respons -> Map.of("Egenansatt_slett", respons)), sendEgenansatt(bestilling, dollyPerson.getIdent()) - .map(respons -> Map.of("Egenansatt_opprett", respons)), - sendSikkerhetstiltakSlett(personer.stream() - .filter(personBolk -> personBolk.getIdent().equals(dollyPerson.getIdent())) - .findFirst()) - .map(respons -> Map.of("Sikkerhetstiltak_slett", respons)), - sendSikkerhetstiltakOpprett(personer.stream() - .filter(personBolk -> personBolk.getIdent().equals(dollyPerson.getIdent())) - .findFirst()) - .map(respons -> Map.of("Sikkerhetstiltak_opprett", respons)) + .map(respons -> Map.of("Egenansatt_opprett", respons)) )) .map(respons -> respons.entrySet().stream() .map(entry -> getStatus(entry.getKey(), entry.getValue())) @@ -127,8 +117,7 @@ private boolean isTpsMessage(RsDollyUtvidetBestilling bestilling) { nonNull(bestilling.getSkjerming()) || (nonNull(bestilling.getPdldata()) && - nonNull(bestilling.getPdldata().getPerson()) && - !bestilling.getPdldata().getPerson().getSikkerhetstiltak().isEmpty()); + nonNull(bestilling.getPdldata().getPerson())); } private ClientFuture futurePersist(DollyPerson dollyPerson, BestillingProgress progress, String status) { @@ -178,30 +167,6 @@ private Flux getPersonData(List identer) { .filter(personBolk -> nonNull(personBolk.getPerson())); } - private Mono> sendSikkerhetstiltakSlett(Optional personBolk) { - - return personBolk.isPresent() && !personBolk.get().getPerson().getSikkerhetstiltak().isEmpty() ? - - tpsMessagingConsumer.deleteSikkerhetstiltakRequest( - personBolk.get().getIdent(), null) - .collectList() : - - Mono.just(emptyList()); - } - - private Mono> sendSikkerhetstiltakOpprett(Optional personBolk) { - - return personBolk.isPresent() && !personBolk.get().getPerson().getSikkerhetstiltak().isEmpty() ? - - tpsMessagingConsumer.sendSikkerhetstiltakRequest( - personBolk.get().getIdent(), null, - personBolk.get().getPerson().getSikkerhetstiltak() - .stream().findFirst().orElse(new SikkerhetstiltakDTO())) - .collectList() : - - Mono.just(emptyList()); - } - private Mono> sendSpraakkode(RsDollyUtvidetBestilling bestilling, String ident) { return nonNull(bestilling.getTpsMessaging()) && nonNull(bestilling.getTpsMessaging().getSpraakKode()) ? diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/TpsMessagingConsumer.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/TpsMessagingConsumer.java index a7a11e11005..a06891bd259 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/TpsMessagingConsumer.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/TpsMessagingConsumer.java @@ -6,7 +6,6 @@ import no.nav.dolly.bestilling.tpsmessagingservice.command.EgenansattDeleteCommand; import no.nav.dolly.bestilling.tpsmessagingservice.command.EgenansattPostCommand; import no.nav.dolly.bestilling.tpsmessagingservice.command.PersonGetCommand; -import no.nav.dolly.bestilling.tpsmessagingservice.command.SikkerhetstiltakDeleteCommand; import no.nav.dolly.bestilling.tpsmessagingservice.command.TpsMessagingPostCommand; import no.nav.dolly.config.Consumers; import no.nav.dolly.metrics.Timed; @@ -33,7 +32,6 @@ public class TpsMessagingConsumer implements ConsumerStatus { private static final String BASE_URL = "/api/v1/personer/{ident}"; private static final String UTENLANDSK_BANKKONTO_URL = BASE_URL + "/bankkonto-utenlandsk"; private static final String NORSK_BANKKONTO_URL = BASE_URL + "/bankkonto-norsk"; - private static final String SIKKERHETSTILTAK_URL = BASE_URL + "/sikkerhetstiltak"; private static final String SPRAAKKODE_URL = BASE_URL + "/spraakkode"; private final WebClient webClient; @@ -71,21 +69,6 @@ public Flux sendNorskBankkontoRequest(String ident, List< new TpsMessagingPostCommand(webClient, ident, miljoer, body, NORSK_BANKKONTO_URL, token.getTokenValue()).call()); } - @Timed(name = "providers", tags = {"operation", "tps_messaging_deleteSikkerhetstiltak"}) - public Flux deleteSikkerhetstiltakRequest(String ident, List miljoer) { - - return tokenService.exchange(serverProperties) - .flatMapMany(token -> new SikkerhetstiltakDeleteCommand(webClient, ident, miljoer, token.getTokenValue()).call()); - } - - @Timed(name = "providers", tags = {"operation", "tps_messaging_createSikkerhetstiltak"}) - public Flux sendSikkerhetstiltakRequest(String ident, List miljoer, Object body) { - - return tokenService.exchange(serverProperties) - .flatMapMany(token -> - new TpsMessagingPostCommand(webClient, ident, miljoer, body, SIKKERHETSTILTAK_URL, token.getTokenValue()).call()); - } - @Timed(name = "providers", tags = {"operation", "tps_messaging_createSkjerming"}) public Flux sendEgenansattRequest(String ident, List miljoer, LocalDate fraOgMed) { diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/command/SikkerhetstiltakDeleteCommand.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/command/SikkerhetstiltakDeleteCommand.java deleted file mode 100644 index c1123461127..00000000000 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/tpsmessagingservice/command/SikkerhetstiltakDeleteCommand.java +++ /dev/null @@ -1,53 +0,0 @@ -package no.nav.dolly.bestilling.tpsmessagingservice.command; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import no.nav.testnav.libs.data.tpsmessagingservice.v1.TpsMeldingResponseDTO; -import no.nav.testnav.libs.reactivecore.utils.WebClientFilter; -import org.springframework.http.HttpHeaders; -import org.springframework.web.reactive.function.client.WebClient; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import reactor.util.retry.Retry; - -import java.time.Duration; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.Callable; - -import static java.util.Objects.nonNull; - -@RequiredArgsConstructor -@Slf4j -public class SikkerhetstiltakDeleteCommand implements Callable> { - - private static final String SIKKERHETSTILTAK_URL = "/api/v1/personer/{ident}/sikkerhetstiltak"; - private static final String MILJOER_PARAM = "miljoer"; - - private final WebClient webClient; - private final String ident; - private final List miljoer; - private final String token; - - @Override - public Flux call() { - - log.trace("Sender delete request på ident: {} til TPS messaging service", ident); - - return webClient.delete() - .uri(uriBuilder -> uriBuilder - .path(SIKKERHETSTILTAK_URL) - .queryParamIfPresent(MILJOER_PARAM, nonNull(miljoer) ? Optional.of(miljoer) : Optional.empty()) - .build(ident)) - .header(HttpHeaders.AUTHORIZATION, "Bearer " + token) - .retrieve() - .bodyToFlux(TpsMeldingResponseDTO.class) - .doOnError(WebClientFilter::logErrorMessage) - .retryWhen(Retry.backoff(3, Duration.ofSeconds(5)) - .filter(WebClientFilter::is5xxException)) - .onErrorResume(throwable -> Mono.just(TpsMeldingResponseDTO.builder() - .status("FEIL") - .utfyllendeMelding(WebClientFilter.getMessage(throwable)) - .build())); - } -} diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/dto/SikkerhetstiltakRequest.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/dto/SikkerhetstiltakRequest.java deleted file mode 100644 index 9f78c0345a9..00000000000 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/dto/SikkerhetstiltakRequest.java +++ /dev/null @@ -1,58 +0,0 @@ -package no.nav.testnav.apps.tpsmessagingservice.dto; - -import com.fasterxml.jackson.annotation.JsonInclude; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import jakarta.xml.bind.annotation.XmlRootElement; -import jakarta.xml.bind.annotation.XmlType; - -@Data -@SuperBuilder -@EqualsAndHashCode(callSuper = true) -@NoArgsConstructor -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@XmlRootElement(name = "sfePersonData") -public class SikkerhetstiltakRequest extends EndringsmeldingRequest { - - private SfeAjourforing sfeAjourforing; - - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @XmlType(propOrder = {"systemInfo", "opprettSikkerhetsTiltak", "opphorSikkerhetsTiltak"}) - public static class SfeAjourforing { - - private TpsSystemInfo systemInfo; - private Sikkerhetstiltak opprettSikkerhetsTiltak; - private BrukerIdentifikasjon opphorSikkerhetsTiltak; - } - - @Data - @SuperBuilder - @EqualsAndHashCode(callSuper = true) - @NoArgsConstructor - @AllArgsConstructor - @XmlType(propOrder = {"typeSikkerhetsTiltak", "beskrSikkerhetsTiltak", "fom", "tom"}) - public static class Sikkerhetstiltak extends BrukerIdentifikasjon { - - private String typeSikkerhetsTiltak; - private String beskrSikkerhetsTiltak; - private String fom; - private String tom; - } - - @Data - @SuperBuilder - @NoArgsConstructor - @XmlType(propOrder = {"offentligIdent"}) - public static class BrukerIdentifikasjon { - - private String offentligIdent; - } -} \ No newline at end of file diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/dto/SikkerhetstiltakResponse.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/dto/SikkerhetstiltakResponse.java deleted file mode 100644 index d05bfa0d0a6..00000000000 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/dto/SikkerhetstiltakResponse.java +++ /dev/null @@ -1,20 +0,0 @@ -package no.nav.testnav.apps.tpsmessagingservice.dto; - -import com.fasterxml.jackson.annotation.JsonInclude; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import jakarta.xml.bind.annotation.XmlRootElement; - -@Data -@SuperBuilder -@EqualsAndHashCode(callSuper = true) -@NoArgsConstructor -@JsonInclude(JsonInclude.Include.NON_EMPTY) -@XmlRootElement(name = "sfePersonData") -public class SikkerhetstiltakResponse extends EndringsmeldingResponse { - - private SikkerhetstiltakRequest.SfeAjourforing sfeAjourforing; -} \ No newline at end of file diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/mapper/S610PersonMappingStrategy.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/mapper/S610PersonMappingStrategy.java index ac82501382a..d492dfd3d38 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/mapper/S610PersonMappingStrategy.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/mapper/S610PersonMappingStrategy.java @@ -4,9 +4,9 @@ import ma.glasnost.orika.MapperFacade; import ma.glasnost.orika.MapperFactory; import ma.glasnost.orika.MappingContext; -import no.nav.testnav.libs.data.tpsmessagingservice.v1.AdresseDTO; import no.nav.testnav.libs.data.kontoregister.v1.BankkontonrNorskDTO; import no.nav.testnav.libs.data.kontoregister.v1.BankkontonrUtlandDTO; +import no.nav.testnav.libs.data.tpsmessagingservice.v1.AdresseDTO; import no.nav.testnav.libs.data.tpsmessagingservice.v1.GateadresseDTO; import no.nav.testnav.libs.data.tpsmessagingservice.v1.MatrikkeladresseDTO; import no.nav.testnav.libs.data.tpsmessagingservice.v1.MidlertidigAdresseDTO; diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/mapper/SikkerhetstiltakMappingStrategy.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/mapper/SikkerhetstiltakMappingStrategy.java index 99de700856d..e7a3d4f8fdf 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/mapper/SikkerhetstiltakMappingStrategy.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/mapper/SikkerhetstiltakMappingStrategy.java @@ -3,15 +3,12 @@ import ma.glasnost.orika.CustomMapper; import ma.glasnost.orika.MapperFactory; import ma.glasnost.orika.MappingContext; -import no.nav.testnav.apps.tpsmessagingservice.dto.SikkerhetstiltakRequest; -import no.nav.testnav.apps.tpsmessagingservice.dto.TpsSystemInfo; import no.nav.testnav.libs.data.tpsmessagingservice.v1.SikkerhetTiltakDTO; import no.nav.tps.ctg.s610.domain.TsikkerhetsTiltakS610; import org.springframework.stereotype.Component; import java.time.LocalDate; -import static java.util.Objects.nonNull; import static org.apache.commons.lang3.StringUtils.isNotBlank; @Component @@ -20,43 +17,6 @@ public class SikkerhetstiltakMappingStrategy implements MappingStrategy { @Override public void register(MapperFactory factory) { - factory.classMap(SikkerhetTiltakDTO.class, SikkerhetstiltakRequest.class) - .customize(new CustomMapper<>() { - @Override - public void mapAtoB(SikkerhetTiltakDTO source, SikkerhetstiltakRequest target, MappingContext context) { - - target.setSfeAjourforing(SikkerhetstiltakRequest.SfeAjourforing.builder() - .systemInfo(TpsSystemInfo.getDefault()) - .opprettSikkerhetsTiltak(mapperFacade.map(source, SikkerhetstiltakRequest.Sikkerhetstiltak.class, context)) - .opphorSikkerhetsTiltak(mapperFacade.map(source, SikkerhetstiltakRequest.BrukerIdentifikasjon.class, context)) - .build()); - } - }) - .register(); - - factory.classMap(SikkerhetTiltakDTO.class, SikkerhetstiltakRequest.Sikkerhetstiltak.class) - .customize(new CustomMapper<>() { - @Override - public void mapAtoB(SikkerhetTiltakDTO source, SikkerhetstiltakRequest.Sikkerhetstiltak target, MappingContext context) { - - target.setTypeSikkerhetsTiltak(source.getTiltakstype()); - target.setBeskrSikkerhetsTiltak(source.getBeskrivelse()); - target.setFom(nonNull(source.getGyldigFraOgMed()) ? source.getGyldigFraOgMed().toLocalDate().toString() : null); - target.setTom(nonNull(source.getGyldigTilOgMed()) ? source.getGyldigTilOgMed().toLocalDate().toString() : null); - } - }) - .register(); - - factory.classMap(SikkerhetTiltakDTO.class, SikkerhetstiltakRequest.BrukerIdentifikasjon.class) - .customize(new CustomMapper<>() { - @Override - public void mapAtoB(SikkerhetTiltakDTO source, SikkerhetstiltakRequest.BrukerIdentifikasjon target, MappingContext context) { - - target.setOffentligIdent((String) context.getProperty("ident")); - } - }) - .register(); - factory.classMap(TsikkerhetsTiltakS610.class, SikkerhetTiltakDTO.class) .customize(new CustomMapper<>() { @Override diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/provider/v1/PersonController.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/provider/v1/PersonController.java index d1f3ee80b7c..12f77f44f1c 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/provider/v1/PersonController.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/provider/v1/PersonController.java @@ -6,12 +6,10 @@ import no.nav.testnav.apps.tpsmessagingservice.service.BankkontoUtlandService; import no.nav.testnav.apps.tpsmessagingservice.service.EgenansattService; import no.nav.testnav.apps.tpsmessagingservice.service.PersonService; -import no.nav.testnav.apps.tpsmessagingservice.service.SikkerhetstiltakService; import no.nav.testnav.apps.tpsmessagingservice.service.SpraakService; import no.nav.testnav.libs.data.kontoregister.v1.BankkontonrNorskDTO; import no.nav.testnav.libs.data.kontoregister.v1.BankkontonrUtlandDTO; import no.nav.testnav.libs.data.tpsmessagingservice.v1.PersonMiljoeDTO; -import no.nav.testnav.libs.data.tpsmessagingservice.v1.SikkerhetTiltakDTO; import no.nav.testnav.libs.data.tpsmessagingservice.v1.SpraakDTO; import no.nav.testnav.libs.data.tpsmessagingservice.v1.TpsMeldingResponseDTO; import org.springframework.format.annotation.DateTimeFormat; @@ -41,7 +39,6 @@ public class PersonController { private final SpraakService spraakService; private final BankkontoUtlandService bankkontoUtlandService; private final BankkontoNorskService bankkontoNorskService; - private final SikkerhetstiltakService sikkerhetstiltakService; private static List convert(Map tpsMeldingDTO) { @@ -116,20 +113,5 @@ public List opphoerBankkontonrUtland(@PathVariable String return convert(bankkontoUtlandService.opphoerBankkontonrUtland(ident, miljoer)); } - - @PostMapping("/{ident}/sikkerhetstiltak") - public List endreSikkerhetstiltak(@PathVariable String ident, - @RequestBody SikkerhetTiltakDTO sikkerhetstiltak, - @RequestParam(required = false) List miljoer) { - - return convert(sikkerhetstiltakService.endreSikkerhetstiltak(ident, sikkerhetstiltak, miljoer)); - } - - @DeleteMapping("/{ident}/sikkerhetstiltak") - public List opphoerSikkerhetstiltak(@PathVariable String ident, - @RequestParam(required = false) List miljoer) { - - return convert(sikkerhetstiltakService.opphoerSikkerhetstiltak(ident, miljoer)); - } } diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java index 5d652798330..8ae159e767e 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java @@ -19,6 +19,7 @@ import no.nav.tps.ctg.m201.domain.SRnavn; import no.nav.tps.ctg.m201.domain.TpsPersonData; import no.nav.tps.ctg.m201.domain.TpsServiceRutineType; +import org.slf4j.event.Level; import org.springframework.stereotype.Service; import javax.xml.namespace.QName; @@ -128,14 +129,12 @@ private Map readFromTps(List ident var miljoerResponse = servicerutineConsumer.sendMessage(xmlRequest, miljoer); - miljoerResponse.forEach((key, value) -> { - if (value.contains("00") || - value.contains("04")) { - log.info("Miljø: {} XML: {}", key, value); - } else { - log.error("Miljø: {} XML: {}", key, value); - } - }); + miljoerResponse.forEach((key, value) -> + log.atLevel(value.contains("00") || + value.contains("04") ? + Level.INFO : + Level.ERROR) + .log("Miljø: {} XML: {}", key, value)); return miljoerResponse.entrySet().parallelStream() .collect(Collectors.toMap(Map.Entry::getKey, diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/SikkerhetstiltakService.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/SikkerhetstiltakService.java deleted file mode 100644 index eaa2b56b79b..00000000000 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/SikkerhetstiltakService.java +++ /dev/null @@ -1,96 +0,0 @@ -package no.nav.testnav.apps.tpsmessagingservice.service; - -import lombok.extern.slf4j.Slf4j; -import ma.glasnost.orika.MapperFacade; -import ma.glasnost.orika.MappingContext; -import no.nav.testnav.apps.tpsmessagingservice.consumer.EndringsmeldingConsumer; -import no.nav.testnav.apps.tpsmessagingservice.consumer.TestmiljoerServiceConsumer; -import no.nav.testnav.apps.tpsmessagingservice.consumer.command.TpsMeldingCommand; -import no.nav.testnav.apps.tpsmessagingservice.dto.SikkerhetstiltakRequest; -import no.nav.testnav.apps.tpsmessagingservice.dto.SikkerhetstiltakResponse; -import no.nav.testnav.apps.tpsmessagingservice.dto.TpsMeldingResponse; -import no.nav.testnav.libs.data.tpsmessagingservice.v1.SikkerhetTiltakDTO; -import org.springframework.stereotype.Service; - -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.JAXBException; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.stream.Collectors; - -import static java.util.Objects.isNull; -import static no.nav.testnav.apps.tpsmessagingservice.utils.EndringsmeldingUtil.getErrorStatus; -import static no.nav.testnav.apps.tpsmessagingservice.utils.EndringsmeldingUtil.getResponseStatus; -import static no.nav.testnav.apps.tpsmessagingservice.utils.EndringsmeldingUtil.marshallToXML; -import static no.nav.testnav.apps.tpsmessagingservice.utils.EndringsmeldingUtil.unmarshallFromXml; - -@Slf4j -@Service -public class SikkerhetstiltakService { - - private final MapperFacade mapperFacade; - private final EndringsmeldingConsumer endringsmeldingConsumer; - private final TestmiljoerServiceConsumer testmiljoerServiceConsumer; - private final JAXBContext requestContext; - private final JAXBContext responseContext; - - public SikkerhetstiltakService(MapperFacade mapperFacade, EndringsmeldingConsumer endringsmeldingConsumer, - TestmiljoerServiceConsumer testmiljoerServiceConsumer) throws JAXBException { - - this.mapperFacade = mapperFacade; - this.endringsmeldingConsumer = endringsmeldingConsumer; - this.testmiljoerServiceConsumer = testmiljoerServiceConsumer; - - this.requestContext = JAXBContext.newInstance(SikkerhetstiltakRequest.class); - this.responseContext = JAXBContext.newInstance(SikkerhetstiltakResponse.class); - } - - private static SikkerhetstiltakRequest updateRequest(SikkerhetstiltakRequest request, boolean isOpprett) { - - if (isOpprett) { - request.getSfeAjourforing().setOpphorSikkerhetsTiltak(null); - - } else { - request.getSfeAjourforing().setOpprettSikkerhetsTiltak(null); - } - - return request; - } - - public Map endreSikkerhetstiltak(String ident, SikkerhetTiltakDTO sikkerhetstiltak, List miljoer) { - - return endreSikkerhetstiltak(true, ident, sikkerhetstiltak, miljoer); - } - - public Map opphoerSikkerhetstiltak(String ident, List miljoer) { - - return endreSikkerhetstiltak(false, ident, new SikkerhetTiltakDTO(), miljoer); - } - - private Map endreSikkerhetstiltak(boolean isEndre, String ident, SikkerhetTiltakDTO sikkerhetstiltak, List miljoer) { - - miljoer = isNull(miljoer) ? testmiljoerServiceConsumer.getMiljoer() : miljoer; - - var context = new MappingContext.Factory().getContext(); - context.setProperty("ident", ident); - - var request = mapperFacade.map(sikkerhetstiltak, SikkerhetstiltakRequest.class, context); - - var requestXml = marshallToXML(requestContext, updateRequest(request, isEndre)); - var miljoerResponse = endringsmeldingConsumer.sendMessage(requestXml, miljoer); - - return miljoerResponse.entrySet().stream() - .collect(Collectors.toMap(Entry::getKey, entry -> { - - try { - return getResponseStatus(TpsMeldingCommand.NO_RESPONSE.equals(entry.getValue()) ? null : - (SikkerhetstiltakResponse) unmarshallFromXml(responseContext, entry.getValue())); - - } catch (JAXBException e) { - log.error(e.getMessage(), e); - return getErrorStatus(e); - } - })); - } -} From 9a7597600a72d639c23ed14bf56338ae55be30ea Mon Sep 17 00:00:00 2001 From: kristenhaerum Date: Tue, 27 Feb 2024 22:18:32 +0100 Subject: [PATCH 02/10] Update XML request modification in IdentService Refactored the way XML requests are modified in IdentService.java. Added a condition to check for ZERO_COUNT presence before replacing EMPTY_FNR, preventing unnecessary operations when ZERO_COUNT is present in the XML request. This enhances efficiency and clarity of code. --- .../tpsmessagingservice/service/IdentService.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java index 8ae159e767e..5de39443a85 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java @@ -40,6 +40,7 @@ public class IdentService { private static final String SERVICE_NAME_OLD = "FS_03_FDLISTER_DISKNAVN_M"; private static final String SERVICE_NAME_NEW = "FS03-FDLISTER-DISKNAVN-M"; private static final String EMPTY_FNR = ""; + private static final String ZERO_COUNT = "0"; private static final int MAX_LIMIT = 80; private static final String BAD_REQUEST = "Antall identer kan ikke være større enn " + MAX_LIMIT; private static final String PROD = "p"; @@ -120,10 +121,14 @@ private Map readFromTps(List ident var request = prepareRequest(identer, isProd); var xmlRequest = marshallToXML(requestContext, request) - .replace(SERVICE_NAME_OLD, SERVICE_NAME_NEW) - .replace(EMPTY_FNR, "%s".formatted(identer.stream() - .map("%s"::formatted) - .collect(Collectors.joining("")))); + .replace(SERVICE_NAME_OLD, SERVICE_NAME_NEW); + + if (xmlRequest.contains(EMPTY_FNR) && !xmlRequest.contains(ZERO_COUNT)) { + xmlRequest = xmlRequest + .replace(EMPTY_FNR, "%s".formatted(identer.stream() + .map("%s"::formatted) + .collect(Collectors.joining("")))); + } log.info("M201 request: {}", xmlRequest); From 701ac0ac93cb40e096ecb58951d1efc3c3a9d747 Mon Sep 17 00:00:00 2001 From: Stian Gustavsson Date: Wed, 28 Feb 2024 09:26:33 +0100 Subject: [PATCH 03/10] Senker kravene til CPU for flere applikasjoner som kun utnytter <1% av denne under normal last (#3428) --- apps/adresse-service/config.yml | 2 +- apps/dolly-frontend/config.idporten.yml | 2 +- apps/dolly-frontend/config.test.yml | 2 +- apps/dolly-frontend/config.unstable.yml | 2 +- apps/dolly-frontend/config.yml | 2 +- apps/endringsmelding-frontend/config.yml | 2 +- apps/miljoer-service/config.yml | 2 +- apps/oppsummeringsdokument-service/config.yml | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/adresse-service/config.yml b/apps/adresse-service/config.yml index 813d46c00e5..018505cf6f3 100644 --- a/apps/adresse-service/config.yml +++ b/apps/adresse-service/config.yml @@ -34,7 +34,7 @@ spec: limits: memory: 2048Mi requests: - cpu: 300m + cpu: 200m memory: 1024Mi accessPolicy: inbound: diff --git a/apps/dolly-frontend/config.idporten.yml b/apps/dolly-frontend/config.idporten.yml index 6b6c38b408d..4abc5e838ac 100644 --- a/apps/dolly-frontend/config.idporten.yml +++ b/apps/dolly-frontend/config.idporten.yml @@ -79,7 +79,7 @@ spec: path: /internal/metrics resources: requests: - cpu: 1000m + cpu: 250m memory: 1024Mi limits: memory: 2048Mi diff --git a/apps/dolly-frontend/config.test.yml b/apps/dolly-frontend/config.test.yml index 335d1d2844e..a44fc9766ca 100644 --- a/apps/dolly-frontend/config.test.yml +++ b/apps/dolly-frontend/config.test.yml @@ -87,7 +87,7 @@ spec: path: /internal/metrics resources: requests: - cpu: 1000m + cpu: 500m memory: 1024Mi limits: memory: 2048Mi diff --git a/apps/dolly-frontend/config.unstable.yml b/apps/dolly-frontend/config.unstable.yml index 80a762bfe64..12ee6eb84e2 100644 --- a/apps/dolly-frontend/config.unstable.yml +++ b/apps/dolly-frontend/config.unstable.yml @@ -88,7 +88,7 @@ spec: path: /internal/metrics resources: requests: - cpu: 1000m + cpu: 100m memory: 1024Mi limits: memory: 2048Mi diff --git a/apps/dolly-frontend/config.yml b/apps/dolly-frontend/config.yml index 75e1dac5330..213876e1b2a 100644 --- a/apps/dolly-frontend/config.yml +++ b/apps/dolly-frontend/config.yml @@ -87,7 +87,7 @@ spec: path: /internal/metrics resources: requests: - cpu: 1000m + cpu: 500m memory: 1024Mi limits: memory: 2048Mi diff --git a/apps/endringsmelding-frontend/config.yml b/apps/endringsmelding-frontend/config.yml index 5cc19a8b63e..b478ef35fec 100644 --- a/apps/endringsmelding-frontend/config.yml +++ b/apps/endringsmelding-frontend/config.yml @@ -39,7 +39,7 @@ spec: limits: memory: 2048Mi requests: - cpu: 300m + cpu: 200m memory: 1024Mi image: "{{image}}" ingresses: diff --git a/apps/miljoer-service/config.yml b/apps/miljoer-service/config.yml index 45fe78c1332..ba198e01e33 100644 --- a/apps/miljoer-service/config.yml +++ b/apps/miljoer-service/config.yml @@ -69,7 +69,7 @@ spec: enabled: true resources: requests: - cpu: 200m + cpu: 100m memory: 1024Mi limits: memory: 2048Mi diff --git a/apps/oppsummeringsdokument-service/config.yml b/apps/oppsummeringsdokument-service/config.yml index c6075a00a28..75a3784ba72 100644 --- a/apps/oppsummeringsdokument-service/config.yml +++ b/apps/oppsummeringsdokument-service/config.yml @@ -64,7 +64,7 @@ spec: max: 1 resources: requests: - cpu: 500m + cpu: 300m memory: 1024Mi limits: memory: 2048Mi From 7e070c989f3b390586280908995d2746b120162f Mon Sep 17 00:00:00 2001 From: kristenhaerum Date: Wed, 28 Feb 2024 11:14:31 +0100 Subject: [PATCH 04/10] Simplify XML request preparation in IdentService Reworked the IdentService to simplify the preparation of XML requests, removing several static constants and the marshallToXML() method altogether. The new approach formats the XML string directly in the prepareRequest() method, streamlining the process and making the code easier to understand. --- .../service/IdentService.java | 69 +++++-------------- 1 file changed, 19 insertions(+), 50 deletions(-) diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java index 5de39443a85..a2998ff2a20 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java @@ -4,9 +4,6 @@ import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.dataformat.xml.XmlMapper; -import jakarta.xml.bind.JAXBContext; -import jakarta.xml.bind.JAXBElement; -import jakarta.xml.bind.JAXBException; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import no.nav.testnav.apps.tpsmessagingservice.consumer.ServicerutineConsumer; @@ -16,14 +13,9 @@ import no.nav.testnav.apps.tpsmessagingservice.exception.BadRequestException; import no.nav.testnav.apps.tpsmessagingservice.utils.EndringsmeldingUtil; import no.nav.testnav.libs.data.tpsmessagingservice.v1.TpsIdentStatusDTO; -import no.nav.tps.ctg.m201.domain.SRnavn; -import no.nav.tps.ctg.m201.domain.TpsPersonData; -import no.nav.tps.ctg.m201.domain.TpsServiceRutineType; import org.slf4j.event.Level; import org.springframework.stereotype.Service; -import javax.xml.namespace.QName; -import java.io.StringWriter; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -37,26 +29,20 @@ @Service public class IdentService { - private static final String SERVICE_NAME_OLD = "FS_03_FDLISTER_DISKNAVN_M"; - private static final String SERVICE_NAME_NEW = "FS03-FDLISTER-DISKNAVN-M"; - private static final String EMPTY_FNR = ""; - private static final String ZERO_COUNT = "0"; private static final int MAX_LIMIT = 80; private static final String BAD_REQUEST = "Antall identer kan ikke være større enn " + MAX_LIMIT; private static final String PROD = "p"; private static final String PROD_LIKE_ENV = "q2"; private final ServicerutineConsumer servicerutineConsumer; - private final JAXBContext requestContext; private final TestmiljoerServiceConsumer testmiljoerServiceConsumer; private final XmlMapper xmlMapper; public IdentService(ServicerutineConsumer servicerutineConsumer, - TestmiljoerServiceConsumer testmiljoerServiceConsumer) - throws JAXBException { + TestmiljoerServiceConsumer testmiljoerServiceConsumer) { + this.servicerutineConsumer = servicerutineConsumer; this.testmiljoerServiceConsumer = testmiljoerServiceConsumer; - this.requestContext = JAXBContext.newInstance(TpsPersonData.class); this.xmlMapper = XmlMapper .builder() .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) @@ -96,18 +82,6 @@ public List getIdenter(List identer, List mil .toList(); } - @SneakyThrows - public static String marshallToXML(JAXBContext requestContext, TpsPersonData endringsmelding) { - - var marshaller = requestContext.createMarshaller(); - - var writer = new StringWriter(); - JAXBElement element = new JAXBElement<>(new QName("", "tpsPersonData"), TpsPersonData.class, endringsmelding); - marshaller.marshal(element, writer); - - return writer.toString(); - } - private boolean exists(String ident, TpsServicerutineM201Response response) { return nonNull(response.getTpsSvar()) && @@ -119,16 +93,7 @@ private boolean exists(String ident, TpsServicerutineM201Response response) { private Map readFromTps(List identer, List miljoer, boolean isProd) { - var request = prepareRequest(identer, isProd); - var xmlRequest = marshallToXML(requestContext, request) - .replace(SERVICE_NAME_OLD, SERVICE_NAME_NEW); - - if (xmlRequest.contains(EMPTY_FNR) && !xmlRequest.contains(ZERO_COUNT)) { - xmlRequest = xmlRequest - .replace(EMPTY_FNR, "%s".formatted(identer.stream() - .map("%s"::formatted) - .collect(Collectors.joining("")))); - } + var xmlRequest = prepareRequest(identer, isProd); log.info("M201 request: {}", xmlRequest); @@ -162,17 +127,21 @@ private TpsServicerutineM201Response unmarshallFromXml(String endringsmeldingRes } } - private TpsPersonData prepareRequest(List identer, boolean isProd) { - - var request = new TpsPersonData(); - request.setTpsServiceRutine(new TpsServiceRutineType()); - request.getTpsServiceRutine().setServiceRutinenavn(SRnavn.FS_03_FDLISTER_DISKNAVN_M); - request.getTpsServiceRutine().setAksjonsKode("A"); - request.getTpsServiceRutine().setAksjonsKode2(isProd ? "2" : "0"); - request.getTpsServiceRutine().setAntallFnr(Integer.toString(identer.size())); - request.getTpsServiceRutine().setNFnr(new TpsServiceRutineType.NFnr()); - request.getTpsServiceRutine().getNFnr().getFnr().addAll(identer); - - return request; + private String prepareRequest(List identer, boolean isProd) { + + return "" + + "" + + "" + + "FS03-FDLISTER-DISKNAVN-M" + + "A" + + "%s" + + "%s" + + "%s" + + "" + + "".formatted(isProd ? "2" : "0", + Integer.toString(identer.size()), + identer.stream() + .map("%s"::formatted) + .collect(Collectors.joining())); } } From 40f382d3c5cdd49ae1071f14f177d0aa6fc0a95b Mon Sep 17 00:00:00 2001 From: kristenhaerum Date: Wed, 28 Feb 2024 11:25:18 +0100 Subject: [PATCH 05/10] Simplify XML string format in IdentService The formatting for an XML string in the IdentService class was simplified and made more readable. This change removed redundant plus operators and turned multiple lines into a single one, improving code comprehensibility. --- .../apps/tpsmessagingservice/service/IdentService.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java index a2998ff2a20..d250dfd471d 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java @@ -134,11 +134,8 @@ private String prepareRequest(List identer, boolean isProd) { "" + "FS03-FDLISTER-DISKNAVN-M" + "A" + - "%s" + - "%s" + - "%s" + - "" + - "".formatted(isProd ? "2" : "0", + "%s%s%s" + .formatted(isProd ? "2" : "0", Integer.toString(identer.size()), identer.stream() .map("%s"::formatted) From c96266f3539899fddabbb4656a8ef0bb091aa7d8 Mon Sep 17 00:00:00 2001 From: kristenhaerum Date: Wed, 28 Feb 2024 13:06:13 +0100 Subject: [PATCH 06/10] Reduce logging level in IdentService The logging level in IdentService has been decreased from INFO to TRACE, and the error detection logging has been removed. This modification aims to decrease the verbosity of the logs, making them easier to review. It also simplifies the code by returning the parsing of miljoerResponse to one line. --- .../apps/tpsmessagingservice/service/IdentService.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java index d250dfd471d..01ca63330be 100644 --- a/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java +++ b/apps/tps-messaging-service/src/main/java/no/nav/testnav/apps/tpsmessagingservice/service/IdentService.java @@ -13,7 +13,6 @@ import no.nav.testnav.apps.tpsmessagingservice.exception.BadRequestException; import no.nav.testnav.apps.tpsmessagingservice.utils.EndringsmeldingUtil; import no.nav.testnav.libs.data.tpsmessagingservice.v1.TpsIdentStatusDTO; -import org.slf4j.event.Level; import org.springframework.stereotype.Service; import java.util.HashMap; @@ -95,16 +94,11 @@ private Map readFromTps(List ident var xmlRequest = prepareRequest(identer, isProd); - log.info("M201 request: {}", xmlRequest); + log.trace("M201 request: {}", xmlRequest); var miljoerResponse = servicerutineConsumer.sendMessage(xmlRequest, miljoer); - miljoerResponse.forEach((key, value) -> - log.atLevel(value.contains("00") || - value.contains("04") ? - Level.INFO : - Level.ERROR) - .log("Miljø: {} XML: {}", key, value)); + miljoerResponse.forEach((key, value) -> log.trace("Miljø: {} XML: {}", key, value)); return miljoerResponse.entrySet().parallelStream() .collect(Collectors.toMap(Map.Entry::getKey, From e5827543f02345bb6a4079f73bc3f563c509ad0b Mon Sep 17 00:00:00 2001 From: stigus Date: Wed, 28 Feb 2024 13:24:06 +0100 Subject: [PATCH 07/10] =?UTF-8?q?Endrer=20arbeidsplassenCV=20url=20etter?= =?UTF-8?q?=20foresp=C3=B8rsel=20fra=20de?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arbeidsplassencv/command/ArbeidsplassenPutCVCommand.java | 2 +- .../src/main/js/src/utils/hooks/useFagsystemer.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/arbeidsplassencv/command/ArbeidsplassenPutCVCommand.java b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/arbeidsplassencv/command/ArbeidsplassenPutCVCommand.java index 3d91ee3f2ee..71f59e13862 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/arbeidsplassencv/command/ArbeidsplassenPutCVCommand.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/bestilling/arbeidsplassencv/command/ArbeidsplassenPutCVCommand.java @@ -20,7 +20,7 @@ @RequiredArgsConstructor public class ArbeidsplassenPutCVCommand implements Callable> { - private static final String ARBEIDSPLASSEN_CV_URL = "/rest/v2/cv"; + private static final String ARBEIDSPLASSEN_CV_URL = "/rest/v3/cv"; private static final String FNR = "fnr"; private final WebClient webClient; diff --git a/apps/dolly-frontend/src/main/js/src/utils/hooks/useFagsystemer.tsx b/apps/dolly-frontend/src/main/js/src/utils/hooks/useFagsystemer.tsx index 4d1d05906e1..8a01a5b3e37 100644 --- a/apps/dolly-frontend/src/main/js/src/utils/hooks/useFagsystemer.tsx +++ b/apps/dolly-frontend/src/main/js/src/utils/hooks/useFagsystemer.tsx @@ -66,7 +66,7 @@ const journalpostUrl = (transaksjonsid, miljoer) => { const histarkUrl = (transaksjonsid: string) => transaksjonsid ? `/testnav-histark-proxy/api/saksmapper/${transaksjonsid}` : null -const arbeidsforholdcvUrl = '/testnav-arbeidsplassencv-proxy/rest/v2/cv' +const arbeidsforholdcvUrl = '/testnav-arbeidsplassencv-proxy/rest/v3/cv' const arbeidsforholdcvHjemmelUrl = '/testnav-arbeidsplassencv-proxy/rest/hjemmel' export const usePoppData = (ident, harPoppBestilling) => { From 384650cb024da7a613d0b24fcabf7a9ed497bb63 Mon Sep 17 00:00:00 2001 From: stigus Date: Wed, 28 Feb 2024 13:44:52 +0100 Subject: [PATCH 08/10] =?UTF-8?q?Fors=C3=B8k=20p=C3=A5=20fix=20for=20altin?= =?UTF-8?q?n=20login=20som=20kaster=20feil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/src/components/ui/form/inputs/textInput/TextInput.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/textInput/TextInput.tsx b/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/textInput/TextInput.tsx index 7fcc7499e30..b3a554eae6a 100644 --- a/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/textInput/TextInput.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/ui/form/inputs/textInput/TextInput.tsx @@ -63,7 +63,7 @@ export const TextInput = React.forwardRef( id={name} className={css} placeholder={placeholder} - {...(name && !isDatepicker && register(name))} + {...(name && !isDatepicker && register?.(name))} {...props} /> {icon && } From c11580980b14ecc7c7e4a67e9ab38f3722af13f4 Mon Sep 17 00:00:00 2001 From: Stian Gustavsson Date: Tue, 5 Mar 2024 15:21:15 +0100 Subject: [PATCH 09/10] Bugfix/idporten issues (#3430) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Lagt til Azure application med dolly group claim for testnav-bruker-service * Lagt til formMethods i BrukernavnVelger * Fikset design på innlogging mot idporten --- apps/bruker-service/config.test.yml | 7 +++ apps/bruker-service/config.yml | 7 +++ .../js/src/pages/brukerPage/BrukerModel.tsx | 8 --- .../js/src/pages/brukerPage/BrukerPage.less | 8 +-- .../src/pages/brukerPage/BrukernavnVelger.tsx | 60 +++++++++++-------- 5 files changed, 54 insertions(+), 36 deletions(-) diff --git a/apps/bruker-service/config.test.yml b/apps/bruker-service/config.test.yml index 6d176a1af71..a9afa1ccde4 100644 --- a/apps/bruker-service/config.test.yml +++ b/apps/bruker-service/config.test.yml @@ -8,6 +8,13 @@ metadata: spec: image: "{{image}}" port: 8080 + azure: + application: + enabled: true + tenant: nav.no + claims: + groups: + - id: 9c7efec1-1599-4216-a67e-6fd53a6a951c tokenx: enabled: true accessPolicy: diff --git a/apps/bruker-service/config.yml b/apps/bruker-service/config.yml index 6e551c4b8e0..2c476c5550b 100644 --- a/apps/bruker-service/config.yml +++ b/apps/bruker-service/config.yml @@ -8,6 +8,13 @@ metadata: spec: image: "{{image}}" port: 8080 + azure: + application: + enabled: true + tenant: nav.no + claims: + groups: + - id: 9c7efec1-1599-4216-a67e-6fd53a6a951c tokenx: enabled: true accessPolicy: diff --git a/apps/dolly-frontend/src/main/js/src/pages/brukerPage/BrukerModel.tsx b/apps/dolly-frontend/src/main/js/src/pages/brukerPage/BrukerModel.tsx index 44cfad306ea..1ae63f789e5 100644 --- a/apps/dolly-frontend/src/main/js/src/pages/brukerPage/BrukerModel.tsx +++ b/apps/dolly-frontend/src/main/js/src/pages/brukerPage/BrukerModel.tsx @@ -1,5 +1,4 @@ import React, { useEffect, useState } from 'react' -import NavButton from '@/components/ui/button/NavButton/NavButton' import Loading from '@/components/ui/loading/Loading' import BrukernavnVelger from '@/pages/brukerPage/BrukernavnVelger' import OrganisasjonVelger from '@/pages/brukerPage/OrganisasjonVelger' @@ -72,13 +71,6 @@ export default () => { {organisasjon && !loading && ( )} - navigateToLogin()} - variant={'secondary'} - > - Tilbake til innlogging - ) diff --git a/apps/dolly-frontend/src/main/js/src/pages/brukerPage/BrukerPage.less b/apps/dolly-frontend/src/main/js/src/pages/brukerPage/BrukerPage.less index d49feea9746..a1c969e918d 100644 --- a/apps/dolly-frontend/src/main/js/src/pages/brukerPage/BrukerPage.less +++ b/apps/dolly-frontend/src/main/js/src/pages/brukerPage/BrukerPage.less @@ -33,14 +33,14 @@ width: 550px; } - .tilbake-button{ + .tilbake-button { border: none; margin: 10px 0 0 0; } - .videre-button{ - padding: 0 30px 0 30px; - margin-top: 23px; + .videre-button { + margin-top: 12px; + margin-right: 20px; } .loading-component { diff --git a/apps/dolly-frontend/src/main/js/src/pages/brukerPage/BrukernavnVelger.tsx b/apps/dolly-frontend/src/main/js/src/pages/brukerPage/BrukernavnVelger.tsx index 3d5a7979092..a307b586205 100644 --- a/apps/dolly-frontend/src/main/js/src/pages/brukerPage/BrukernavnVelger.tsx +++ b/apps/dolly-frontend/src/main/js/src/pages/brukerPage/BrukernavnVelger.tsx @@ -4,6 +4,8 @@ import NavButton from '@/components/ui/button/NavButton/NavButton' import { DollyTextInput } from '@/components/ui/form/inputs/textInput/TextInput' import { Bruker, Organisasjon } from '@/pages/brukerPage/types' import { BrukerApi } from '@/service/Api' +import { FormProvider, useForm } from 'react-hook-form' +import { navigateToLogin } from '@/components/utlogging/navigateToLogin' type BrukernavnVelgerProps = { organisasjon: Organisasjon @@ -12,7 +14,7 @@ type BrukernavnVelgerProps = { const Selector = styled.div` display: flexbox; - text-align: left; + text-align: -webkit-center; justify-content: center; margin-bottom: 20px; ` @@ -25,6 +27,7 @@ const feilmeldinger = { } export default ({ organisasjon, addToSession }: BrukernavnVelgerProps) => { + const formMethods = useForm() const [brukernavn, setBrukernavn] = useState('') const [loading, setLoading] = useState(false) const [error, setError] = useState(null) @@ -67,30 +70,39 @@ export default ({ organisasjon, addToSession }: BrukernavnVelgerProps) => { return ( -

- Lag ditt eget brukernavn som brukes når du representerer {organisasjon.navn}. Neste - gang du logger inn for denne organisasjonen skjer det automatisk med dette brukernavnet. -

+ +

+ Lag ditt eget brukernavn som brukes når du representerer {organisasjon.navn}. Neste + gang du logger inn for denne organisasjonen skjer det automatisk med dette brukernavnet. +

- - onChange(e.target.value)} - isDisabled={loading} - /> - onSubmit()} - variant={'primary'} - className="videre-button" - disabled={error} - > - Gå videre til Dolly - - + + onChange(e.target.value)} + isDisabled={loading} + /> + onSubmit()} + variant={'primary'} + className="videre-button" + disabled={error} + > + Gå videre til Dolly + + navigateToLogin()} + variant={'secondary'} + > + Tilbake til innlogging + + +
) } From a8bd28a2c9232f8c8c3f4963d3e69c9b07725610 Mon Sep 17 00:00:00 2001 From: Stian Gustavsson Date: Tue, 5 Mar 2024 15:22:05 +0100 Subject: [PATCH 10/10] =?UTF-8?q?H=C3=A5ndterer=20feilmelding=20som=20dukk?= =?UTF-8?q?er=20opp=20dersom=20det=20har=20v=C3=A6rt=20deploy=20av=20front?= =?UTF-8?q?end=20(#3427)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix for "Failed to fetch dynamically imported module" * Lagt til cypress komponentTest for AppError i forbindelse med 'Failed to fetch dynamically imported module' * Bedre håndtering av feil som dukker opp i frontend applikasjon hvis det har vært en deploy * Skrevet noen komponent-tester for dette i Cypress * Mindre oppdateringer --- .../web/DollyFrontendApplicationStarter.java | 2 +- .../src/main/js/package-lock.json | 154 +++++++++--------- .../src/main/js/src/RootComponent.tsx | 24 ++- .../components/ui/appError/AppError.cy.tsx | 11 ++ .../src/components/ui/appError/AppError.tsx | 103 +++++++----- .../src/main/js/src/pages/minSide/MinSide.tsx | 7 +- 6 files changed, 176 insertions(+), 125 deletions(-) diff --git a/apps/dolly-frontend/src/main/java/no/nav/dolly/web/DollyFrontendApplicationStarter.java b/apps/dolly-frontend/src/main/java/no/nav/dolly/web/DollyFrontendApplicationStarter.java index 57fcb74d094..75078944514 100644 --- a/apps/dolly-frontend/src/main/java/no/nav/dolly/web/DollyFrontendApplicationStarter.java +++ b/apps/dolly-frontend/src/main/java/no/nav/dolly/web/DollyFrontendApplicationStarter.java @@ -129,4 +129,4 @@ private Function> createRoute(String segment, St .filters(filter, addUserJwtHeaderFilter()) ).uri(host); } -} +} \ No newline at end of file diff --git a/apps/dolly-frontend/src/main/js/package-lock.json b/apps/dolly-frontend/src/main/js/package-lock.json index 3951c66f442..7f7736503ee 100644 --- a/apps/dolly-frontend/src/main/js/package-lock.json +++ b/apps/dolly-frontend/src/main/js/package-lock.json @@ -1239,9 +1239,9 @@ } }, "node_modules/@eslint/js": { - "version": "8.56.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.56.0.tgz", - "integrity": "sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", + "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } @@ -1506,9 +1506,9 @@ } }, "node_modules/@jridgewell/gen-mapping": { - "version": "0.3.3", - "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.3.tgz", - "integrity": "sha512-HLhSWOLRi875zjjMG/r+Nv0oCW8umGb0BgEhyX3dDX3egwZtB8PqLnjz3yedt8R5StBrzcg4aBpnh8UA9D1BoQ==", + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.4.tgz", + "integrity": "sha512-Oud2QPM5dHviZNn4y/WhhYKSXksv+1xLEIsNrAbGcFzUN3ubqWRFT5gwPchNc5NuzILOU4tPBDTZ4VwhL8Y7cw==", "dependencies": { "@jridgewell/set-array": "^1.0.1", "@jridgewell/sourcemap-codec": "^1.4.10", @@ -1550,9 +1550,9 @@ "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==" }, "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.22", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.22.tgz", - "integrity": "sha512-Wf963MzWtA2sjrNt+g18IAln9lKnlRp+K2eH4jjIoF1wYeq3aMREpG09xhlhdzS0EjwU7qmUJYangWa+151vZw==", + "version": "0.3.23", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.23.tgz", + "integrity": "sha512-9/4foRoUKp8s96tSkh8DlAAc5A0Ty8vLXld+l9gjKKY6ckwI8G15f0hskGmuLZu78ZlGa1vtsfOa+lnB4vG6Jg==", "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" @@ -2861,9 +2861,9 @@ "integrity": "sha512-ga8y9v9uyeiLdpKddhxYQkxNDrfvuPrlFb0N1qnZZByvcElJaXthF1UhvCh9TLWJBEHeNtdnbysW7Y6Uq8CVng==" }, "node_modules/@types/react": { - "version": "18.2.58", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.58.tgz", - "integrity": "sha512-TaGvMNhxvG2Q0K0aYxiKfNDS5m5ZsoIBBbtfUorxdH4NGSXIlYvZxLJI+9Dd3KjeB3780bciLyAb7ylO8pLhPw==", + "version": "18.2.59", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.2.59.tgz", + "integrity": "sha512-DE+F6BYEC8VtajY85Qr7mmhTd/79rJKIHCg99MU9SWPB4xvLb6D1za2vYflgZfmPqQVEr6UqJTnLXEwzpVPuOg==", "dependencies": { "@types/prop-types": "*", "@types/scheduler": "*", @@ -3000,9 +3000,9 @@ "integrity": "sha512-WZLiwShhwLRmeV6zH+GkbOFT6Z6VklCItrDioxUnv+u4Ll+8vKeFySoFyK/0ctcRpOmwAicELfmys1sDc/Rw+A==" }, "node_modules/@types/semver": { - "version": "7.5.7", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.7.tgz", - "integrity": "sha512-/wdoPq1QqkSj9/QOeKkFquEuPzQbHTWAMPH/PaUMB+JuR31lXhlWXRZ52IpfDYVlDOUBvX09uBrPwxGT1hjNBg==", + "version": "7.5.8", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.8.tgz", + "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==", "dev": true }, "node_modules/@types/shimmer": { @@ -3049,16 +3049,16 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.0.2.tgz", - "integrity": "sha512-/XtVZJtbaphtdrWjr+CJclaCVGPtOdBpFEnvtNf/jRV0IiEemRrL0qABex/nEt8isYcnFacm3nPHYQwL+Wb7qg==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-7.1.0.tgz", + "integrity": "sha512-j6vT/kCulhG5wBmGtstKeiVr1rdXE4nk+DT1k6trYkwlrvW9eOF5ZbgKnd/YR6PcM4uTEXa0h6Fcvf6X7Dxl0w==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "7.0.2", - "@typescript-eslint/type-utils": "7.0.2", - "@typescript-eslint/utils": "7.0.2", - "@typescript-eslint/visitor-keys": "7.0.2", + "@typescript-eslint/scope-manager": "7.1.0", + "@typescript-eslint/type-utils": "7.1.0", + "@typescript-eslint/utils": "7.1.0", + "@typescript-eslint/visitor-keys": "7.1.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -3117,15 +3117,15 @@ "dev": true }, "node_modules/@typescript-eslint/parser": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.0.2.tgz", - "integrity": "sha512-GdwfDglCxSmU+QTS9vhz2Sop46ebNCXpPPvsByK7hu0rFGRHL+AusKQJ7SoN+LbLh6APFpQwHKmDSwN35Z700Q==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-7.1.0.tgz", + "integrity": "sha512-V1EknKUubZ1gWFjiOZhDSNToOjs63/9O0puCgGS8aDOgpZY326fzFu15QAUjwaXzRZjf/qdsdBrckYdv9YxB8w==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "7.0.2", - "@typescript-eslint/types": "7.0.2", - "@typescript-eslint/typescript-estree": "7.0.2", - "@typescript-eslint/visitor-keys": "7.0.2", + "@typescript-eslint/scope-manager": "7.1.0", + "@typescript-eslint/types": "7.1.0", + "@typescript-eslint/typescript-estree": "7.1.0", + "@typescript-eslint/visitor-keys": "7.1.0", "debug": "^4.3.4" }, "engines": { @@ -3145,13 +3145,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.0.2.tgz", - "integrity": "sha512-l6sa2jF3h+qgN2qUMjVR3uCNGjWw4ahGfzIYsCtFrQJCjhbrDPdiihYT8FnnqFwsWX+20hK592yX9I2rxKTP4g==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-7.1.0.tgz", + "integrity": "sha512-6TmN4OJiohHfoOdGZ3huuLhpiUgOGTpgXNUPJgeZOZR3DnIpdSgtt83RS35OYNNXxM4TScVlpVKC9jyQSETR1A==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.0.2", - "@typescript-eslint/visitor-keys": "7.0.2" + "@typescript-eslint/types": "7.1.0", + "@typescript-eslint/visitor-keys": "7.1.0" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -3162,13 +3162,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.0.2.tgz", - "integrity": "sha512-IKKDcFsKAYlk8Rs4wiFfEwJTQlHcdn8CLwLaxwd6zb8HNiMcQIFX9sWax2k4Cjj7l7mGS5N1zl7RCHOVwHq2VQ==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-7.1.0.tgz", + "integrity": "sha512-UZIhv8G+5b5skkcuhgvxYWHjk7FW7/JP5lPASMEUoliAPwIH/rxoUSQPia2cuOj9AmDZmwUl1usKm85t5VUMew==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "7.0.2", - "@typescript-eslint/utils": "7.0.2", + "@typescript-eslint/typescript-estree": "7.1.0", + "@typescript-eslint/utils": "7.1.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -3189,9 +3189,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.0.2.tgz", - "integrity": "sha512-ZzcCQHj4JaXFjdOql6adYV4B/oFOFjPOC9XYwCaZFRvqN8Llfvv4gSxrkQkd2u4Ci62i2c6W6gkDwQJDaRc4nA==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-7.1.0.tgz", + "integrity": "sha512-qTWjWieJ1tRJkxgZYXx6WUYtWlBc48YRxgY2JN1aGeVpkhmnopq+SUC8UEVGNXIvWH7XyuTjwALfG6bFEgCkQA==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -3202,13 +3202,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.0.2.tgz", - "integrity": "sha512-3AMc8khTcELFWcKcPc0xiLviEvvfzATpdPj/DXuOGIdQIIFybf4DMT1vKRbuAEOFMwhWt7NFLXRkbjsvKZQyvw==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-7.1.0.tgz", + "integrity": "sha512-k7MyrbD6E463CBbSpcOnwa8oXRdHzH1WiVzOipK3L5KSML92ZKgUBrTlehdi7PEIMT8k0bQixHUGXggPAlKnOQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.0.2", - "@typescript-eslint/visitor-keys": "7.0.2", + "@typescript-eslint/types": "7.1.0", + "@typescript-eslint/visitor-keys": "7.1.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -3263,17 +3263,17 @@ "dev": true }, "node_modules/@typescript-eslint/utils": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.0.2.tgz", - "integrity": "sha512-PZPIONBIB/X684bhT1XlrkjNZJIEevwkKDsdwfiu1WeqBxYEEdIgVDgm8/bbKHVu+6YOpeRqcfImTdImx/4Bsw==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-7.1.0.tgz", + "integrity": "sha512-WUFba6PZC5OCGEmbweGpnNJytJiLG7ZvDBJJoUcX4qZYf1mGZ97mO2Mps6O2efxJcJdRNpqweCistDbZMwIVHw==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "7.0.2", - "@typescript-eslint/types": "7.0.2", - "@typescript-eslint/typescript-estree": "7.0.2", + "@typescript-eslint/scope-manager": "7.1.0", + "@typescript-eslint/types": "7.1.0", + "@typescript-eslint/typescript-estree": "7.1.0", "semver": "^7.5.4" }, "engines": { @@ -3321,12 +3321,12 @@ "dev": true }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.0.2.tgz", - "integrity": "sha512-8Y+YiBmqPighbm5xA2k4wKTxRzx9EkBu7Rlw+WHqMvRJ3RPz/BMBO9b2ru0LUNmXg120PHUXD5+SWFy2R8DqlQ==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-7.1.0.tgz", + "integrity": "sha512-FhUqNWluiGNzlvnDZiXad4mZRhtghdoKW6e98GoEOYSu5cND+E39rG5KwJMUzeENwm1ztYBRqof8wMLP+wNPIA==", "dev": true, "dependencies": { - "@typescript-eslint/types": "7.0.2", + "@typescript-eslint/types": "7.1.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -4074,9 +4074,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001589", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001589.tgz", - "integrity": "sha512-vNQWS6kI+q6sBlHbh71IIeC+sRwK2N3EDySc/updIGhIee2x5z00J4c1242/5/d6EpEMdOnk/m+6tuk4/tcsqg==", + "version": "1.0.30001591", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001591.tgz", + "integrity": "sha512-PCzRMei/vXjJyL5mJtzNiUCKP59dm8Apqc3PH8gJkMnMXZGox93RbE76jHsmLwmIo6/3nsYIpJtx0O7u5PqFuQ==", "funding": [ { "type": "opencollective", @@ -5073,9 +5073,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.4.680", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.680.tgz", - "integrity": "sha512-4nToZ5jlPO14W82NkF32wyjhYqQByVaDmLy4J2/tYcAbJfgO2TKJC780Az1V13gzq4l73CJ0yuyalpXvxXXD9A==" + "version": "1.4.682", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.682.tgz", + "integrity": "sha512-oCglfs8yYKs9RQjJFOHonSnhikPK3y+0SvSYc/YpYJV//6rqc0/hbwd0c7vgK4vrl6y2gJAwjkhkSGWK+z4KRA==" }, "node_modules/emoji-regex": { "version": "9.2.2", @@ -5340,15 +5340,15 @@ } }, "node_modules/eslint": { - "version": "8.56.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.56.0.tgz", - "integrity": "sha512-Go19xM6T9puCOWntie1/P997aXxFsOi37JIHRWI514Hc6ZnaHGKY9xFhrU65RT6CcBEzZoGG1e6Nq+DT04ZtZQ==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", + "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", "@eslint/eslintrc": "^2.1.4", - "@eslint/js": "8.56.0", - "@humanwhocodes/config-array": "^0.11.13", + "@eslint/js": "8.57.0", + "@humanwhocodes/config-array": "^0.11.14", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", "@ungap/structured-clone": "^1.2.0", @@ -5448,9 +5448,9 @@ } }, "node_modules/eslint-module-utils": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.0.tgz", - "integrity": "sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw==", + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.8.1.tgz", + "integrity": "sha512-rXDXR3h7cs7dy9RNpUlQf80nX31XWJEyGq1tRMo+6GsO5VmTe4UTwtmonAD4ZkAsrfMVDA2wlGJ3790Ys+D49Q==", "dependencies": { "debug": "^3.2.7" }, @@ -11052,9 +11052,9 @@ "optional": true }, "node_modules/terser": { - "version": "5.27.2", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.27.2.tgz", - "integrity": "sha512-sHXmLSkImesJ4p5apTeT63DsV4Obe1s37qT8qvwHRmVxKTBH7Rv9Wr26VcAMmLbmk9UliiwK8z+657NyJHHy/w==", + "version": "5.28.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.28.1.tgz", + "integrity": "sha512-wM+bZp54v/E9eRRGXb5ZFDvinrJIOaTapx3WUokyVGZu5ucVCK55zEgGd5Dl2fSr3jUo5sDiERErUWLY6QPFyA==", "dev": true, "dependencies": { "@jridgewell/source-map": "^0.3.3", @@ -11126,9 +11126,9 @@ "integrity": "sha512-Eet/eeMhkO6TX8mnUteS9zgPbUMQa4I6Kkp5ORiBD5476/m+PIRiumP5tmh5ioJpH7k51Kehawy2UDfsnxxY8Q==" }, "node_modules/tiny-invariant": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.2.tgz", - "integrity": "sha512-oLXoWt7bk7SI3REp16Hesm0kTBTErhk+FWTvuujYMlIbX42bb3yLN98T3OyzFNkZ3WAjVYDL4sWykCR6kD2mqQ==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz", + "integrity": "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg==", "dev": true }, "node_modules/tiny-warning": { diff --git a/apps/dolly-frontend/src/main/js/src/RootComponent.tsx b/apps/dolly-frontend/src/main/js/src/RootComponent.tsx index 37f26512f7e..5e0d28ca773 100644 --- a/apps/dolly-frontend/src/main/js/src/RootComponent.tsx +++ b/apps/dolly-frontend/src/main/js/src/RootComponent.tsx @@ -23,6 +23,9 @@ import { ReactIntegration, ReactRouterVersion, } from '@grafana/faro-react' +import { useRouteError } from 'react-router' +import { AppError } from '@/components/ui/appError/AppError' +import { navigateToLogin } from '@/components/utlogging/navigateToLogin' initializeFaro({ paused: window.location.hostname.includes('localhost'), @@ -46,6 +49,23 @@ initializeFaro({ ], }) +const ErrorView = () => { + console.error('Applikasjonen har støtt på en feil') + const error: any = useRouteError() + console.error(error) + + const errors = [ + 'Failed to fetch dynamically imported module', + 'Unable to preload CSS', + "Cannot destructure property of 'register'", + ] + + if (errors.some((e) => error?.message?.includes(e))) { + navigateToLogin(error?.message) + } + return +} + export const RootComponent = () => ( @@ -57,9 +77,9 @@ export const RootComponent = () => ( }} > - } /> } /> - } /> + } path="/bruker" element={} /> + } path="*" element={} /> diff --git a/apps/dolly-frontend/src/main/js/src/components/ui/appError/AppError.cy.tsx b/apps/dolly-frontend/src/main/js/src/components/ui/appError/AppError.cy.tsx index d0d7ff443dd..9de694487c4 100644 --- a/apps/dolly-frontend/src/main/js/src/components/ui/appError/AppError.cy.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/ui/appError/AppError.cy.tsx @@ -8,3 +8,14 @@ describe('', () => { ) }) }) + +describe('', () => { + it('renders', () => { + cy.mount( + , + ) + }) +}) diff --git a/apps/dolly-frontend/src/main/js/src/components/ui/appError/AppError.tsx b/apps/dolly-frontend/src/main/js/src/components/ui/appError/AppError.tsx index 13bf5403d3d..de98befe24f 100644 --- a/apps/dolly-frontend/src/main/js/src/components/ui/appError/AppError.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/ui/appError/AppError.tsx @@ -3,54 +3,71 @@ import Icon from '@/components/ui/icon/Icon' import './appError.less' import 'rc-tooltip/assets/bootstrap.css' import { DollyCopyButton } from '@/components/ui/button/CopyButton/DollyCopyButton' -import { CSSProperties } from 'react' +import { CSSProperties, useEffect } from 'react' +import { useNavigate } from 'react-router-dom' type Props = { style?: CSSProperties | undefined error: Error | string stackTrace: string } -export const AppError = ({ error, stackTrace, style }: Props) => ( -
-

- - {'Ooops, dette var ikke planlagt...'} -

-

Feilmelding

-
-			{error ? error.toString() : 'Det har skjedd en feil og vi er ikke helt sikre på hvorfor. '}
-		
- {error && ( -
- +export const AppError = ({ error, stackTrace, style }: Props) => { + const navigate = useNavigate() + const errorsRequiringReload = [ + 'Failed to fetch dynamically imported module', + 'Unable to preload CSS', + ] -
- Detaljert Feilbeskrivelse -

-
- {error && error.toString()} -
- {stackTrace} -

-
-
- )} + useEffect(() => { + if (errorsRequiringReload.some((e) => error?.toString()?.includes(e))) { + navigate(0) + } + }, []) -

- Noe gikk galt under visning av elementet.
- Dersom refresh av siden ikke fungerer, forsøk å trykke{' '} - - her - - , clear cookies eller kontakt Team Dolly på slack{' '} - - #dolly - {' '} - med detaljene over (bruk kopier-ikonet). -

-
-) + return ( +
+

+ + {'Ooops, dette var ikke planlagt...'} +

+

Feilmelding

+
+				{error ? error.toString() : 'Det har skjedd en feil og vi er ikke helt sikre på hvorfor. '}
+			
+ {error && ( +
+ + +
+ Detaljert Feilbeskrivelse +

+
+ {error && error.toString()} +
+ {stackTrace} +

+
+
+ )} + +

+ Noe gikk galt under visning av elementet.
+ Dersom refresh av siden ikke fungerer, forsøk å trykke{' '} + + + her + + + , clear cookies eller kontakt Team Dolly på slack{' '} + + #dolly + {' '} + med detaljene over (bruk kopier-ikonet). +

+
+ ) +} diff --git a/apps/dolly-frontend/src/main/js/src/pages/minSide/MinSide.tsx b/apps/dolly-frontend/src/main/js/src/pages/minSide/MinSide.tsx index b61b7fa174d..4814b34f261 100644 --- a/apps/dolly-frontend/src/main/js/src/pages/minSide/MinSide.tsx +++ b/apps/dolly-frontend/src/main/js/src/pages/minSide/MinSide.tsx @@ -3,6 +3,7 @@ import Profil from './Profil' import './MinSide.less' import { useBrukerProfil, useCurrentBruker } from '@/utils/hooks/useBruker' +import { ErrorBoundary } from '@/components/ui/appError/ErrorBoundary' export default () => { const { brukerProfil } = useBrukerProfil() @@ -11,8 +12,10 @@ export default () => { return ( <>

Min side

- - {brukerProfil && } + + + {brukerProfil && } + ) }