From 3cfbc2cf03cabb4e81f979196e5aae6310e78219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Burkard?= <22095555+JeromeBu@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:39:53 +0100 Subject: [PATCH 1/2] rename wikidata to softwareExternalData to be able to run with HAL as source of data --- src/core/adapter/sillApi.ts | 7 +- src/core/adapter/sillApiMock.ts | 137 +++++++++++------- src/core/ports/SillApi.ts | 12 +- src/core/usecases/instanceForm/state.ts | 2 +- src/core/usecases/instanceForm/thunks.ts | 2 +- .../usecases/softwareCatalog/selectors.ts | 40 +++-- src/core/usecases/softwareCatalog/thunks.ts | 6 +- src/core/usecases/softwareDetails/thunks.ts | 17 ++- src/core/usecases/softwareForm/state.ts | 12 +- src/core/usecases/softwareForm/thunks.ts | 49 +++---- .../softwareForm/SoftwareForm.stories.tsx | 2 +- src/ui/pages/instanceForm/InstanceForm.tsx | 4 +- src/ui/pages/instanceForm/Step1.tsx | 2 +- .../softwareDetails/AlikeSoftwareTab.tsx | 4 +- .../pages/softwareDetails/SoftwareDetails.tsx | 4 +- src/ui/pages/softwareForm/SoftwareForm.tsx | 11 +- src/ui/pages/softwareForm/Step2.tsx | 14 +- src/ui/pages/softwareForm/Step4.tsx | 17 ++- src/ui/pages/softwareForm/route.ts | 2 +- 19 files changed, 190 insertions(+), 154 deletions(-) diff --git a/src/core/adapter/sillApi.ts b/src/core/adapter/sillApi.ts index fe394a24..5255094b 100644 --- a/src/core/adapter/sillApi.ts +++ b/src/core/adapter/sillApi.ts @@ -59,9 +59,10 @@ export function createSillApi(params: { "getInstances": memoize(() => trpcClient.getInstances.query(), { "promise": true }), - "getWikidataOptions": params => trpcClient.getWikidataOptions.query(params), - "getSoftwareFormAutoFillDataFromWikidataAndOtherSources": params => - trpcClient.getSoftwareFormAutoFillDataFromWikidataAndOtherSources.query( + "getExternalSoftwareOptions": params => + trpcClient.getExternalSoftwareOptions.query(params), + "getSoftwareFormAutoFillDataFromExternalSoftwareAndOtherSources": params => + trpcClient.getSoftwareFormAutoFillDataFromExternalSoftwareAndOtherSources.query( params ), "createSoftware": async params => { diff --git a/src/core/adapter/sillApiMock.ts b/src/core/adapter/sillApiMock.ts index 44165fcc..37331c05 100644 --- a/src/core/adapter/sillApiMock.ts +++ b/src/core/adapter/sillApiMock.ts @@ -1,3 +1,4 @@ +import { SoftwareExternalDataOption } from "@codegouvfr/sill/core/ports/GetSoftwareExternalDataOptions"; import memoize from "memoizee"; import type { SillApi } from "../ports/SillApi"; import { id } from "tsafe/id"; @@ -45,7 +46,7 @@ export const sillApi: SillApi = { }, { "promise": true } ), - "getWikidataOptions": async ({ queryString }) => { + "getExternalSoftwareOptions": async ({ queryString }) => { if (queryString === "") { return []; } @@ -54,15 +55,17 @@ export const sillApi: SillApi = { return options; }, - "getSoftwareFormAutoFillDataFromWikidataAndOtherSources": async ({ wikidataId }) => { + "getSoftwareFormAutoFillDataFromExternalSoftwareAndOtherSources": async ({ + externalId + }) => { await new Promise(resolve => setTimeout(resolve, 1)); return { - wikidataId, + externalId, "comptoirDuLibreId": 123, - "softwareName": `Software ${wikidataId}`, - "softwareDescription": `Software ${wikidataId} description`, - "softwareLicense": `Software ${wikidataId} license`, + "softwareName": `Software ${externalId}`, + "softwareDescription": `Software ${externalId} description`, + "softwareLicense": `Software ${externalId} license`, "softwareMinimalVersion": `1.3.4`, "softwareLogoUrl": undefined, "keywords": [] @@ -86,7 +89,8 @@ export const sillApi: SillApi = { "versionMin": "3.9.0", "comptoirDuLibreServiceProviderCount": 0, "comptoirDuLibreId": formData.comptoirDuLibreId, - "wikidataId": formData.wikidataId, + "externalId": formData.externalId, + "externalDataOrigin": "wikidata", "license": formData.softwareLicense, "officialWebsiteUrl": undefined, "documentationUrl": undefined, @@ -139,7 +143,8 @@ export const sillApi: SillApi = { "versionMin": "3.9.0", "comptoirDuLibreServiceProviderCount": 0, "comptoirDuLibreId": formData.comptoirDuLibreId, - "wikidataId": formData.wikidataId, + "externalId": formData.externalId, + "externalDataOrigin": "wikidata", "license": formData.softwareLicense, "officialWebsiteUrl": undefined, "documentationUrl": undefined, @@ -234,49 +239,55 @@ export const sillApi: SillApi = { } }; -const options = [ +const options: (SoftwareExternalDataOption & { isInSill: boolean })[] = [ { - "wikidataId": "Q110492908", + "externalId": "Q110492908", "label": "Onyxia", "description": "A data science oriented container launcher", - "isInSill": true, - "isLibreSoftware": true + "isLibreSoftware": true, + "externalDataOrigin": "wikidata", + "isInSill": true }, { - "wikidataId": "Q107693197", + "externalId": "Q107693197", "label": "Keycloakify", "description": "Build tool for creating Keycloak themes using React", - "isInSill": true, - "isLibreSoftware": true + "isLibreSoftware": true, + "externalDataOrigin": "wikidata", + "isInSill": true }, { - "wikidataId": "Q8038", + "externalId": "Q8038", "description": "image retouching and editing tool", "label": "GIMP", - "isInSill": true, - "isLibreSoftware": true + "isLibreSoftware": true, + "externalDataOrigin": "wikidata", + "isInSill": true }, { - "wikidataId": "Q10135", + "externalId": "Q10135", "description": "office suite supported by the free software community", "label": "LibreOffice", - "isInSill": true, - "isLibreSoftware": true + "isLibreSoftware": true, + "externalDataOrigin": "wikidata", + "isInSill": true }, { - "wikidataId": "Q19841877", + "externalId": "Q19841877", "description": "source code editor developed by Microsoft", "label": "Visual Studio Code", - "isInSill": true, - "isLibreSoftware": true + "isLibreSoftware": true, + "externalDataOrigin": "wikidata", + "isInSill": true }, { - "wikidataId": "Q50938515", + "externalId": "Q50938515", "description": "decentralized video hosting network, based on free/libre software", "label": "PeerTube", - "isInSill": true, - "isLibreSoftware": true + "isLibreSoftware": true, + "externalDataOrigin": "wikidata", + "isInSill": true } ]; @@ -296,13 +307,15 @@ const softwares = [ { "description": "team collaboration and videoconferencing application developed by Microsoft", - "wikidataId": "Q28406404", + "externalId": "Q28406404", "label": "Microsoft Teams", "isLibreSoftware": false, - "isInSill": false + "isInSill": false, + "externalDataOrigin": "wikidata" } ], - "wikidataId": "Q25874683", + "externalId": "Q25874683", + "externalDataOrigin": "wikidata", "license": "AGPL-3.0-or-later", "officialWebsiteUrl": undefined, "documentationUrl": undefined, @@ -350,13 +363,15 @@ const softwares = [ { "description": "team collaboration and videoconferencing application developed by Microsoft", - "wikidataId": "Q28406404", + "externalId": "Q28406404", "label": "Microsoft Teams", "isLibreSoftware": false, - "isInSill": false + "isInSill": false, + "externalDataOrigin": "wikidata" } ], - "wikidataId": "Q10135", + "externalId": "Q10135", + "externalDataOrigin": "wikidata", "license": "MPL-2.0", "officialWebsiteUrl": "https://www.libreoffice.org/", "documentationUrl": "https://www.libreoffice.org/", @@ -417,7 +432,8 @@ const softwares = [ "comptoirDuLibreId": 38, "annuaireCnllServiceProviders": [], "similarSoftwares": [], - "wikidataId": "Q10135", + "externalId": "Q10135", + "externalDataOrigin": "wikidata", "softwareType": { "type": "cloud" }, @@ -468,7 +484,8 @@ const softwares = [ "comptoirDuLibreId": 62, "annuaireCnllServiceProviders": [], "similarSoftwares": [], - "wikidataId": "Q171477", + "externalId": "Q171477", + "externalDataOrigin": "wikidata", "license": "GPL-2.0-only", "officialWebsiteUrl": "https://www.wikidata.org/wiki/Q171477", "documentationUrl": undefined, @@ -521,13 +538,15 @@ const softwares = [ { "description": "team collaboration and videoconferencing application developed by Microsoft", - "wikidataId": "Q28406404", + "externalId": "Q28406404", "label": "Microsoft Teams", "isLibreSoftware": false, - "isInSill": false + "isInSill": false, + "externalDataOrigin": "wikidata" } ], - "wikidataId": "Q7715973", + "externalId": "Q7715973", + "externalDataOrigin": "wikidata", "license": "N/A", "officialWebsiteUrl": "https://www.debian.org/", "documentationUrl": undefined, @@ -581,7 +600,8 @@ const softwares = [ "comptoirDuLibreServiceProviderCount": 9, "comptoirDuLibreId": 80, "annuaireCnllServiceProviders": [], - "wikidataId": "Q483604", + "externalId": "Q483604", + "externalDataOrigin": "wikidata", "license": "MPL-2.0", "officialWebsiteUrl": "https://www.thunderbird.net/", "documentationUrl": undefined, @@ -605,7 +625,8 @@ const softwares = [ { "description": "team collaboration and videoconferencing application developed by Microsoft", - "wikidataId": "Q28406404", + "externalId": "Q28406404", + "externalDataOrigin": "wikidata", "label": "Microsoft Teams", "isLibreSoftware": false, "isInSill": false @@ -645,7 +666,8 @@ const softwares = [ "comptoirDuLibreId": 60, "annuaireCnllServiceProviders": [], "similarSoftwares": [], - "wikidataId": "Q1329181", + "externalId": "Q1329181", + "externalDataOrigin": "wikidata", "license": "GPL-2.0-or-later", "officialWebsiteUrl": "https://qgis.org/fr/site/", "documentationUrl": undefined, @@ -713,7 +735,8 @@ const softwares = [ "comptoirDuLibreServiceProviderCount": 3, "comptoirDuLibreId": 82, "annuaireCnllServiceProviders": [], - "wikidataId": "Q698", + "externalId": "Q698", + "externalDataOrigin": "wikidata", "license": "MPL-2.0", "officialWebsiteUrl": "https://www.mozilla.org/fr/firefox/new/", "documentationUrl": undefined, @@ -770,7 +793,8 @@ const softwares = [ "comptoirDuLibreId": 123, "annuaireCnllServiceProviders": [], "similarSoftwares": [], - "wikidataId": "Q192490", + "externalId": "Q192490", + "externalDataOrigin": "wikidata", "license": "PostgreSQL", "officialWebsiteUrl": "https://www.postgresql.org/", "documentationUrl": undefined, @@ -815,7 +839,8 @@ const softwares = [ "comptoirDuLibreId": 140, "annuaireCnllServiceProviders": [], "similarSoftwares": [], - "wikidataId": "Q50938515", + "externalId": "Q50938515", + "externalDataOrigin": "wikidata", "license": "AGPL-3.0-or-later", "officialWebsiteUrl": "https://joinpeertube.org/", "documentationUrl": undefined, @@ -857,7 +882,8 @@ const softwares = [ "comptoirDuLibreServiceProviderCount": 1, "comptoirDuLibreId": 368, "annuaireCnllServiceProviders": [], - "wikidataId": "Q77064547", + "externalId": "Q77064547", + "externalDataOrigin": "wikidata", "license": "MIT", "officialWebsiteUrl": "https://archifiltre.fabrique.social.gouv.fr/", "documentationUrl": undefined, @@ -902,7 +928,8 @@ const softwares = [ "comptoirDuLibreServiceProviderCount": 1, "comptoirDuLibreId": 368, "annuaireCnllServiceProviders": [], - "wikidataId": "Q77064547", + "externalId": "Q77064547", + "externalDataOrigin": "wikidata", "license": "MIT", "officialWebsiteUrl": "https://archifiltre.fabrique.social.gouv.fr/", "documentationUrl": undefined, @@ -947,7 +974,8 @@ const softwares = [ "comptoirDuLibreServiceProviderCount": 1, "comptoirDuLibreId": 368, "annuaireCnllServiceProviders": [], - "wikidataId": "Q77064547", + "externalId": "Q77064547", + "externalDataOrigin": "wikidata", "license": "MIT", "officialWebsiteUrl": "https://archifiltre.fabrique.social.gouv.fr/", "documentationUrl": undefined, @@ -992,7 +1020,8 @@ const softwares = [ "comptoirDuLibreServiceProviderCount": 1, "comptoirDuLibreId": 368, "annuaireCnllServiceProviders": [], - "wikidataId": "Q77064547", + "externalId": "Q77064547", + "externalDataOrigin": "wikidata", "license": "MIT", "officialWebsiteUrl": "https://archifiltre.fabrique.social.gouv.fr/", "documentationUrl": undefined, @@ -1037,7 +1066,8 @@ const softwares = [ "comptoirDuLibreServiceProviderCount": 1, "comptoirDuLibreId": 368, "annuaireCnllServiceProviders": [], - "wikidataId": "Q77064547", + "externalId": "Q77064547", + "externalDataOrigin": "wikidata", "license": "MIT", "officialWebsiteUrl": "https://archifiltre.fabrique.social.gouv.fr/", "documentationUrl": undefined, @@ -1082,7 +1112,8 @@ const softwares = [ "comptoirDuLibreServiceProviderCount": 1, "comptoirDuLibreId": 368, "annuaireCnllServiceProviders": [], - "wikidataId": "Q77064547", + "externalId": "Q77064547", + "externalDataOrigin": "wikidata", "license": "MIT", "officialWebsiteUrl": "https://archifiltre.fabrique.social.gouv.fr/", "documentationUrl": undefined, @@ -1127,7 +1158,8 @@ const softwares = [ "annuaireCnllServiceProviders": [], "comptoirDuLibreServiceProviderCount": 1, "comptoirDuLibreId": 368, - "wikidataId": "Q77064547", + "externalId": "Q77064547", + "externalDataOrigin": "wikidata", "license": "MIT", "officialWebsiteUrl": "https://archifiltre.fabrique.social.gouv.fr/", "documentationUrl": undefined, @@ -1172,7 +1204,8 @@ const softwares = [ "annuaireCnllServiceProviders": [], "comptoirDuLibreServiceProviderCount": 1, "comptoirDuLibreId": 368, - "wikidataId": "Q77064547", + "externalId": "Q77064547", + "externalDataOrigin": "wikidata", "license": "MIT", "officialWebsiteUrl": "https://archifiltre.fabrique.social.gouv.fr/", "documentationUrl": undefined, diff --git a/src/core/ports/SillApi.ts b/src/core/ports/SillApi.ts index 6d290728..bb171315 100644 --- a/src/core/ports/SillApi.ts +++ b/src/core/ports/SillApi.ts @@ -33,13 +33,13 @@ export type SillApi = { (): Promise; clear: () => void; }; - getWikidataOptions: ( - params: TrpcRouterInput["getWikidataOptions"] - ) => Promise; - getSoftwareFormAutoFillDataFromWikidataAndOtherSources: ( - params: TrpcRouterInput["getSoftwareFormAutoFillDataFromWikidataAndOtherSources"] + getExternalSoftwareOptions: ( + params: TrpcRouterInput["getExternalSoftwareOptions"] + ) => Promise; + getSoftwareFormAutoFillDataFromExternalSoftwareAndOtherSources: ( + params: TrpcRouterInput["getSoftwareFormAutoFillDataFromExternalSoftwareAndOtherSources"] ) => Promise< - TrpcRouterOutput["getSoftwareFormAutoFillDataFromWikidataAndOtherSources"] + TrpcRouterOutput["getSoftwareFormAutoFillDataFromExternalSoftwareAndOtherSources"] >; createSoftware: ( params: TrpcRouterInput["createSoftware"] diff --git a/src/core/usecases/instanceForm/state.ts b/src/core/usecases/instanceForm/state.ts index 08a90086..8fa8402f 100644 --- a/src/core/usecases/instanceForm/state.ts +++ b/src/core/usecases/instanceForm/state.ts @@ -7,7 +7,7 @@ import type { Language } from "@codegouvfr/sill"; export type WikidataEntry = { label: LocalizedString; description: LocalizedString; - wikidataId: string; + externalId: string; }; type State = State.NotInitialized | State.Ready; diff --git a/src/core/usecases/instanceForm/thunks.ts b/src/core/usecases/instanceForm/thunks.ts index 7d8291f6..440a3dc4 100644 --- a/src/core/usecases/instanceForm/thunks.ts +++ b/src/core/usecases/instanceForm/thunks.ts @@ -156,7 +156,7 @@ export const thunks = { "mainSoftwareSillId": step1Data.mainSoftwareSillId, organization, "otherSoftwareWikidataIds": step1Data.otherWikidataSoftwares.map( - ({ wikidataId }) => wikidataId + ({ externalId }) => externalId ), publicUrl, targetAudience diff --git a/src/core/usecases/softwareCatalog/selectors.ts b/src/core/usecases/softwareCatalog/selectors.ts index e102ef2c..27b38587 100644 --- a/src/core/usecases/softwareCatalog/selectors.ts +++ b/src/core/usecases/softwareCatalog/selectors.ts @@ -1,4 +1,5 @@ import "minimal-polyfills/Object.fromEntries"; +import type { ExternalDataOrigin } from "@codegouvfr/sill/core/ports/GetSoftwareExternalData"; import { createCompareFn } from "core/tools/compareFn"; import type { State as RootState } from "core/bootstrap"; import { createSelector } from "redux-clean-architecture"; @@ -684,15 +685,7 @@ function filterByPrerogative(params: { function apiSoftwareToInternalSoftware(params: { apiSoftwares: ApiTypes.Software[]; - softwareRef: - | { - type: "wikidataId"; - wikidataId: string; - } - | { - type: "name"; - softwareName: string; - }; + softwareRef: SoftwareRef; userDeclaration: | { isUser: boolean; @@ -707,8 +700,8 @@ function apiSoftwareToInternalSoftware(params: { switch (softwareRef.type) { case "name": return apiSoftware.softwareName === softwareRef.softwareName; - case "wikidataId": - return apiSoftware.wikidataId === softwareRef.wikidataId; + case "externalId": + return apiSoftware.externalId === softwareRef.externalId; } }); @@ -749,7 +742,7 @@ function apiSoftwareToInternalSoftware(params: { in_sill: { const software = apiSoftwares.find( - software => software.wikidataId === parentWikidataSoftware.wikidataId + software => software.externalId === parentWikidataSoftware.externalId ); if (software === undefined) { @@ -765,7 +758,7 @@ function apiSoftwareToInternalSoftware(params: { return { "isInSill": false, "softwareName": resolveLocalizedString(parentWikidataSoftware.label), - "url": `https://www.wikidata.org/wiki/${parentWikidataSoftware.wikidataId}` + "url": `https://www.wikidata.org/wiki/${parentWikidataSoftware.externalId}` }; })(); @@ -882,17 +875,20 @@ function internalSoftwareToExternalSoftware(params: { }; } +type SoftwareRef = + | { + type: "externalId"; + externalDataOrigin: ExternalDataOrigin; + externalId: string; + } + | { + type: "name"; + softwareName: string; + }; + export function apiSoftwareToExternalCatalogSoftware(params: { apiSoftwares: ApiTypes.Software[]; - softwareRef: - | { - type: "wikidataId"; - wikidataId: string; - } - | { - type: "name"; - softwareName: string; - }; + softwareRef: SoftwareRef; }): State.Software.External | undefined { const { apiSoftwares, softwareRef } = params; diff --git a/src/core/usecases/softwareCatalog/thunks.ts b/src/core/usecases/softwareCatalog/thunks.ts index 31dfdb0b..7cfeacae 100644 --- a/src/core/usecases/softwareCatalog/thunks.ts +++ b/src/core/usecases/softwareCatalog/thunks.ts @@ -204,7 +204,7 @@ function apiSoftwareToInternalSoftware(params: { case "name": return apiSoftware.softwareName === softwareRef.softwareName; case "wikidataId": - return apiSoftware.wikidataId === softwareRef.wikidataId; + return apiSoftware.externalId === softwareRef.wikidataId; } }); @@ -245,7 +245,7 @@ function apiSoftwareToInternalSoftware(params: { in_sill: { const software = apiSoftwares.find( - software => software.wikidataId === parentWikidataSoftware.wikidataId + software => software.externalId === parentWikidataSoftware.externalId ); if (software === undefined) { @@ -261,7 +261,7 @@ function apiSoftwareToInternalSoftware(params: { return { "isInSill": false, "softwareName": resolveLocalizedString(parentWikidataSoftware.label), - "url": `https://www.wikidata.org/wiki/${parentWikidataSoftware.wikidataId}` + "url": `https://www.wikidata.org/wiki/${parentWikidataSoftware.externalId}` }; })(); diff --git a/src/core/usecases/softwareDetails/thunks.ts b/src/core/usecases/softwareDetails/thunks.ts index 062de657..9666da2d 100644 --- a/src/core/usecases/softwareDetails/thunks.ts +++ b/src/core/usecases/softwareDetails/thunks.ts @@ -186,7 +186,7 @@ function apiSoftwareToSoftware(params: { comptoirDuLibreServiceProviderCount, comptoirDuLibreId, similarSoftwares: similarSoftwares_api, - wikidataId, + externalId, license, versionMin, softwareType, @@ -207,7 +207,7 @@ function apiSoftwareToSoftware(params: { in_sill: { const software = apiSoftwares.find( - software => software.wikidataId === parentWikidataSoftware_api.wikidataId + software => software.externalId === parentWikidataSoftware_api.externalId ); if (software === undefined) { @@ -223,7 +223,7 @@ function apiSoftwareToSoftware(params: { return { "isInSill": false, "softwareName": resolveLocalizedString(parentWikidataSoftware_api.label), - "url": `https://www.wikidata.org/wiki/${parentWikidataSoftware_api.wikidataId}` + "url": `https://www.wikidata.org/wiki/${parentWikidataSoftware_api.externalId}` }; })(); @@ -257,9 +257,9 @@ function apiSoftwareToSoftware(params: { ? undefined : `https://comptoir-du-libre.org/fr/softwares/${comptoirDuLibreId}`, "wikidataUrl": - wikidataId === undefined + externalId === undefined ? undefined - : `https://www.wikidata.org/wiki/${wikidataId}`, + : `https://www.wikidata.org/wiki/${externalId}`, "instances": softwareType.type !== "cloud" ? undefined @@ -285,8 +285,9 @@ function apiSoftwareToSoftware(params: { "softwareName": similarSoftware.softwareName } : { - "type": "wikidataId", - "wikidataId": similarSoftware.wikidataId + "type": "externalId", + "externalId": similarSoftware.externalId, + "externalDataOrigin": similarSoftware.externalDataOrigin } }); @@ -295,7 +296,7 @@ function apiSoftwareToSoftware(params: { return { "isInSill": false, - "wikidataId": similarSoftware.wikidataId, + "wikidataId": similarSoftware.externalId, "label": similarSoftware.label, "description": similarSoftware.description, "isLibreSoftware": similarSoftware.isLibreSoftware diff --git a/src/core/usecases/softwareForm/state.ts b/src/core/usecases/softwareForm/state.ts index 248aa22c..df1784d5 100644 --- a/src/core/usecases/softwareForm/state.ts +++ b/src/core/usecases/softwareForm/state.ts @@ -1,3 +1,4 @@ +import { ExternalDataOrigin } from "@codegouvfr/sill/core/ports/GetSoftwareExternalData"; import { createUsecaseActions } from "redux-clean-architecture"; import { id } from "tsafe/id"; import { assert } from "tsafe/assert"; @@ -27,7 +28,7 @@ export type FormData = { softwareType: ApiTypes.SoftwareType; }; step2: { - wikidataId: string | undefined; + externalId: string | undefined; comptoirDuLibreId: number | undefined; softwareName: string; softwareDescription: string; @@ -45,7 +46,8 @@ export type FormData = { similarSoftwares: { label: LocalizedString; description: LocalizedString; - wikidataId: string; + externalId: string; + externalDataOrigin: ExternalDataOrigin | undefined; }[]; }; }; @@ -73,7 +75,7 @@ export const { reducer, actions } = createUsecaseActions({ payload }: { payload: { - wikidataId: string; + externalId: string; comptoirDuLibreId: number | undefined; softwareName: string; softwareDescription: string; @@ -85,7 +87,7 @@ export const { reducer, actions } = createUsecaseActions({ } ) => { const { - wikidataId, + externalId, comptoirDuLibreId, softwareName, softwareDescription, @@ -99,7 +101,7 @@ export const { reducer, actions } = createUsecaseActions({ "stateDescription": "ready", "formData": { "step2": { - wikidataId, + externalId, comptoirDuLibreId, softwareName, softwareDescription, diff --git a/src/core/usecases/softwareForm/thunks.ts b/src/core/usecases/softwareForm/thunks.ts index 18ac0a4b..283466ad 100644 --- a/src/core/usecases/softwareForm/thunks.ts +++ b/src/core/usecases/softwareForm/thunks.ts @@ -11,7 +11,7 @@ export const thunks = { params: | { scenario: "create"; - wikidataId: string | undefined; + externalId: string | undefined; } | { scenario: "update"; @@ -34,7 +34,7 @@ export const thunks = { } } - if (params.scenario === "create" && params.wikidataId === undefined) { + if (params.scenario === "create" && params.externalId === undefined) { dispatch(actions.initializedForCreate()); return; } @@ -44,9 +44,9 @@ export const thunks = { switch (params.scenario) { case "create": { - const { wikidataId } = params; + const { externalId } = params; - assert(wikidataId !== undefined); + assert(externalId !== undefined); const { comptoirDuLibreId, @@ -56,11 +56,11 @@ export const thunks = { softwareLogoUrl, softwareMinimalVersion, softwareName - } = await dispatch(thunks.getAutofillData({ wikidataId })); + } = await dispatch(thunks.getAutofillData({ externalId })); dispatch( actions.initializedForCreateWithPreSelectedSoftware({ - wikidataId, + externalId, comptoirDuLibreId, "softwareName": softwareName ?? "", "softwareDescription": softwareDescription ?? "", @@ -90,7 +90,7 @@ export const thunks = { "softwareType": software.softwareType }, "step2": { - "wikidataId": software.wikidataId, + "externalId": software.externalId, "comptoirDuLibreId": software.comptoirDuLibreId, "softwareDescription": software.softwareDescription, @@ -124,7 +124,7 @@ export const thunks = { if ( software === undefined || - software.wikidataId === undefined + software.externalId === undefined ) { return undefined; } @@ -133,8 +133,10 @@ export const thunks = { "label": software.softwareName, "description": software.softwareDescription, - "wikidataId": software.wikidataId, - "isLibreSoftware": true + "isLibreSoftware": true, + "externalId": software.externalId, + "externalDataOrigin": + software.externalDataOrigin }; } }) @@ -208,7 +210,7 @@ export const thunks = { const formData: ApiTypes.SoftwareFormData = { "softwareType": step1.softwareType, - "wikidataId": step2.wikidataId, + "externalId": step2.externalId, "comptoirDuLibreId": step2.comptoirDuLibreId, "softwareName": step2.softwareName, "softwareDescription": step2.softwareDescription, @@ -217,8 +219,8 @@ export const thunks = { "isPresentInSupportContract": step3.isPresentInSupportContract ?? false, "isFromFrenchPublicService": step3.isFromFrenchPublicService, "doRespectRgaa": step3.doRespectRgaa, - "similarSoftwareWikidataIds": formDataStep4.similarSoftwares.map( - ({ wikidataId }) => wikidataId + "similarSoftwareExternalDataIds": formDataStep4.similarSoftwares.map( + ({ externalId }) => externalId ), "softwareLogoUrl": step2.softwareLogoUrl, "softwareKeywords": step2.softwareKeywords @@ -244,33 +246,24 @@ export const thunks = { dispatch(actions.navigatedToPreviousStep()); }, - "getLibreSoftwareWikidataOptions": + "getExternalSoftwareOptions": (props: { queryString: string; language: Language }) => async (...args) => { const { queryString, language } = props; const [, , { sillApi }] = args; - return await sillApi.getWikidataOptions({ queryString, language }); - }, - "getWikidataOptions": - (props: { queryString: string; language: Language }) => - async (...args) => { - const { queryString, language } = props; - - const [, , { sillApi }] = args; - - return await sillApi.getWikidataOptions({ queryString, language }); + return await sillApi.getExternalSoftwareOptions({ queryString, language }); }, "getAutofillData": - (props: { wikidataId: string }) => + (props: { externalId: string }) => (...args) => { - const { wikidataId } = props; + const { externalId } = props; const [, , extraArg] = args; - return extraArg.sillApi.getSoftwareFormAutoFillDataFromWikidataAndOtherSources( - { wikidataId } + return extraArg.sillApi.getSoftwareFormAutoFillDataFromExternalSoftwareAndOtherSources( + { externalId } ); } } satisfies Thunks; diff --git a/src/stories/pages/softwareForm/SoftwareForm.stories.tsx b/src/stories/pages/softwareForm/SoftwareForm.stories.tsx index 384067d1..c9dfb0f9 100644 --- a/src/stories/pages/softwareForm/SoftwareForm.stories.tsx +++ b/src/stories/pages/softwareForm/SoftwareForm.stories.tsx @@ -11,7 +11,7 @@ export default meta; export const VueCreation = getStory({ "route": createMockRoute("softwareCreationForm", { - "wikidataId": undefined + "externalId": undefined }) }); diff --git a/src/ui/pages/instanceForm/InstanceForm.tsx b/src/ui/pages/instanceForm/InstanceForm.tsx index a88b979f..8c8ff7f3 100644 --- a/src/ui/pages/instanceForm/InstanceForm.tsx +++ b/src/ui/pages/instanceForm/InstanceForm.tsx @@ -36,7 +36,7 @@ export default function InstanceForm(props: Props) { const { instanceForm, - softwareForm: { getLibreSoftwareWikidataOptions } + softwareForm: { getExternalSoftwareOptions } } = useCore().functions; const { @@ -151,7 +151,7 @@ export default function InstanceForm(props: Props) { "otherWikidataSoftwares": initializationData.otherSoftwares }} getLibreSoftwareWikidataOptions={queryString => - getLibreSoftwareWikidataOptions({ queryString, "language": lang }) + getExternalSoftwareOptions({ queryString, "language": lang }) } onSubmit={({ mainSoftwareSillId, otherWikidataSoftwares }) => instanceForm.completeStep1({ diff --git a/src/ui/pages/instanceForm/Step1.tsx b/src/ui/pages/instanceForm/Step1.tsx index bb2d87fc..11927026 100644 --- a/src/ui/pages/instanceForm/Step1.tsx +++ b/src/ui/pages/instanceForm/Step1.tsx @@ -32,7 +32,7 @@ export type Step1Props = { ) => ReturnType< ReturnType< typeof useCore - >["functions"]["softwareForm"]["getLibreSoftwareWikidataOptions"] + >["functions"]["softwareForm"]["getExternalSoftwareOptions"] >; }; diff --git a/src/ui/pages/softwareDetails/AlikeSoftwareTab.tsx b/src/ui/pages/softwareDetails/AlikeSoftwareTab.tsx index 656b8f3b..28bd73f3 100644 --- a/src/ui/pages/softwareDetails/AlikeSoftwareTab.tsx +++ b/src/ui/pages/softwareDetails/AlikeSoftwareTab.tsx @@ -21,7 +21,7 @@ export type Props = { "declarationForm" | "softwareDetails" | "softwareUsersAndReferents", Link >; - getAddWikipediaSoftwareToSillLink: (params: { wikidataId: string }) => Link; + getAddWikipediaSoftwareToSillLink: (params: { externalId: string }) => Link; }; export const SimilarSoftwareTab = (props: Props) => { @@ -153,7 +153,7 @@ export const SimilarSoftwareTab = (props: Props) => { iconId="ri-check-fill" linkProps={getAddWikipediaSoftwareToSillLink( { - wikidataId + externalId: wikidataId } )} > diff --git a/src/ui/pages/softwareDetails/SoftwareDetails.tsx b/src/ui/pages/softwareDetails/SoftwareDetails.tsx index 2a29d936..3fe07cd8 100644 --- a/src/ui/pages/softwareDetails/SoftwareDetails.tsx +++ b/src/ui/pages/softwareDetails/SoftwareDetails.tsx @@ -213,10 +213,10 @@ export default function SoftwareDetails(props: Props) { }).link })} getAddWikipediaSoftwareToSillLink={({ - wikidataId + externalId }) => routes.softwareCreationForm({ - wikidataId + externalId: externalId }).link } /> diff --git a/src/ui/pages/softwareForm/SoftwareForm.tsx b/src/ui/pages/softwareForm/SoftwareForm.tsx index 7f0d800b..5a4c09e8 100644 --- a/src/ui/pages/softwareForm/SoftwareForm.tsx +++ b/src/ui/pages/softwareForm/SoftwareForm.tsx @@ -51,7 +51,7 @@ export default function SoftwareForm(props: Props) { case "softwareCreationForm": return { "scenario": "create", - "wikidataId": route.params.wikidataId + "externalId": route.params.externalId }; case "softwareUpdateForm": return { @@ -172,7 +172,7 @@ export default function SoftwareForm(props: Props) { } getAutofillDataFromWikidata={softwareForm.getAutofillData} getLibreSoftwareWikidataOptions={queryString => - softwareForm.getLibreSoftwareWikidataOptions({ + softwareForm.getExternalSoftwareOptions({ "language": lang, queryString }) @@ -200,8 +200,11 @@ export default function SoftwareForm(props: Props) { "formDataStep4": formData }) } - getWikidataOptions={queryString => - softwareForm.getWikidataOptions({ "language": lang, queryString }) + getExternalSoftwareOptions={queryString => + softwareForm.getExternalSoftwareOptions({ + "language": lang, + queryString + }) } /> diff --git a/src/ui/pages/softwareForm/Step2.tsx b/src/ui/pages/softwareForm/Step2.tsx index 9d2c94fb..3a10b443 100644 --- a/src/ui/pages/softwareForm/Step2.tsx +++ b/src/ui/pages/softwareForm/Step2.tsx @@ -29,7 +29,7 @@ export type Step2Props = { ReturnType< ReturnType< typeof useCore - >["functions"]["softwareForm"]["getLibreSoftwareWikidataOptions"] + >["functions"]["softwareForm"]["getExternalSoftwareOptions"] > >; }; @@ -73,16 +73,16 @@ export function SoftwareFormStep2(props: Step2Props) { return undefined; } - const { comptoirDuLibreId, wikidataId, softwareKeywords, ...rest } = + const { comptoirDuLibreId, externalId, softwareKeywords, ...rest } = initialFormData ?? {}; return { ...rest, "wikidataEntry": - wikidataId === undefined + externalId === undefined ? undefined : { - wikidataId, + externalId, "description": "", "label": rest.softwareName }, @@ -134,7 +134,7 @@ export function SoftwareFormStep2(props: Step2Props) { softwareMinimalVersion, softwareLogoUrl } = await getAutofillDataFromWikidata({ - "wikidataId": wikiDataEntry.wikidataId + "externalId": wikiDataEntry.externalId }); if (!isActive) { @@ -214,7 +214,7 @@ export function SoftwareFormStep2(props: Step2Props) { : comptoirDuLibreInputValueToComptoirDuLibreId( comptoirDuLibreIdInputValue ), - "wikidataId": wikidataEntry?.wikidataId + "externalId": wikidataEntry?.externalId }) )} > @@ -233,7 +233,7 @@ export function SoftwareFormStep2(props: Step2Props) { resolveLocalizedString(wikidataEntry.label) } renderOption={(liProps, wikidataEntity) => ( -
  • +
  • {resolveLocalizedString(wikidataEntity.label)} diff --git a/src/ui/pages/softwareForm/Step4.tsx b/src/ui/pages/softwareForm/Step4.tsx index 8bcd7644..79d4b945 100644 --- a/src/ui/pages/softwareForm/Step4.tsx +++ b/src/ui/pages/softwareForm/Step4.tsx @@ -15,18 +15,25 @@ export type Step4Props = { initialFormData: FormData["step4"] | undefined; onSubmit: (formData: FormData["step4"]) => void; evtActionSubmit: NonPostableEvt; - getWikidataOptions: ( + getExternalSoftwareOptions: ( queryString: string ) => Promise< ReturnType< - ReturnType["functions"]["softwareForm"]["getWikidataOptions"] + ReturnType< + typeof useCore + >["functions"]["softwareForm"]["getExternalSoftwareOptions"] > >; }; export function SoftwareFormStep4(props: Step4Props) { - const { className, initialFormData, onSubmit, evtActionSubmit, getWikidataOptions } = - props; + const { + className, + initialFormData, + onSubmit, + evtActionSubmit, + getExternalSoftwareOptions + } = props; const { t } = useTranslation({ SoftwareFormStep4 }); const { handleSubmit, control } = useForm({ @@ -70,7 +77,7 @@ export function SoftwareFormStep4(props: Step4Props) { render={({ field }) => ( field.onChange(value)} getOptionLabel={wikidataEntry => diff --git a/src/ui/pages/softwareForm/route.ts b/src/ui/pages/softwareForm/route.ts index 7ecacc4c..7502c7a0 100644 --- a/src/ui/pages/softwareForm/route.ts +++ b/src/ui/pages/softwareForm/route.ts @@ -3,7 +3,7 @@ import { appPath } from "urls"; export const routeDefs = { "softwareCreationForm": defineRoute( - { "wikidataId": param.query.optional.string }, + { "externalId": param.query.optional.string }, () => appPath + "/add" ), "softwareUpdateForm": defineRoute( From aae049160a6d392f48ebbd294db51af787e0975d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Burkard?= <22095555+JeromeBu@users.noreply.github.com> Date: Fri, 16 Feb 2024 17:34:22 +0100 Subject: [PATCH 2/2] bump version --- package.json | 2 +- yarn.lock | 54 +++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index d2768dab..5f7a4587 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ }, "dependencies": { "@codegouvfr/react-dsfr": "^1.0.0", - "@codegouvfr/sill": "^1.19.1", + "@codegouvfr/sill": "^1.20.0", "@emotion/react": "^11.11.0", "@emotion/styled": "^11.11.0", "@mui/icons-material": "^5.0.4", diff --git a/yarn.lock b/yarn.lock index af8ef2fc..ac5d2193 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1150,6 +1150,14 @@ resolved "https://registry.yarnpkg.com/@babel/regjsgen/-/regjsgen-0.8.0.tgz#f0ba69b075e1f05fb2825b7fad991e7adbb18310" integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA== +"@babel/runtime-corejs3@^7.16.5": + version "7.23.9" + resolved "https://registry.yarnpkg.com/@babel/runtime-corejs3/-/runtime-corejs3-7.23.9.tgz#1b43062a13ecb60158aecdd81bc3fab4108b7cbc" + integrity sha512-oeOFTrYWdWXCvXGB5orvMTJ6gCZ9I6FBjR+M38iKNXCsPxr4xT0RTdg5uz1H7QP8pp74IzPtwritEr+JscqHXQ== + dependencies: + core-js-pure "^3.30.2" + regenerator-runtime "^0.14.0" + "@babel/runtime@^7.0.0", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.16.3", "@babel/runtime@^7.17.8", "@babel/runtime@^7.18.3", "@babel/runtime@^7.20.7", "@babel/runtime@^7.21.0", "@babel/runtime@^7.5.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": version "7.21.0" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.21.0.tgz#5b55c9d394e5fcf304909a8b00c07dc217b56673" @@ -1232,16 +1240,17 @@ dependencies: tsafe "^1.6.3" -"@codegouvfr/sill@^1.19.1": - version "1.19.1" - resolved "https://registry.yarnpkg.com/@codegouvfr/sill/-/sill-1.19.1.tgz#b2e7b966c2098ba0de10c165f82f6f209f4b3a51" - integrity sha512-JI8h0qqY5TNdYJHNRHlqmGSfyLM0GpSbJiMFaNVOLUEO89tZDQgz/+sYmfw7XfUsbegby4JYtNwhlcyWUj11OQ== +"@codegouvfr/sill@^1.20.0": + version "1.20.0" + resolved "https://registry.yarnpkg.com/@codegouvfr/sill/-/sill-1.20.0.tgz#19508b5a58b86d6151f71bc78c7f34140d51e765" + integrity sha512-73fLogw9K1cEHQqwurgfq8peobJoJlz5lrSQAxhF759gm6sCQym4N/srOCJiGKE5xwqaDroQ8LvTKpGtjihdpQ== dependencies: "@octokit/graphql" "^7.0.2" + "@retorquere/bibtex-parser" "^7.0.11" "@trpc/server" "^10.18.0" jwt-decode "^3.1.2" semver "^7.5.4" - tsafe "^1.6.0" + tsafe "^1.6.6" zod "^3.21.4" "@colors/colors@1.5.0": @@ -2279,6 +2288,14 @@ redux-thunk "^2.4.2" reselect "^4.1.8" +"@retorquere/bibtex-parser@^7.0.11": + version "7.0.12" + resolved "https://registry.yarnpkg.com/@retorquere/bibtex-parser/-/bibtex-parser-7.0.12.tgz#2cfd463555f51fe3c63e72df761711c30a9ac1cd" + integrity sha512-Eb8o7Nyk1gAZ2qeZS3Ur5YyjMzqUXf+rqsH3EauJxTQYbeQXyx+tpv0QGraGxtMAelKDDJY8fTYYsdNRKhdgQA== + dependencies: + unicode2latex "^4.0.42" + xregexp "^5.1.1" + "@rollup/plugin-babel@^5.2.0": version "5.3.1" resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz#04bc0608f4aa4b2e4b1aebf284344d0f68fda283" @@ -6194,6 +6211,11 @@ core-js-pure@^3.23.3: resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.29.1.tgz#1be6ca2b8772f6b4df7fc4621743286e676c6162" integrity sha512-4En6zYVi0i0XlXHVz/bi6l1XDjCqkKRq765NXuX+SnaIatlE96Odt5lMLjdxUiNI1v9OXI5DSLWYPlmTfkTktg== +core-js-pure@^3.30.2: + version "3.36.0" + resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.36.0.tgz#ffb34330b14e594d6a9835cf5843b4123f1d95db" + integrity sha512-cN28qmhRNgbMZZMc/RFu5w8pK9VJzpb2rJVR/lHuZJKwmXnoWOpXmMkxqBB514igkp1Hu8WGROsiOAzUcKdHOQ== + core-js@^3.0.4, core-js@^3.19.2, core-js@^3.6.5, core-js@^3.8.2: version "3.29.1" resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.29.1.tgz#40ff3b41588b091aaed19ca1aa5cb111803fa9a6" @@ -14089,6 +14111,11 @@ regenerator-runtime@^0.13.11, regenerator-runtime@^0.13.7, regenerator-runtime@^ resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9" integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg== +regenerator-runtime@^0.14.0: + version "0.14.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz#356ade10263f685dda125100cd862c1db895327f" + integrity sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw== + regenerator-transform@^0.15.1: version "0.15.1" resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.15.1.tgz#f6c4e99fc1b4591f780db2586328e4d9a9d8dc56" @@ -16066,6 +16093,11 @@ tsafe@^1.6.5: resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-1.6.5.tgz#74943b69190069168a53d2accd6d07891cf1cce8" integrity sha512-895zss8xqqHKTc28sHGIfZKnt3C5jrstB1DyPr/h3/flK0zojsZUMQL1/W4ytdDW6KI4Oth62nb9rrxmA3s3Iw== +tsafe@^1.6.6: + version "1.6.6" + resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-1.6.6.tgz#fd93e64d6eb13ef83ed1650669cc24bad4f5df9f" + integrity sha512-gzkapsdbMNwBnTIjgO758GujLCj031IgHK/PKr2mrmkCSJMhSOR5FeOuSxKLMUoYc0vAA4RGEYYbjt/v6afD3g== + tsconfig-paths@^3.14.1: version "3.14.2" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz#6e32f1f79412decd261f92d633a9dc1cfa99f088" @@ -16253,6 +16285,11 @@ unicode-property-aliases-ecmascript@^2.0.0: resolved "https://registry.yarnpkg.com/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-2.1.0.tgz#43d41e3be698bd493ef911077c9b131f827e8ccd" integrity sha512-6t3foTQI9qne+OZoVQB/8x8rk2k1eVy1gRXhV3oFQ5T6R1dqQ1xtin3XqSlx3+ATBkliTaR/hHyJBm+LVPNM8w== +unicode2latex@^4.0.42: + version "4.0.44" + resolved "https://registry.yarnpkg.com/unicode2latex/-/unicode2latex-4.0.44.tgz#047ed4030b889a5cb6c51aacaa8aad19d0a88b04" + integrity sha512-5Usk2xJw+2a/o37E7qkcwIfLpZfPYzURPEnlqpf26er/K2mXB1ucUO+oJnhoPsGyQYYqSub7p5cTpkKDbkleoA== + unified@9.2.0: version "9.2.0" resolved "https://registry.yarnpkg.com/unified/-/unified-9.2.0.tgz#67a62c627c40589edebbf60f53edfd4d822027f8" @@ -17388,6 +17425,13 @@ xmlchars@^2.2.0: resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb" integrity sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw== +xregexp@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-5.1.1.tgz#6d3fe18819e3143aaf52f9284d34f49a59583ebb" + integrity sha512-fKXeVorD+CzWvFs7VBuKTYIW63YD1e1osxwQ8caZ6o1jg6pDAbABDG54LCIq0j5cy7PjRvGIq6sef9DYPXpncg== + dependencies: + "@babel/runtime-corejs3" "^7.16.5" + xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1: version "4.0.2" resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"