Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SCR-842] feat: Reorganize shortcuts metadata structure #482

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions src/CozyUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,19 @@ class CozyUtils {
shouldReplaceFile: () => true,
fileAttributes: {
metadata: {
...file
target: {
title: file.title,
description: file.description,
category: file.type
},
externalDataSource: {
networkAccess: file.networkAccess,
source: file.source,
hubMetadata: {
...file.hubMetadata
}
},
icon: file.icon
}
}
}
Expand Down Expand Up @@ -214,7 +226,19 @@ class CozyUtils {
shouldReplaceFile: () => true,
fileAttributes: {
metadata: {
...file
target: {
title: file.title,
description: file.description,
category: file.type
},
externalDataSource: {
networkAccess: file.networkAccess,
source: file.source,
hubMetadata: {
...file.hubMetadata
}
},
icon: file.icon
}
}
}
Expand All @@ -238,7 +262,7 @@ class CozyUtils {
}
}
for (const app of rightContentStore) {
switch (app.fileAttributes.metadata.type) {
switch (app.fileAttributes.metadata.target.category) {
case 'info':
log('info', 'Info shortcut')
infosShortcuts.push(app)
Expand Down Expand Up @@ -306,8 +330,8 @@ class CozyUtils {
let idx = allComputedShortcuts.findIndex(apiShortcut => {
return (
apiShortcut.vendorRef === cozyShortcut.metadata.fileIdAttributes &&
apiShortcut.fileAttributes?.metadata?.hubMetadata?.favori ===
isFavourite
apiShortcut.fileAttributes?.metadata?.externalDataSource?.hubMetadata
?.favori === isFavourite
)
})
if (idx == -1) {
Expand Down
72 changes: 48 additions & 24 deletions src/cozyUtils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,10 @@ describe('CozyUtils', () => {
vendorRef: 'SOME_OTHER_VALUE',
fileAttributes: {
metadata: {
hubMetadata: {
favori: false
externalDataSource: {
hubMetadata: {
favori: false
}
}
}
}
Expand All @@ -490,8 +492,10 @@ describe('CozyUtils', () => {
vendorRef: 'SOME_VALUE_2',
fileAttributes: {
metadata: {
hubMetadata: {
favori: false
externalDataSource: {
hubMetadata: {
favori: false
}
}
}
}
Expand Down Expand Up @@ -572,8 +576,10 @@ describe('CozyUtils', () => {
vendorRef: 'SOME_OTHER_VALUE',
fileAttributes: {
metadata: {
hubMetadata: {
favori: false
externalDataSource: {
hubMetadata: {
favori: false
}
}
}
}
Expand All @@ -584,8 +590,10 @@ describe('CozyUtils', () => {
vendorRef: 'SOME_VALUE_2',
fileAttributes: {
metadata: {
hubMetadata: {
favori: true
externalDataSource: {
hubMetadata: {
favori: true
}
}
}
}
Expand Down Expand Up @@ -665,8 +673,10 @@ describe('CozyUtils', () => {
vendorRef: 'SOME_OTHER_VALUE',
fileAttributes: {
metadata: {
hubMetadata: {
favori: false
externalDataSource: {
hubMetadata: {
favori: false
}
}
}
}
Expand All @@ -678,8 +688,10 @@ describe('CozyUtils', () => {
vendorRef: 'SOME_VALUE_2',
fileAttributes: {
metadata: {
hubMetadata: {
favori: true
externalDataSource: {
hubMetadata: {
favori: true
}
}
}
}
Expand Down Expand Up @@ -772,8 +784,10 @@ describe('CozyUtils', () => {
vendorRef: 'SOME_VALUE_2',
fileAttributes: {
metadata: {
hubMetadata: {
favori: true
externalDataSource: {
hubMetadata: {
favori: true
}
}
}
}
Expand Down Expand Up @@ -851,8 +865,10 @@ describe('CozyUtils', () => {
vendorRef: 'SOME_OTHER_VALUE',
fileAttributes: {
metadata: {
hubMetadata: {
favori: false
externalDataSource: {
hubMetadata: {
favori: false
}
}
}
}
Expand All @@ -866,8 +882,10 @@ describe('CozyUtils', () => {
vendorRef: 'SOME_VALUE_2',
fileAttributes: {
metadata: {
hubMetadata: {
favori: true
externalDataSource: {
hubMetadata: {
favori: true
}
}
}
}
Expand Down Expand Up @@ -944,8 +962,10 @@ describe('CozyUtils', () => {
vendorRef: 'SOME_VALUE_2',
fileAttributes: {
metadata: {
hubMetadata: {
favori: false
externalDataSource: {
hubMetadata: {
favori: false
}
}
}
}
Expand All @@ -954,8 +974,10 @@ describe('CozyUtils', () => {
vendorRef: 'SOME_VALUE_3',
fileAttributes: {
metadata: {
hubMetadata: {
favori: false
externalDataSource: {
hubMetadata: {
favori: false
}
}
}
}
Expand All @@ -966,8 +988,10 @@ describe('CozyUtils', () => {
vendorRef: 'SOME_VALUE',
fileAttributes: {
metadata: {
hubMetadata: {
favori: true
externalDataSource: {
hubMetadata: {
favori: true
}
}
}
}
Expand Down