From 0f7a0f46f62489f36cc4e7ff52bc529246d35f51 Mon Sep 17 00:00:00 2001 From: andreastanderen Date: Wed, 11 Dec 2024 10:49:40 +0100 Subject: [PATCH] adapt getAllOptionsLists to return also faulty options lists if reading them fails --- .../Designer/Controllers/OptionsController.cs | 33 +++++- .../src/Designer/Models/Dto/OptionListData.cs | 11 ++ .../AppContentLibrary.test.tsx | 17 ++- .../appContentLibrary/AppContentLibrary.tsx | 26 ++--- ...convertOptionsListToCodeListResult.test.ts | 58 ---------- .../convertOptionsListToCodeListResult.ts | 14 --- ...ertOptionsListsDataToCodeListsData.test.ts | 49 ++++++++ .../convertOptionsListsDataToCodeListsData.ts | 20 ++++ .../mocks/mockPagesConfig.ts | 13 ++- .../pages/CodeList/CodeList.test.tsx | 15 +-- .../LibraryBody/pages/CodeList/CodeList.tsx | 23 ++-- .../CodeList/CodeLists/CodeLists.test.tsx | 18 +-- .../pages/CodeList/CodeLists/CodeLists.tsx | 44 +++---- .../LibraryBody/pages/CodeList/index.ts | 2 +- .../ContentLibrary/LibraryBody/pages/index.ts | 2 +- .../libs/studio-content-library/src/index.ts | 2 +- .../src/types/useLibraryQuery.ts | 5 - .../src/ObjectUtils/ObjectUtils.ts | 10 -- frontend/packages/shared/src/api/queries.ts | 5 +- .../useUpdateOptionListIdMutation.test.ts | 37 +++--- .../useUpdateOptionListIdMutation.ts | 25 ++-- .../useUpdateOptionListMutation.test.ts | 17 ++- .../mutations/useUpdateOptionListMutation.ts | 24 +++- .../shared/src/hooks/queries/index.ts | 1 - .../hooks/queries/useGetOptionListQuery.ts | 16 --- .../hooks/queries/useOptionListQuery.test.ts | 3 + .../src/hooks/queries/useOptionListQuery.ts | 2 +- .../src/hooks/queries/useOptionListsQuery.ts | 11 +- .../packages/shared/src/mocks/queriesMock.ts | 4 +- .../packages/shared/src/types/QueryKey.ts | 1 + .../shared/src/types/api/OptionsLists.ts | 8 ++ .../src/components/Elements/ExportForm.tsx | 6 +- .../OptionTabs/EditTab/EditTab.tsx | 7 +- .../OptionListEditor.test.tsx | 107 ++++++++---------- .../OptionListEditor/OptionListEditor.tsx | 49 ++++---- .../ux-editor/src/utils/exportUtils.test.ts | 23 ++-- .../ux-editor/src/utils/exportUtils.ts | 13 ++- 37 files changed, 366 insertions(+), 355 deletions(-) create mode 100644 backend/src/Designer/Models/Dto/OptionListData.cs delete mode 100644 frontend/app-development/features/appContentLibrary/utils/convertOptionsListToCodeListResult.test.ts delete mode 100644 frontend/app-development/features/appContentLibrary/utils/convertOptionsListToCodeListResult.ts create mode 100644 frontend/app-development/features/appContentLibrary/utils/convertOptionsListsDataToCodeListsData.test.ts create mode 100644 frontend/app-development/features/appContentLibrary/utils/convertOptionsListsDataToCodeListsData.ts delete mode 100644 frontend/libs/studio-content-library/src/types/useLibraryQuery.ts delete mode 100644 frontend/packages/shared/src/hooks/queries/useGetOptionListQuery.ts diff --git a/backend/src/Designer/Controllers/OptionsController.cs b/backend/src/Designer/Controllers/OptionsController.cs index 1482ad10064..33f38d1ac8f 100644 --- a/backend/src/Designer/Controllers/OptionsController.cs +++ b/backend/src/Designer/Controllers/OptionsController.cs @@ -3,8 +3,10 @@ using System.Text.Json; using System.Threading; using System.Threading.Tasks; +using Altinn.Studio.Designer.Exceptions.Options; using Altinn.Studio.Designer.Helpers; using Altinn.Studio.Designer.Models; +using Altinn.Studio.Designer.Models.Dto; using Altinn.Studio.Designer.Services.Interfaces; using LibGit2Sharp; using Microsoft.AspNetCore.Authorization; @@ -56,20 +58,41 @@ public ActionResult GetOptionsListIds(string org, string repo) /// /// Unique identifier of the organisation responsible for the app. /// Application identifier which is unique within an organisation. - /// Dictionary of all option lists belonging to the app + /// List of objects with all option lists belonging to the app with data + /// set if option list is valid, or isError set if option list is invalid. [HttpGet] [Route("option-lists")] - public async Task>>> GetOptionLists(string org, string repo) + public async Task>> GetOptionLists(string org, string repo) { try { string developer = AuthenticationHelper.GetDeveloperUserName(HttpContext); string[] optionListIds = _optionsService.GetOptionsListIds(org, repo, developer); - Dictionary> optionLists = []; + List optionLists = []; foreach (string optionListId in optionListIds) { - List