From 02739964cddf772498c5314d41c2c0201ebdbecf Mon Sep 17 00:00:00 2001 From: andreastanderen Date: Thu, 12 Dec 2024 10:55:07 +0100 Subject: [PATCH] refactor: adapt contract when fetching all option lists to visualise error per option list --- .../Designer/Controllers/OptionsController.cs | 32 ++++++++++-- .../src/Designer/Models/Dto/OptionListData.cs | 11 +++++ .../AppContentLibrary.test.tsx | 16 +++--- .../appContentLibrary/AppContentLibrary.tsx | 20 ++++---- .../convertOptionListsToCodeLists.test.ts | 41 ---------------- .../utils/convertOptionListsToCodeLists.ts | 13 ----- ...ertOptionsListsDataToCodeListsData.test.ts | 49 +++++++++++++++++++ .../convertOptionsListsDataToCodeListsData.ts | 20 ++++++++ frontend/language/src/nb.json | 2 +- .../mocks/mockPagesConfig.ts | 14 ++++-- .../pages/CodeListPage/CodeListPage.test.tsx | 43 +++++----------- .../pages/CodeListPage/CodeListPage.tsx | 24 ++++----- .../CodeListPage/CodeLists/CodeLists.test.tsx | 31 +++++++----- .../CodeListPage/CodeLists/CodeLists.tsx | 45 +++++++++++------ .../LibraryBody/pages/CodeListPage/index.ts | 2 +- .../ContentLibrary/LibraryBody/pages/index.ts | 2 +- .../ContentResourceLibraryImpl.test.tsx | 3 +- .../libs/studio-content-library/src/index.ts | 2 +- .../utils/router/RouterRouteMapper.test.ts | 3 +- .../src/ObjectUtils/ObjectUtils.test.ts | 28 ----------- .../src/ObjectUtils/ObjectUtils.ts | 10 ---- frontend/packages/shared/src/api/queries.ts | 1 - .../useUpdateOptionListIdMutation.test.ts | 37 +++++++------- .../useUpdateOptionListIdMutation.ts | 25 ++++++---- .../mutations/useUpdateOptionListMutation.ts | 25 ++++++++-- .../src/hooks/queries/useOptionListsQuery.ts | 11 +++-- .../packages/shared/src/mocks/queriesMock.ts | 4 +- .../shared/src/types/api/OptionsLists.ts | 10 +++- .../src/components/Elements/ExportForm.tsx | 6 +-- .../ux-editor/src/utils/exportUtils.test.ts | 20 ++++---- .../ux-editor/src/utils/exportUtils.ts | 13 +++-- 31 files changed, 306 insertions(+), 257 deletions(-) create mode 100644 backend/src/Designer/Models/Dto/OptionListData.cs delete mode 100644 frontend/app-development/features/appContentLibrary/utils/convertOptionListsToCodeLists.test.ts delete mode 100644 frontend/app-development/features/appContentLibrary/utils/convertOptionListsToCodeLists.ts create mode 100644 frontend/app-development/features/appContentLibrary/utils/convertOptionsListsDataToCodeListsData.test.ts create mode 100644 frontend/app-development/features/appContentLibrary/utils/convertOptionsListsDataToCodeListsData.ts diff --git a/backend/src/Designer/Controllers/OptionsController.cs b/backend/src/Designer/Controllers/OptionsController.cs index 1482ad10064..232870e2714 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,40 @@ 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