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

[VO-1124] fix: Show additional apps only when there ones #2702

Merged
merged 1 commit into from
Oct 9, 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
10 changes: 0 additions & 10 deletions react/AppSections/__snapshots__/index.spec.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1075,11 +1075,6 @@ exports[`AppsSection component should render dropdown filter on mobile if no nav
"type": "webapp",
"value": "partners",
},
Object {
"label": "Additional apps",
"secondary": false,
"value": "shortcuts",
},
Object {
"label": "Services",
"secondary": false,
Expand Down Expand Up @@ -1481,11 +1476,6 @@ exports[`AppsSection component should render dropdown filter on tablet if no nav
"type": "webapp",
"value": "partners",
},
Object {
"label": "Additional apps",
"secondary": false,
"value": "shortcuts",
},
Object {
"label": "Services",
"secondary": false,
Expand Down
7 changes: 5 additions & 2 deletions react/AppSections/categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,18 @@ export const generateOptionsFromApps = (apps, options = {}) => {
})
)
}
if (type === APP_TYPE.FILE) {

const categories = Object.keys(catApps)
if (type === APP_TYPE.FILE && categories.length > 0) {
allCategoryOptions.push(
addLabel({
value: 'shortcuts',
secondary: false
})
)
}
const categoryOptions = Object.keys(catApps).map(cat => {

const categoryOptions = categories.map(cat => {
return addLabel({
value: cat,
type: type,
Expand Down
101 changes: 94 additions & 7 deletions react/AppSections/categories.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ import { I18nContext } from '../jestLib/I18n'
import mockApps from '../mocks/apps'

const i18nContext = I18nContext({
locale: en
locale: {
...en,
app_categories: {
...en.app_categories,
foo: 'Foo',
bar: 'Bar'
}
}
})
const tMock = i18nContext.t

Expand Down Expand Up @@ -104,7 +111,6 @@ describe('generateOptionsFromApps', () => {
type: 'webapp',
value: 'others'
},
{ label: 'Additional apps', secondary: false, value: 'shortcuts' },
{
label: 'Services',
secondary: false,
Expand Down Expand Up @@ -157,11 +163,6 @@ describe('generateOptionsFromApps', () => {
type: 'webapp',
value: 'others'
},
{
label: 'Additional apps',
secondary: false,
value: 'shortcuts'
},
{
label: 'Services',
secondary: false,
Expand Down Expand Up @@ -199,4 +200,90 @@ describe('generateOptionsFromApps', () => {
catUtils.generateOptionsFromApps(null, { includeAll: false, addLabel })
).toEqual([])
})

it('should return additional apps categories when there more than one', () => {
const appsWithAdditionlOnes = [
...mockApps,
{
_id: 'shortcutA',
name: 'Shortcut A',
categories: ['foo'],
type: 'file',
_type: 'io.cozy.files'
},
{
_id: 'shortcutB',
name: 'Shortcut B',
categories: ['bar'],
type: 'file',
_type: 'io.cozy.files'
}
]

expect(
catUtils.generateOptionsFromApps(appsWithAdditionlOnes, {
includeAll: false,
addLabel
})
).toEqual([
{
label: 'The essentials',
secondary: false,
type: 'webapp',
value: 'cozy'
},
{
label: 'Partners',
secondary: false,
type: 'webapp',
value: 'partners'
},
{
label: 'Others',
secondary: false,
type: 'webapp',
value: 'others'
},
{
label: 'Additional apps',
secondary: false,
value: 'shortcuts'
},
{
label: 'Bar',
secondary: true,
type: 'file',
value: 'bar'
},
{
label: 'Foo',
secondary: true,
type: 'file',
value: 'foo'
},
{
label: 'Services',
secondary: false,
value: 'konnectors'
},
{
label: 'Mobile and Internet',
secondary: true,
type: 'konnector',
value: 'isp'
},
{
label: 'Telecom',
secondary: true,
type: 'konnector',
value: 'telecom'
},
{
label: 'Transportation',
secondary: true,
type: 'konnector',
value: 'transport'
}
])
})
})
Loading