From c242c18cc139479ea5d239e6609a4936e959ae46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20Hafli=C3=B0ason?= Date: Fri, 14 Jun 2024 13:03:36 +0000 Subject: [PATCH 01/21] Fix locale updates. Add cleanstring --- .../Notifications/NotificationButton.tsx | 9 +++++++-- .../api/domains/notifications/src/utils/helpers.ts | 14 ++++++++++---- .../screens/Notifications/Notifications.graphql | 11 +++++++---- .../src/screens/Notifications/Notifications.tsx | 10 ++++++++-- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/apps/service-portal/src/components/Notifications/NotificationButton.tsx b/apps/service-portal/src/components/Notifications/NotificationButton.tsx index 95bd7a20d4f1..82583f47e539 100644 --- a/apps/service-portal/src/components/Notifications/NotificationButton.tsx +++ b/apps/service-portal/src/components/Notifications/NotificationButton.tsx @@ -24,21 +24,26 @@ const NotificationButton = ({ showMenu = false, disabled, }: Props) => { - const { formatMessage } = useLocale() + const { formatMessage, lang } = useLocale() const [hasMarkedLocally, setHasMarkedLocally] = useState(false) const [markAllAsSeen] = useMarkAllNotificationsAsSeenMutation() const { width } = useWindowSize() const isMobile = width < theme.breakpoints.md const ref = useRef(null) - const { data } = useGetUserNotificationsOverviewQuery({ + const { data, refetch } = useGetUserNotificationsOverviewQuery({ variables: { input: { limit: 5, }, + locale: lang, }, }) + useEffect(() => { + refetch() + }, [lang, refetch]) + const showBadge = !!data?.userNotificationsOverview?.unseenCount && !hasMarkedLocally diff --git a/libs/api/domains/notifications/src/utils/helpers.ts b/libs/api/domains/notifications/src/utils/helpers.ts index 2e45833e1afe..918804210289 100644 --- a/libs/api/domains/notifications/src/utils/helpers.ts +++ b/libs/api/domains/notifications/src/utils/helpers.ts @@ -1,6 +1,10 @@ import { RenderedNotificationDto } from '@island.is/clients/user-notification' import { Notification } from '../lib/notifications.model' +const cleanString = (str: string) => { + return str.replace(/\s+/g, ' ').trim() +} + export const notificationMapper = ( notification: RenderedNotificationDto, ): Notification => ({ @@ -20,10 +24,12 @@ export const notificationMapper = ( nationalId: undefined, }, message: { - title: notification.title, - body: notification.body, - dataCopy: notification.dataCopy, - displayBody: notification.dataCopy ?? notification.body, + title: cleanString(notification.title ?? ''), + body: cleanString(notification.body ?? ''), + dataCopy: notification.dataCopy + ? cleanString(notification.dataCopy) + : undefined, + displayBody: cleanString(notification.dataCopy ?? notification.body), link: { url: notification.clickActionUrl, }, diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql index b370a1d97a3d..8aec19cda7e5 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql @@ -32,8 +32,8 @@ fragment NotificationDataFields on Notification { } } -query GetUserNotifications($input: NotificationsInput!) { - userNotifications(input: $input) { +query GetUserNotifications($input: NotificationsInput!, $locale: String!) { + userNotifications(input: $input, locale: $locale) { data { ...NotificationDataFields recipient { @@ -52,8 +52,11 @@ query GetUserNotifications($input: NotificationsInput!) { } } -query GetUserNotificationsOverview($input: NotificationsInput!) { - userNotificationsOverview: userNotifications(input: $input) { +query GetUserNotificationsOverview( + $input: NotificationsInput! + $locale: String! +) { + userNotificationsOverview: userNotifications(input: $input, locale: $locale) { data { ...NotificationDataFields } diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx index 294bec5bc6cf..96dea2401617 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { useEffect, useState } from 'react' import { Box, Button, @@ -32,7 +32,7 @@ const DEFAULT_PAGE_SIZE = 5 const UserNotifications = () => { useNamespaces('sp.information-notifications') - const { formatMessage } = useLocale() + const { formatMessage, lang } = useLocale() const [loadingMore, setLoadingMore] = useState(false) const [postMarkAsRead] = useMarkUserNotificationAsReadMutation() @@ -54,9 +54,14 @@ const UserNotifications = () => { before: '', after: '', }, + locale: lang, }, }) + useEffect(() => { + refetch() + }, [refetch, lang]) + const loadMore = (cursor: string) => { if (loadingMore) return setLoadingMore(true) @@ -67,6 +72,7 @@ const UserNotifications = () => { before: '', after: cursor, }, + locale: lang, }, updateQuery: (prevResult, { fetchMoreResult }) => { if ( From 5a25e302fc22c9841c9b2a73a2e6987b7933bff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20Hafli=C3=B0ason?= Date: Fri, 14 Jun 2024 13:16:33 +0000 Subject: [PATCH 02/21] update string clean --- libs/api/domains/notifications/src/utils/helpers.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libs/api/domains/notifications/src/utils/helpers.ts b/libs/api/domains/notifications/src/utils/helpers.ts index 918804210289..f8c68345fd92 100644 --- a/libs/api/domains/notifications/src/utils/helpers.ts +++ b/libs/api/domains/notifications/src/utils/helpers.ts @@ -1,7 +1,10 @@ import { RenderedNotificationDto } from '@island.is/clients/user-notification' import { Notification } from '../lib/notifications.model' -const cleanString = (str: string) => { +const cleanString = (str?: string) => { + if (!str) { + return '' + } return str.replace(/\s+/g, ' ').trim() } @@ -24,8 +27,8 @@ export const notificationMapper = ( nationalId: undefined, }, message: { - title: cleanString(notification.title ?? ''), - body: cleanString(notification.body ?? ''), + title: cleanString(notification.title), + body: cleanString(notification.body), dataCopy: notification.dataCopy ? cleanString(notification.dataCopy) : undefined, From 6f1509f83e78fd9f33a626b8f669f5239a2ef608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20Hafli=C3=B0ason?= Date: Fri, 14 Jun 2024 13:34:17 +0000 Subject: [PATCH 03/21] Update packagejson --- libs/service-portal/information/project.json | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/service-portal/information/project.json b/libs/service-portal/information/project.json index c7d097c4d436..967f733f0c68 100644 --- a/libs/service-portal/information/project.json +++ b/libs/service-portal/information/project.json @@ -29,6 +29,7 @@ "codegen/frontend-client": { "executor": "nx:run-commands", "options": { + "parallel": false, "output": "libs/service-portal/information/src/**/*.generated.ts", "command": "graphql-codegen --config libs/service-portal/information/codegen.yml" } From b72757734da3b8047772dcfcf690b1418880cc2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20Hafli=C3=B0ason?= Date: Fri, 14 Jun 2024 14:37:27 +0000 Subject: [PATCH 04/21] Update query --- .../information/src/screens/Notifications/Notifications.graphql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql index 8aec19cda7e5..63fe15c7f240 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql @@ -32,7 +32,7 @@ fragment NotificationDataFields on Notification { } } -query GetUserNotifications($input: NotificationsInput!, $locale: String!) { +query GetUserNotifications($input: NotificationsInput!, $locale: String) { userNotifications(input: $input, locale: $locale) { data { ...NotificationDataFields From ae5d56a8d400dde018a01c5c7df1ab12d94b8773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20Hafli=C3=B0ason?= Date: Fri, 14 Jun 2024 14:43:33 +0000 Subject: [PATCH 05/21] Update query --- .../src/components/Notifications/NotificationButton.tsx | 1 - .../information/src/screens/Notifications/Notifications.graphql | 2 +- .../information/src/screens/Notifications/Notifications.tsx | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/service-portal/src/components/Notifications/NotificationButton.tsx b/apps/service-portal/src/components/Notifications/NotificationButton.tsx index 82583f47e539..9461de07f11b 100644 --- a/apps/service-portal/src/components/Notifications/NotificationButton.tsx +++ b/apps/service-portal/src/components/Notifications/NotificationButton.tsx @@ -36,7 +36,6 @@ const NotificationButton = ({ input: { limit: 5, }, - locale: lang, }, }) diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql index 63fe15c7f240..c92e90e288f3 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql @@ -54,7 +54,7 @@ query GetUserNotifications($input: NotificationsInput!, $locale: String) { query GetUserNotificationsOverview( $input: NotificationsInput! - $locale: String! + $locale: String ) { userNotificationsOverview: userNotifications(input: $input, locale: $locale) { data { diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx index 96dea2401617..0b0b809f0d0d 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx @@ -54,7 +54,6 @@ const UserNotifications = () => { before: '', after: '', }, - locale: lang, }, }) @@ -72,7 +71,6 @@ const UserNotifications = () => { before: '', after: cursor, }, - locale: lang, }, updateQuery: (prevResult, { fetchMoreResult }) => { if ( From 1a60cbb02786d1101c33684357c1844b69641281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20Hafli=C3=B0ason?= Date: Fri, 14 Jun 2024 15:02:44 +0000 Subject: [PATCH 06/21] Add lang option --- .../src/components/Notifications/NotificationButton.tsx | 1 + .../information/src/screens/Notifications/Notifications.tsx | 2 ++ 2 files changed, 3 insertions(+) diff --git a/apps/service-portal/src/components/Notifications/NotificationButton.tsx b/apps/service-portal/src/components/Notifications/NotificationButton.tsx index 9461de07f11b..82583f47e539 100644 --- a/apps/service-portal/src/components/Notifications/NotificationButton.tsx +++ b/apps/service-portal/src/components/Notifications/NotificationButton.tsx @@ -36,6 +36,7 @@ const NotificationButton = ({ input: { limit: 5, }, + locale: lang, }, }) diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx index 0b0b809f0d0d..96dea2401617 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx @@ -54,6 +54,7 @@ const UserNotifications = () => { before: '', after: '', }, + locale: lang, }, }) @@ -71,6 +72,7 @@ const UserNotifications = () => { before: '', after: cursor, }, + locale: lang, }, updateQuery: (prevResult, { fetchMoreResult }) => { if ( From 76f5cf009eeeaa9f164ff819ef616a89c52df56d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20Hafli=C3=B0ason?= Date: Fri, 14 Jun 2024 15:14:18 +0000 Subject: [PATCH 07/21] Test --- .../src/components/Notifications/NotificationButton.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/service-portal/src/components/Notifications/NotificationButton.tsx b/apps/service-portal/src/components/Notifications/NotificationButton.tsx index 82583f47e539..9461de07f11b 100644 --- a/apps/service-portal/src/components/Notifications/NotificationButton.tsx +++ b/apps/service-portal/src/components/Notifications/NotificationButton.tsx @@ -36,7 +36,6 @@ const NotificationButton = ({ input: { limit: 5, }, - locale: lang, }, }) From 895b2187cd27ae629eedc6bbbb74fd5b24244df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20Hafli=C3=B0ason?= Date: Fri, 14 Jun 2024 15:34:23 +0000 Subject: [PATCH 08/21] Fix --- .../src/components/Notifications/NotificationButton.tsx | 1 + libs/service-portal/information/project.json | 1 - .../src/screens/Notifications/Notifications.graphql | 2 +- .../information/src/screens/Notifications/Notifications.tsx | 4 ++-- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/service-portal/src/components/Notifications/NotificationButton.tsx b/apps/service-portal/src/components/Notifications/NotificationButton.tsx index 9461de07f11b..82583f47e539 100644 --- a/apps/service-portal/src/components/Notifications/NotificationButton.tsx +++ b/apps/service-portal/src/components/Notifications/NotificationButton.tsx @@ -36,6 +36,7 @@ const NotificationButton = ({ input: { limit: 5, }, + locale: lang, }, }) diff --git a/libs/service-portal/information/project.json b/libs/service-portal/information/project.json index 967f733f0c68..c7d097c4d436 100644 --- a/libs/service-portal/information/project.json +++ b/libs/service-portal/information/project.json @@ -29,7 +29,6 @@ "codegen/frontend-client": { "executor": "nx:run-commands", "options": { - "parallel": false, "output": "libs/service-portal/information/src/**/*.generated.ts", "command": "graphql-codegen --config libs/service-portal/information/codegen.yml" } diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql index c92e90e288f3..b3dbcdbf1c08 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql @@ -32,7 +32,7 @@ fragment NotificationDataFields on Notification { } } -query GetUserNotifications($input: NotificationsInput!, $locale: String) { +query GetUserNotificationsList($input: NotificationsInput!, $locale: String) { userNotifications(input: $input, locale: $locale) { data { ...NotificationDataFields diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx index 96dea2401617..7914eaf6defa 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx @@ -17,7 +17,7 @@ import { } from '@island.is/service-portal/core' import { - useGetUserNotificationsQuery, + useGetUserNotificationsListQuery, useMarkAllNotificationsAsReadMutation, useMarkUserNotificationAsReadMutation, } from './Notifications.generated' @@ -47,7 +47,7 @@ const UserNotifications = () => { }) const { data, loading, error, refetch, fetchMore } = - useGetUserNotificationsQuery({ + useGetUserNotificationsListQuery({ variables: { input: { limit: DEFAULT_PAGE_SIZE, From f6bda61fd436a8fe4f9dd66949f4cecd7d7b23e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20Hafli=C3=B0ason?= Date: Fri, 14 Jun 2024 16:22:41 +0000 Subject: [PATCH 09/21] Add locale --- .../Notifications/Notifications.graphql | 2 +- .../screens/Notifications/Notifications.tsx | 23 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql index b3dbcdbf1c08..127f773a3515 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql @@ -33,7 +33,7 @@ fragment NotificationDataFields on Notification { } query GetUserNotificationsList($input: NotificationsInput!, $locale: String) { - userNotifications(input: $input, locale: $locale) { + userNotificationsList: userNotifications(input: $input, locale: $locale) { data { ...NotificationDataFields recipient { diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx index 7914eaf6defa..7851c5b3050b 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx @@ -76,12 +76,12 @@ const UserNotifications = () => { }, updateQuery: (prevResult, { fetchMoreResult }) => { if ( - fetchMoreResult?.userNotifications?.data.length && - prevResult?.userNotifications?.data.length + fetchMoreResult?.userNotificationsList?.data.length && + prevResult?.userNotificationsList?.data.length ) { - fetchMoreResult.userNotifications.data = [ - ...prevResult.userNotifications.data, - ...fetchMoreResult.userNotifications.data, + fetchMoreResult.userNotificationsList.data = [ + ...prevResult.userNotificationsList.data, + ...fetchMoreResult.userNotificationsList.data, ] return fetchMoreResult } @@ -90,7 +90,8 @@ const UserNotifications = () => { }).finally(() => setLoadingMore(false)) } - const noData = !data?.userNotifications?.data?.length && !loading && !error + const noData = + !data?.userNotificationsList?.data?.length && !loading && !error return ( <> { )} {!loading && - data?.userNotifications?.data.map((item) => ( + data?.userNotificationsList?.data.map((item) => ( { /> ))} {loadingMore && } - {data?.userNotifications?.pageInfo.hasNextPage ? ( + {data?.userNotificationsList?.pageInfo.hasNextPage ? ( { > ) : undefined} From 332484d3ab5cba69c3ceb1a6d52615177da0ef76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20Hafli=C3=B0ason?= Date: Fri, 14 Jun 2024 16:32:13 +0000 Subject: [PATCH 10/21] Test name update --- libs/service-portal/information/src/index.ts | 2 +- .../{Notifications.graphql => NotificationInfo.graphql} | 0 .../information/src/screens/Notifications/Notifications.tsx | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename libs/service-portal/information/src/screens/Notifications/{Notifications.graphql => NotificationInfo.graphql} (100%) diff --git a/libs/service-portal/information/src/index.ts b/libs/service-portal/information/src/index.ts index 2a9e5fd8c20c..0461ff590ce8 100644 --- a/libs/service-portal/information/src/index.ts +++ b/libs/service-portal/information/src/index.ts @@ -4,7 +4,7 @@ export * from './module' export * from './lib/navigation' export * from './lib/paths' export * from './components/FamilyMemberCard/FamilyMemberCard' -export * from './screens/Notifications/Notifications.generated' +export * from './screens/Notifications/NotificationInfo.generated' export * from './utils/notificationLinkResolver' /** diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.graphql b/libs/service-portal/information/src/screens/Notifications/NotificationInfo.graphql similarity index 100% rename from libs/service-portal/information/src/screens/Notifications/Notifications.graphql rename to libs/service-portal/information/src/screens/Notifications/NotificationInfo.graphql diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx index 7851c5b3050b..2ba20eb98864 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx @@ -20,7 +20,7 @@ import { useGetUserNotificationsListQuery, useMarkAllNotificationsAsReadMutation, useMarkUserNotificationAsReadMutation, -} from './Notifications.generated' +} from './NotificationInfo.generated' import { mInformationNotifications } from '../../lib/messages' import { ActionCard, CardLoader } from '@island.is/service-portal/core' From 825347cec0b37d52a8042daa12d7b901d479988c Mon Sep 17 00:00:00 2001 From: lommi Date: Fri, 14 Jun 2024 16:54:39 +0000 Subject: [PATCH 11/21] fix: force generated files --- scripts/ci/cache/__config.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/ci/cache/__config.mjs b/scripts/ci/cache/__config.mjs index eb31e5e661c4..d16f0851dcd3 100644 --- a/scripts/ci/cache/__config.mjs +++ b/scripts/ci/cache/__config.mjs @@ -23,6 +23,7 @@ import { keyStorage } from './_key_storage.mjs' // When testing this is good to manipulate const HASH_VERSION = `newcache-${6}` +const GENERATED_FILES_VERSION = '2024061401-notifications-locale-cleanstring'; export const ENABLED_MODULES = (process.env[ENV_ENABLED_CACHE] || '') .split(',') @@ -85,7 +86,7 @@ export const caches = [ enabled: ENABLED_MODULES['generated-files'], hash: async () => keyStorage.getKey('generated-files') ?? - `generated-files-${HASH_VERSION}-${getPlatformString()}-${await getYarnLockHash()}-${await getPackageHash()}-${await getGeneratedFileHash()}`, + `generated-files-${GENERATED_FILES_VERSION}-${HASH_VERSION}-${getPlatformString()}-${await getYarnLockHash()}-${await getPackageHash()}-${await getGeneratedFileHash()}`, name: 'Cache Generated Files', id: 'generated-files', path: 'generated_files.tar.gz', From bf4e3b10fdf5df542532a282948b9074f1d291b2 Mon Sep 17 00:00:00 2001 From: andes-it Date: Fri, 14 Jun 2024 17:06:09 +0000 Subject: [PATCH 12/21] chore: nx format:write update dirty files --- scripts/ci/cache/__config.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/cache/__config.mjs b/scripts/ci/cache/__config.mjs index d16f0851dcd3..1d2a84f7788d 100644 --- a/scripts/ci/cache/__config.mjs +++ b/scripts/ci/cache/__config.mjs @@ -23,7 +23,7 @@ import { keyStorage } from './_key_storage.mjs' // When testing this is good to manipulate const HASH_VERSION = `newcache-${6}` -const GENERATED_FILES_VERSION = '2024061401-notifications-locale-cleanstring'; +const GENERATED_FILES_VERSION = '2024061401-notifications-locale-cleanstring' export const ENABLED_MODULES = (process.env[ENV_ENABLED_CACHE] || '') .split(',') From 17e56731695005a04a69330071348d2198cebf16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20Hafli=C3=B0ason?= Date: Mon, 17 Jun 2024 23:53:24 +0000 Subject: [PATCH 13/21] Revert test --- libs/service-portal/information/src/index.ts | 2 +- ...tionInfo.graphql => Notifications.graphql} | 2 +- .../screens/Notifications/Notifications.tsx | 25 +++++++++---------- 3 files changed, 14 insertions(+), 15 deletions(-) rename libs/service-portal/information/src/screens/Notifications/{NotificationInfo.graphql => Notifications.graphql} (94%) diff --git a/libs/service-portal/information/src/index.ts b/libs/service-portal/information/src/index.ts index 0461ff590ce8..2a9e5fd8c20c 100644 --- a/libs/service-portal/information/src/index.ts +++ b/libs/service-portal/information/src/index.ts @@ -4,7 +4,7 @@ export * from './module' export * from './lib/navigation' export * from './lib/paths' export * from './components/FamilyMemberCard/FamilyMemberCard' -export * from './screens/Notifications/NotificationInfo.generated' +export * from './screens/Notifications/Notifications.generated' export * from './utils/notificationLinkResolver' /** diff --git a/libs/service-portal/information/src/screens/Notifications/NotificationInfo.graphql b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql similarity index 94% rename from libs/service-portal/information/src/screens/Notifications/NotificationInfo.graphql rename to libs/service-portal/information/src/screens/Notifications/Notifications.graphql index 127f773a3515..b3dbcdbf1c08 100644 --- a/libs/service-portal/information/src/screens/Notifications/NotificationInfo.graphql +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.graphql @@ -33,7 +33,7 @@ fragment NotificationDataFields on Notification { } query GetUserNotificationsList($input: NotificationsInput!, $locale: String) { - userNotificationsList: userNotifications(input: $input, locale: $locale) { + userNotifications(input: $input, locale: $locale) { data { ...NotificationDataFields recipient { diff --git a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx index 2ba20eb98864..7914eaf6defa 100644 --- a/libs/service-portal/information/src/screens/Notifications/Notifications.tsx +++ b/libs/service-portal/information/src/screens/Notifications/Notifications.tsx @@ -20,7 +20,7 @@ import { useGetUserNotificationsListQuery, useMarkAllNotificationsAsReadMutation, useMarkUserNotificationAsReadMutation, -} from './NotificationInfo.generated' +} from './Notifications.generated' import { mInformationNotifications } from '../../lib/messages' import { ActionCard, CardLoader } from '@island.is/service-portal/core' @@ -76,12 +76,12 @@ const UserNotifications = () => { }, updateQuery: (prevResult, { fetchMoreResult }) => { if ( - fetchMoreResult?.userNotificationsList?.data.length && - prevResult?.userNotificationsList?.data.length + fetchMoreResult?.userNotifications?.data.length && + prevResult?.userNotifications?.data.length ) { - fetchMoreResult.userNotificationsList.data = [ - ...prevResult.userNotificationsList.data, - ...fetchMoreResult.userNotificationsList.data, + fetchMoreResult.userNotifications.data = [ + ...prevResult.userNotifications.data, + ...fetchMoreResult.userNotifications.data, ] return fetchMoreResult } @@ -90,8 +90,7 @@ const UserNotifications = () => { }).finally(() => setLoadingMore(false)) } - const noData = - !data?.userNotificationsList?.data?.length && !loading && !error + const noData = !data?.userNotifications?.data?.length && !loading && !error return ( <> { )} {!loading && - data?.userNotificationsList?.data.map((item) => ( + data?.userNotifications?.data.map((item) => ( { /> ))} {loadingMore && } - {data?.userNotificationsList?.pageInfo.hasNextPage ? ( + {data?.userNotifications?.pageInfo.hasNextPage ? ( { > ) : undefined} From 2f282245610e67a089451e10da51566846620a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3r=C3=B0ur=20Hafli=C3=B0ason?= Date: Tue, 18 Jun 2024 00:27:42 +0000 Subject: [PATCH 14/21] Remove ff --- .../api/domains/notifications/src/lib/notifications.resolver.ts | 2 -- .../domains/notifications/src/lib/notificationsList.resolver.ts | 2 -- 2 files changed, 4 deletions(-) diff --git a/libs/api/domains/notifications/src/lib/notifications.resolver.ts b/libs/api/domains/notifications/src/lib/notifications.resolver.ts index 0f4ee313468d..8b9d124e7359 100644 --- a/libs/api/domains/notifications/src/lib/notifications.resolver.ts +++ b/libs/api/domains/notifications/src/lib/notifications.resolver.ts @@ -13,7 +13,6 @@ import { } from './notifications.model' import type { Locale } from '@island.is/shared/types' import { LOGGER_PROVIDER, type Logger } from '@island.is/logging' -import { FeatureFlag, Features } from '@island.is/nest/feature-flags' const LOG_CATEGORY = 'notifications-resolver' export const AUDIT_NAMESPACE = 'notifications-resolver' @@ -22,7 +21,6 @@ export const AUDIT_NAMESPACE = 'notifications-resolver' @Resolver() @Audit({ namespace: AUDIT_NAMESPACE }) @Scopes(DocumentsScope.main) -@FeatureFlag(Features.ServicePortalNotificationsEnabled) export class NotificationsResolver { constructor( private readonly service: NotificationsService, diff --git a/libs/api/domains/notifications/src/lib/notificationsList.resolver.ts b/libs/api/domains/notifications/src/lib/notificationsList.resolver.ts index 738fc7d18d58..cd2b81bc5d19 100644 --- a/libs/api/domains/notifications/src/lib/notificationsList.resolver.ts +++ b/libs/api/domains/notifications/src/lib/notificationsList.resolver.ts @@ -26,7 +26,6 @@ import type { Locale } from '@island.is/shared/types' import { LOGGER_PROVIDER, type Logger } from '@island.is/logging' import { Loader } from '@island.is/nest/dataloader' import { AUDIT_NAMESPACE } from './notifications.resolver' -import { FeatureFlag, Features } from '@island.is/nest/feature-flags' import { DocumentsScope } from '@island.is/auth/scopes' const LOG_CATEGORY = 'notification-list-resolver' @@ -35,7 +34,6 @@ const LOG_CATEGORY = 'notification-list-resolver' @Resolver(() => NotificationsResponse) @Audit({ namespace: AUDIT_NAMESPACE }) @Scopes(DocumentsScope.main) -@FeatureFlag(Features.ServicePortalNotificationsEnabled) export class NotificationsListResolver { constructor( private readonly service: NotificationsService, From b36f87cae4d77d4976c29e33f91e9b52ee89a931 Mon Sep 17 00:00:00 2001 From: lommi Date: Tue, 18 Jun 2024 10:17:48 +0000 Subject: [PATCH 15/21] fix: hash generated files --- scripts/_hash-generated-files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_hash-generated-files.sh b/scripts/_hash-generated-files.sh index 87acbd3cd1aa..b45e6576e1d3 100755 --- a/scripts/_hash-generated-files.sh +++ b/scripts/_hash-generated-files.sh @@ -33,7 +33,7 @@ patterns=( 'apps/**/*.union.ts' 'libs/**/*.union.ts' 'apps/**/*.graphql.ts' - 'apps/judicial-system/**/*.graphql' + 'apps/**/*.graphql' 'libs/**/*.graphql.ts' 'libs/**/*.graphql' 'libs/**/clientConfig.yaml' From 56f72cc986d78b760cb0da6bfef73ee22f2ba126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0j=C3=B3n=20Gu=C3=B0j=C3=B3nsson?= Date: Tue, 18 Jun 2024 09:24:09 +0000 Subject: [PATCH 16/21] fix(j-s): Null Service Reference (#15247) Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .../backend/src/app/modules/case/internalCase.service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts b/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts index fa2f48a5ab7c..3f1330ed5351 100644 --- a/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts +++ b/apps/judicial-system/backend/src/app/modules/case/internalCase.service.ts @@ -164,6 +164,7 @@ export class InternalCaseService { private readonly defendantService: DefendantService, @Inject(forwardRef(() => EventLogService)) private readonly eventLogService: EventLogService, + @Inject(forwardRef(() => PDFService)) private readonly pdfService: PDFService, @Inject(LOGGER_PROVIDER) private readonly logger: Logger, ) {} From 3b25846bb5442412759083a2f49768999ddb0a80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9E=C3=B3rey=20J=C3=B3na?= Date: Tue, 18 Jun 2024 09:55:34 +0000 Subject: [PATCH 17/21] feat(native-app): Notifications final improvements (#15240) * feat: buttons at top should not be sticky * feat: add empty state for notifications * fix: make sure to update unreadCount in inbox when fetching next page * feat: add fallback icon for notifications --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- apps/native/app/src/messages/en.ts | 3 + apps/native/app/src/messages/is.ts | 3 + apps/native/app/src/screens/inbox/inbox.tsx | 1 + .../screens/notifications/notifications.tsx | 125 ++++++++++++------ .../app/src/ui/lib/empty-state/empty-list.tsx | 20 +-- 5 files changed, 97 insertions(+), 55 deletions(-) diff --git a/apps/native/app/src/messages/en.ts b/apps/native/app/src/messages/en.ts index 2490a8017358..6792e2614ac4 100644 --- a/apps/native/app/src/messages/en.ts +++ b/apps/native/app/src/messages/en.ts @@ -281,6 +281,9 @@ export const en: TranslatedMessages = { 'notifications.markAllAsRead': 'Mark all as read', 'notifications.settings': 'My settings', 'notifications.errorUnknown': 'Error occurred while loading notifications', + 'notifications.emptyListTitle': 'No notifications', + 'notifications.emptyListDescription': + 'When you receive notifications, they will appear here.', // profile 'profile.screenTitle': 'More', diff --git a/apps/native/app/src/messages/is.ts b/apps/native/app/src/messages/is.ts index f6754c762e4c..c3bcdb5d8bf4 100644 --- a/apps/native/app/src/messages/is.ts +++ b/apps/native/app/src/messages/is.ts @@ -415,6 +415,9 @@ export const is = { 'notifications.markAllAsRead': 'Merkja allt lesið', 'notifications.settings': 'Mínar stillingar', 'notifications.errorUnknown': 'Villa kom upp við að sækja tilkynningar', + 'notifications.emptyListTitle': 'Engar tilkynningar', + 'notifications.emptyListDescription': + 'Þegar þú færð sendar tilkynningar þá birtast þær hér.', // applications screen 'applications.title': 'Umsóknir', diff --git a/apps/native/app/src/screens/inbox/inbox.tsx b/apps/native/app/src/screens/inbox/inbox.tsx index 334c2ae70252..308966c19068 100644 --- a/apps/native/app/src/screens/inbox/inbox.tsx +++ b/apps/native/app/src/screens/inbox/inbox.tsx @@ -217,6 +217,7 @@ function useInboxQuery(incomingFilters?: Filters) { ...(data.documentsV2?.data ?? []), ], totalCount: data.documentsV2?.totalCount ?? 0, + unreadCount: data.documentsV2?.unreadCount ?? 0, })) } else { setData(data.documentsV2) diff --git a/apps/native/app/src/screens/notifications/notifications.tsx b/apps/native/app/src/screens/notifications/notifications.tsx index 548498d79e15..aa54c3fe624a 100644 --- a/apps/native/app/src/screens/notifications/notifications.tsx +++ b/apps/native/app/src/screens/notifications/notifications.tsx @@ -4,13 +4,20 @@ import { NotificationCard, Problem, ListItemSkeleton, + EmptyList, } from '@ui' import { useApolloClient } from '@apollo/client' import { dismissAllNotificationsAsync } from 'expo-notifications' import React, { useCallback, useEffect, useMemo, useState } from 'react' import { useIntl } from 'react-intl' -import { ActivityIndicator, FlatList, SafeAreaView } from 'react-native' +import { + ActivityIndicator, + FlatList, + SafeAreaView, + View, + Image, +} from 'react-native' import { Navigation, NavigationFunctionComponent, @@ -37,6 +44,7 @@ import { isAndroid } from '../../utils/devices' import { testIDs } from '../../utils/test-ids' import settings from '../../assets/icons/settings.png' import inboxRead from '../../assets/icons/inbox-read.png' +import emptyIllustrationSrc from '../../assets/illustrations/le-company-s3.png' const LoadingWrapper = styled.View` padding-vertical: ${({ theme }) => theme.spacing[3]}px; @@ -47,10 +55,14 @@ const ButtonWrapper = styled.View` flex-direction: row; margin-horizontal: ${({ theme }) => theme.spacing[2]}px; margin-top: ${({ theme }) => theme.spacing[2]}px; + margin-bottom: ${({ theme }) => theme.spacing[2]}px; ` const DEFAULT_PAGE_SIZE = 50 +const FALLBACK_ICON_URL = + 'https://images.ctfassets.net/8k0h54kbe6bj/6XhCz5Ss17OVLxpXNVDxAO/d3d6716bdb9ecdc5041e6baf68b92ba6/coat_of_arms.svg' + const { getNavigationOptions, useNavigationOptions } = createNavigationOptionHooks(() => ({ topBar: { @@ -62,7 +74,12 @@ type NotificationItem = NonNullable< NonNullable['data'] >[0] -type ListItem = SkeletonItem | NotificationItem +export type EmptyItem = { + id: string + __typename: 'Empty' +} + +type ListItem = SkeletonItem | NotificationItem | EmptyItem export const NotificationsScreen: NavigationFunctionComponent = ({ componentId, @@ -123,6 +140,10 @@ export const NotificationsScreen: NavigationFunctionComponent = ({ return createSkeletonArr(9) } + if (data?.userNotifications?.data?.length === 0) { + return [{ id: '0', __typename: 'Empty' }] + } + return data?.userNotifications?.data || [] }, [data, loading]) @@ -185,6 +206,26 @@ export const NotificationsScreen: NavigationFunctionComponent = ({ return } + if (item.__typename === 'Empty') { + return ( + + + } + /> + + ) + } + return ( onNotificationPress(item)} testID={testIDs.NOTIFICATION_CARD_BUTTON} @@ -219,40 +260,6 @@ export const NotificationsScreen: NavigationFunctionComponent = ({ showLoading={loading && !!data} /> - -