diff --git a/package.json b/package.json index bca012f23..0078db7d5 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,7 @@ "cozy-minilog": "^3.3.1", "cozy-realtime": "3.14.4", "cozy-stack-client": "^48.16.0", - "cozy-ui": "^111.12.0", + "cozy-ui": "^111.13.0", "emoji-js": "3.7.0", "focus-trap-react": "4.0.1", "fuse.js": "6.5.3", diff --git a/src/ducks/AlternativeStore/tests/transformData.spec.ts b/src/ducks/AlternativeStore/tests/transformData.spec.ts index daa6853ee..ba52c4962 100644 --- a/src/ducks/AlternativeStore/tests/transformData.spec.ts +++ b/src/ducks/AlternativeStore/tests/transformData.spec.ts @@ -3,23 +3,47 @@ import { transformData } from 'ducks/AlternativeStore/transformData' import { AlternativeShortcut } from 'ducks/AlternativeStore/types' describe('transformData', () => { - test('categorizes files correctly based on metadata type and path', () => { + test('categorizes files correctly based on metadata category and path', () => { const data: AlternativeShortcut[] = [ { id: '01904ab1-f1fd-7243-b39b-37fe73b5579a', - metadata: { type: 'perso' }, + metadata: { + target: { + category: 'perso', + description: 'Description for I-Paf' + }, + externalDataSource: { + source: 'Developer A' + } + }, path: '/Settings/Home/Barfoo/I-Paf.url', name: 'I-Paf' }, { id: '01904ab2-20a9-7243-9972-df18c9c671d3', - metadata: { type: 'foobaz' }, + metadata: { + target: { + category: 'foobaz', + description: 'Description for Gestion des dossiers publidoc' + }, + externalDataSource: { + source: 'Developer B' + } + }, path: '/Settings/Home/Foobaz/Gestion des dossiers publidoc.url', name: 'Gestion des dossiers publidoc' }, { id: '01904ab2-2633-7243-9774-dc81fb0bc46a', - metadata: { type: 'quxbaz' }, + metadata: { + target: { + category: 'quxbaz', + description: 'Description for M@gistère' + }, + externalDataSource: { + source: 'Developer C' + } + }, path: '/Settings/Home/Barfoo/M@gistère.url', name: 'M@gistère' } @@ -28,30 +52,60 @@ describe('transformData', () => { const expected = [ { id: '01904ab1-f1fd-7243-b39b-37fe73b5579a', - metadata: { type: 'perso' }, + metadata: { + target: { + category: 'perso', + description: 'Description for I-Paf' + }, + externalDataSource: { + source: 'Developer A' + } + }, path: '/Settings/Home/Barfoo/I-Paf.url', installed: true, categories: ['barfoo'], slug: '01904ab1-f1fd-7243-b39b-37fe73b5579a', - name: 'I-Paf' + name: 'I-Paf', + long_description: 'Description for I-Paf', + developer: { name: 'Developer A' } }, { id: '01904ab2-20a9-7243-9972-df18c9c671d3', - metadata: { type: 'foobaz' }, + metadata: { + target: { + category: 'foobaz', + description: 'Description for Gestion des dossiers publidoc' + }, + externalDataSource: { + source: 'Developer B' + } + }, path: '/Settings/Home/Foobaz/Gestion des dossiers publidoc.url', installed: true, categories: ['foobaz'], slug: '01904ab2-20a9-7243-9972-df18c9c671d3', - name: 'Gestion des dossiers publidoc' + name: 'Gestion des dossiers publidoc', + long_description: 'Description for Gestion des dossiers publidoc', + developer: { name: 'Developer B' } }, { id: '01904ab2-2633-7243-9774-dc81fb0bc46a', - metadata: { type: 'quxbaz' }, + metadata: { + target: { + category: 'quxbaz', + description: 'Description for M@gistère' + }, + externalDataSource: { + source: 'Developer C' + } + }, path: '/Settings/Home/Barfoo/M@gistère.url', installed: true, categories: ['barfoo'], slug: '01904ab2-2633-7243-9774-dc81fb0bc46a', - name: 'M@gistère' + name: 'M@gistère', + long_description: 'Description for M@gistère', + developer: { name: 'Developer C' } } ] @@ -63,13 +117,29 @@ describe('transformData', () => { const data: AlternativeShortcut[] = [ { id: '01908039-3b2c-7852-b4bd-1d768199c89c', - metadata: { type: 'foobaz' }, + metadata: { + target: { + category: 'foobaz', + description: 'Description for quxbaz' + }, + externalDataSource: { + source: 'Developer D' + } + }, path: '/Settings/Home/Applications Foobar/Store Foobar/quxbaz.url', name: 'quxbaz' }, { id: '01908039-3b2c-7852-b4bd-1d768199c89d', - metadata: { type: 'other' }, + metadata: { + target: { + category: 'other', + description: 'Description for OtherFile' + }, + externalDataSource: { + source: 'Developer E' + } + }, path: '/Settings/Home/Applications Foobar/Store Foobar/OtherFile.url', name: 'OtherFile' } @@ -78,21 +148,41 @@ describe('transformData', () => { const expected = [ { id: '01908039-3b2c-7852-b4bd-1d768199c89c', - metadata: { type: 'foobaz' }, + metadata: { + target: { + category: 'foobaz', + description: 'Description for quxbaz' + }, + externalDataSource: { + source: 'Developer D' + } + }, path: '/Settings/Home/Applications Foobar/Store Foobar/quxbaz.url', installed: false, categories: ['foobaz'], slug: '01908039-3b2c-7852-b4bd-1d768199c89c', - name: 'quxbaz' + name: 'quxbaz', + long_description: 'Description for quxbaz', + developer: { name: 'Developer D' } }, { id: '01908039-3b2c-7852-b4bd-1d768199c89d', - metadata: { type: 'other' }, + metadata: { + target: { + category: 'other', + description: 'Description for OtherFile' + }, + externalDataSource: { + source: 'Developer E' + } + }, path: '/Settings/Home/Applications Foobar/Store Foobar/OtherFile.url', installed: false, categories: ['alternativeStore'], slug: '01908039-3b2c-7852-b4bd-1d768199c89d', - name: 'OtherFile' + name: 'OtherFile', + long_description: 'Description for OtherFile', + developer: { name: 'Developer E' } } ] @@ -100,42 +190,76 @@ describe('transformData', () => { expect(result).toEqual(expected) }) - test('handles files with no metadata type or undefined type', () => { + test('handles files with no metadata category or undefined category', () => { const data: AlternativeShortcut[] = [ { id: '01908039-3b2c-7852-b4bd-1d768199c890', - metadata: {}, - path: '/Settings/Home/Foobaz/NoType.url', - name: 'NoType' + metadata: { + target: { + description: 'Description for NoCategory' + }, + externalDataSource: { + source: 'Developer F' + } + }, + path: '/Settings/Home/Foobaz/NoCategory.url', + name: 'NoCategory' }, { id: '01908039-3b2c-7852-b4bd-1d768199c891', - metadata: { type: undefined }, + metadata: { + target: { + category: undefined, + description: 'Description for UndefinedCategory' + }, + externalDataSource: { + source: 'Developer G' + } + }, path: - '/Settings/Home/Applications Foobar/Store Foobar/UndefinedType.url', - name: 'UndefinedType' + '/Settings/Home/Applications Foobar/Store Foobar/UndefinedCategory.url', + name: 'UndefinedCategory' } ] as AlternativeShortcut[] const expected = [ { id: '01908039-3b2c-7852-b4bd-1d768199c890', - metadata: {}, - path: '/Settings/Home/Foobaz/NoType.url', + metadata: { + target: { + description: 'Description for NoCategory' + }, + externalDataSource: { + source: 'Developer F' + } + }, + path: '/Settings/Home/Foobaz/NoCategory.url', installed: true, categories: ['alternativeStore'], - name: 'NoType', - slug: '01908039-3b2c-7852-b4bd-1d768199c890' + name: 'NoCategory', + slug: '01908039-3b2c-7852-b4bd-1d768199c890', + long_description: 'Description for NoCategory', + developer: { name: 'Developer F' } }, { id: '01908039-3b2c-7852-b4bd-1d768199c891', - metadata: { type: undefined }, + metadata: { + target: { + category: undefined, + description: 'Description for UndefinedCategory' + }, + externalDataSource: { + source: 'Developer G' + } + }, path: - '/Settings/Home/Applications Foobar/Store Foobar/UndefinedType.url', + '/Settings/Home/Applications Foobar/Store Foobar/UndefinedCategory.url', installed: false, categories: ['alternativeStore'], - name: 'UndefinedType', - slug: '01908039-3b2c-7852-b4bd-1d768199c891' + name: 'UndefinedCategory', + slug: '01908039-3b2c-7852-b4bd-1d768199c891', + long_description: 'Description for UndefinedCategory', + developer: { name: 'Developer G' } } ] @@ -147,7 +271,15 @@ describe('transformData', () => { const data: AlternativeShortcut[] = [ { id: '01908039-3b2c-7852-b4bd-1d768199c892', - metadata: { type: 'unknown' }, + metadata: { + target: { + category: 'unknown', + description: 'Description for Unknown' + }, + externalDataSource: { + source: 'Developer H' + } + }, path: '/ultra/bogus/path', name: 'Unknown' } @@ -163,19 +295,42 @@ describe('transformData', () => { const data: AlternativeShortcut[] = [ { id: '01908039-3b2c-7852-b4bd-1d768199c89c', - metadata: { type: 'foobaz' }, + metadata: { + target: { + category: 'foobaz', + description: 'Description for quxbaz' + }, + externalDataSource: { + source: 'Developer I' + } + }, path: '/Settings/Home/Applications Foobar/Store Foobar/quxbaz.url', name: 'quxbaz' }, { id: '01908039-3b2c-7852-b4bd-1d768199c890', - metadata: {}, + metadata: { + target: { + description: 'Description for NoType' + }, + externalDataSource: { + source: 'Developer J' + } + }, path: '/Settings/Home/Foobaz/NoType.url', name: 'NoType' }, { id: '01908039-3b2c-7852-b4bd-1d768199c892', - metadata: { type: 'unknown' }, + metadata: { + target: { + category: 'unknown', + description: 'Description for Unknown' + }, + externalDataSource: { + source: 'Developer K' + } + }, path: '/Settings/Home/Applications Foobar/Store Foobar/Unknown.url', name: 'Unknown' } @@ -184,30 +339,59 @@ describe('transformData', () => { const expected = [ { id: '01908039-3b2c-7852-b4bd-1d768199c89c', - metadata: { type: 'foobaz' }, + metadata: { + target: { + category: 'foobaz', + description: 'Description for quxbaz' + }, + externalDataSource: { + source: 'Developer I' + } + }, path: '/Settings/Home/Applications Foobar/Store Foobar/quxbaz.url', installed: false, categories: ['foobaz'], slug: '01908039-3b2c-7852-b4bd-1d768199c89c', - name: 'quxbaz' + name: 'quxbaz', + long_description: 'Description for quxbaz', + developer: { name: 'Developer I' } }, { id: '01908039-3b2c-7852-b4bd-1d768199c890', - metadata: {}, + metadata: { + target: { + description: 'Description for NoType' + }, + externalDataSource: { + source: 'Developer J' + } + }, path: '/Settings/Home/Foobaz/NoType.url', installed: true, categories: ['alternativeStore'], name: 'NoType', - slug: '01908039-3b2c-7852-b4bd-1d768199c890' + slug: '01908039-3b2c-7852-b4bd-1d768199c890', + long_description: 'Description for NoType', + developer: { name: 'Developer J' } }, { id: '01908039-3b2c-7852-b4bd-1d768199c892', - metadata: { type: 'unknown' }, + metadata: { + target: { + category: 'unknown', + description: 'Description for Unknown' + }, + externalDataSource: { + source: 'Developer K' + } + }, path: '/Settings/Home/Applications Foobar/Store Foobar/Unknown.url', installed: false, categories: ['alternativeStore'], name: 'Unknown', - slug: '01908039-3b2c-7852-b4bd-1d768199c892' + slug: '01908039-3b2c-7852-b4bd-1d768199c892', + long_description: 'Description for Unknown', + developer: { name: 'Developer K' } } ] diff --git a/src/ducks/AlternativeStore/transformData.ts b/src/ducks/AlternativeStore/transformData.ts index 0985bf726..86fce1a46 100644 --- a/src/ducks/AlternativeStore/transformData.ts +++ b/src/ducks/AlternativeStore/transformData.ts @@ -33,8 +33,7 @@ export const transformData = ( return isStorePath || matchesCategoryPath }) .map(file => { - // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment - const metadataType = file.metadata.type ?? 'default' + const metadataCategory = file.metadata.target?.category ?? 'default' const filePath = file.path if (!filePath) return file @@ -42,12 +41,13 @@ export const transformData = ( const isStorePath = filePath.startsWith(config.store) // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - let category = fileTypeMappings[metadataType] || fileTypeMappings.default + let category = + fileTypeMappings[metadataCategory] || fileTypeMappings.default // If the file is not in the store path and no specific category was found based on metadata type, // determine the category based on the file path // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - if (!isStorePath && !fileTypeMappings[metadataType]) { + if (!isStorePath && !fileTypeMappings[metadataCategory]) { for (const [path, cat] of Object.entries(categoryPathMap)) { if (filePath.startsWith(path)) { category = cat @@ -59,9 +59,13 @@ export const transformData = ( return { ...file, name: file.name.replace('.url', ''), + long_description: file.metadata.target?.description, installed: !isStorePath, categories: [category], - slug: file.id // This is much easier than refactoring the whole app + slug: file.id, // This is much easier than refactoring the whole app + developer: { + name: file.metadata.externalDataSource?.source + } } }) } diff --git a/src/ducks/AlternativeStore/types/index.ts b/src/ducks/AlternativeStore/types/index.ts index 7c7ebc112..6ea79fd49 100644 --- a/src/ducks/AlternativeStore/types/index.ts +++ b/src/ducks/AlternativeStore/types/index.ts @@ -8,4 +8,8 @@ export interface AlternativeStoreConfig { export interface AlternativeShortcut extends IOCozyFile { installed?: boolean + long_description?: string + developer?: { + name?: string + } } diff --git a/src/ducks/apps/components/ApplicationPage/Details.jsx b/src/ducks/apps/components/ApplicationPage/Details.jsx index 2da13ca60..d6e4877fa 100644 --- a/src/ducks/apps/components/ApplicationPage/Details.jsx +++ b/src/ducks/apps/components/ApplicationPage/Details.jsx @@ -1,9 +1,6 @@ import androidIcon from 'assets/icons/platforms/icon-android.svg' import iosIcon from 'assets/icons/platforms/icon-ios.svg' -import { - isAppOrKonnectorFile, - isShortcutFile -} from 'ducks/AlternativeStore/helpers' +import { isAppOrKonnectorFile } from 'ducks/AlternativeStore/helpers' import { getContext, REGISTRY_CHANNELS } from 'ducks/apps' import { isUnderMaintenance } from 'ducks/apps/appStatus' import Maintenance from 'ducks/apps/components/ApplicationPage/Maintenance' @@ -52,11 +49,9 @@ export const Details = ({ app, description, changes, parent, mobileApps }) => { !!categories.length && categories.map(c => t(`app_categories.${c}`)) const developerName = - (developer && getTranslatedManifestProperty(app, 'developer.name', t)) || - (isShortcutFile(app) && app.attributes?.metadata?.source) + developer && getTranslatedManifestProperty(app, 'developer.name', t) const developerUrl = - (developer && getTranslatedManifestProperty(app, 'developer.url', t)) || - app.attributes?.metadata?.url + developer && getTranslatedManifestProperty(app, 'developer.url', t) const shortVersion = version && version.match(/^(\d+\.\d+\.\d+)-.*$/) const displayedVersion = ((shortVersion && shortVersion.length && shortVersion[1]) || version) ?? '-' // If no version, display a dash diff --git a/src/ducks/apps/components/ApplicationPage/index.jsx b/src/ducks/apps/components/ApplicationPage/index.jsx index 7e8cd2f44..c17225b89 100644 --- a/src/ducks/apps/components/ApplicationPage/index.jsx +++ b/src/ducks/apps/components/ApplicationPage/index.jsx @@ -1,4 +1,3 @@ -import { isShortcutFile } from 'ducks/AlternativeStore/helpers' import { getAppIconProps } from 'ducks/apps' import Details from 'ducks/apps/components/ApplicationPage/Details' import Gallery from 'ducks/apps/components/ApplicationPage/Gallery' @@ -110,10 +109,12 @@ export class ApplicationPage extends Component { 'short_description', t ) - const appLongDesc = - getTranslatedManifestProperty(app, 'long_description', t) || - (isShortcutFile(app) && app.attributes?.metadata?.source) || - '' + const appLongDesc = getTranslatedManifestProperty( + app, + 'long_description', + t + ) + const appChanges = getTranslatedManifestProperty(app, 'changes', t) const mobileApps = app.platforms && diff --git a/src/locales/en.json b/src/locales/en.json index 548f7ab36..17118c385 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -114,7 +114,6 @@ "sections": { "applications": "Applications", "konnectors": "Services", - "shortcuts": "Shortcuts", "filters": { "action": "Filter", "under_maintenance": { @@ -161,7 +160,7 @@ "tech": "Tech", "clouds": "Clouds and vaults", "finance": "Employment and finance", - "shortcuts": "Shortcuts" + "shortcuts": "Additional apps" }, "app_langs": { "list_separator": ", ", diff --git a/src/locales/fr.json b/src/locales/fr.json index 8ad69c4e5..f07aa28e7 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -114,7 +114,6 @@ "sections": { "applications": "Applications", "konnectors": "Services", - "shortcuts": "Raccourcis", "filters": { "action": "Filtrer", "under_maintenance": { @@ -161,7 +160,7 @@ "tech": "Tech", "clouds": "Clouds & coffres", "finance": "Emploi & finance", - "shortcuts": "Raccourcis" + "shortcuts": "App supplémentaires" }, "app_langs": { "list_separator": ", ", diff --git a/yarn.lock b/yarn.lock index 86e4f553c..d15f17fea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5551,10 +5551,10 @@ cozy-tsconfig@^1.2.0: resolved "https://registry.yarnpkg.com/cozy-tsconfig/-/cozy-tsconfig-1.2.0.tgz#17e61f960f139fae4d26cbac2254b9ab632b269e" integrity sha512-TRHnY9goF3FzVlUbP7BcHxuN2XAA4AmppT4fHHZmTKaSwYTByVR1Al+riFMDbce94kJZ1wzl9WNLWQuqzGZ6Cw== -cozy-ui@^111.12.0: - version "111.12.0" - resolved "https://registry.yarnpkg.com/cozy-ui/-/cozy-ui-111.12.0.tgz#c0db5fa110037ab0c3d364a55adf504091b4fb98" - integrity sha512-JmQUA9ysnJWsSf4eaVqdaMYV8IgmzNVOlVLwMSVCRzs5lerRnVZZ3KDBW78pyrx4Au6k0ijnAct3su5hUOTldA== +cozy-ui@^111.13.0: + version "111.13.0" + resolved "https://registry.yarnpkg.com/cozy-ui/-/cozy-ui-111.13.0.tgz#5875d405e451037a9597e2b7882f3c1ee5b3aef6" + integrity sha512-qg6ocCHVyFqosHzlX4RCWSW+Nz3/a645y+E+MfPa3wWsKo3+C5YjWFACMO+P14IkoM2uDy/rxLHOBEsogUYE6g== dependencies: "@babel/runtime" "^7.3.4" "@material-ui/core" "4.12.3" @@ -11125,9 +11125,9 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -"mui-bottom-sheet@https://github.com/cozy/mui-bottom-sheet.git#v1.0.9": +"mui-bottom-sheet@git+https://github.com/cozy/mui-bottom-sheet.git#v1.0.9": version "1.0.8" - resolved "https://github.com/cozy/mui-bottom-sheet.git#3dc4c2a245ab39079bc2f73546bccf80847be14c" + resolved "git+https://github.com/cozy/mui-bottom-sheet.git#3dc4c2a245ab39079bc2f73546bccf80847be14c" dependencies: "@juggle/resize-observer" "^3.1.3" jest-environment-jsdom-sixteen "^1.0.3"