cozy-ui 111.15.0 → 111.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [111.15.1](https://github.com/cozy/cozy-ui/compare/v111.15.0...v111.15.1) (2024-10-09)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * Show additional apps only when there ones ([64c6c5e](https://github.com/cozy/cozy-ui/commit/64c6c5e))
7
+
1
8
  # [111.15.0](https://github.com/cozy/cozy-ui/compare/v111.14.0...v111.15.0) (2024-10-09)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-ui",
3
- "version": "111.15.0",
3
+ "version": "111.15.1",
4
4
  "description": "Cozy apps UI SDK",
5
5
  "main": "./index.js",
6
6
  "bin": {
@@ -1075,11 +1075,6 @@ exports[`AppsSection component should render dropdown filter on mobile if no nav
1075
1075
  "type": "webapp",
1076
1076
  "value": "partners",
1077
1077
  },
1078
- Object {
1079
- "label": "Additional apps",
1080
- "secondary": false,
1081
- "value": "shortcuts",
1082
- },
1083
1078
  Object {
1084
1079
  "label": "Services",
1085
1080
  "secondary": false,
@@ -1481,11 +1476,6 @@ exports[`AppsSection component should render dropdown filter on tablet if no nav
1481
1476
  "type": "webapp",
1482
1477
  "value": "partners",
1483
1478
  },
1484
- Object {
1485
- "label": "Additional apps",
1486
- "secondary": false,
1487
- "value": "shortcuts",
1488
- },
1489
1479
  Object {
1490
1480
  "label": "Services",
1491
1481
  "secondary": false,
@@ -109,7 +109,9 @@ export const generateOptionsFromApps = (apps, options = {}) => {
109
109
  })
110
110
  )
111
111
  }
112
- if (type === APP_TYPE.FILE) {
112
+
113
+ const categories = Object.keys(catApps)
114
+ if (type === APP_TYPE.FILE && categories.length > 0) {
113
115
  allCategoryOptions.push(
114
116
  addLabel({
115
117
  value: 'shortcuts',
@@ -117,7 +119,8 @@ export const generateOptionsFromApps = (apps, options = {}) => {
117
119
  })
118
120
  )
119
121
  }
120
- const categoryOptions = Object.keys(catApps).map(cat => {
122
+
123
+ const categoryOptions = categories.map(cat => {
121
124
  return addLabel({
122
125
  value: cat,
123
126
  type: type,
@@ -10,7 +10,14 @@ import { I18nContext } from '../jestLib/I18n'
10
10
  import mockApps from '../mocks/apps'
11
11
 
12
12
  const i18nContext = I18nContext({
13
- locale: en
13
+ locale: {
14
+ ...en,
15
+ app_categories: {
16
+ ...en.app_categories,
17
+ foo: 'Foo',
18
+ bar: 'Bar'
19
+ }
20
+ }
14
21
  })
15
22
  const tMock = i18nContext.t
16
23
 
@@ -104,7 +111,6 @@ describe('generateOptionsFromApps', () => {
104
111
  type: 'webapp',
105
112
  value: 'others'
106
113
  },
107
- { label: 'Additional apps', secondary: false, value: 'shortcuts' },
108
114
  {
109
115
  label: 'Services',
110
116
  secondary: false,
@@ -157,11 +163,6 @@ describe('generateOptionsFromApps', () => {
157
163
  type: 'webapp',
158
164
  value: 'others'
159
165
  },
160
- {
161
- label: 'Additional apps',
162
- secondary: false,
163
- value: 'shortcuts'
164
- },
165
166
  {
166
167
  label: 'Services',
167
168
  secondary: false,
@@ -199,4 +200,90 @@ describe('generateOptionsFromApps', () => {
199
200
  catUtils.generateOptionsFromApps(null, { includeAll: false, addLabel })
200
201
  ).toEqual([])
201
202
  })
203
+
204
+ it('should return additional apps categories when there more than one', () => {
205
+ const appsWithAdditionlOnes = [
206
+ ...mockApps,
207
+ {
208
+ _id: 'shortcutA',
209
+ name: 'Shortcut A',
210
+ categories: ['foo'],
211
+ type: 'file',
212
+ _type: 'io.cozy.files'
213
+ },
214
+ {
215
+ _id: 'shortcutB',
216
+ name: 'Shortcut B',
217
+ categories: ['bar'],
218
+ type: 'file',
219
+ _type: 'io.cozy.files'
220
+ }
221
+ ]
222
+
223
+ expect(
224
+ catUtils.generateOptionsFromApps(appsWithAdditionlOnes, {
225
+ includeAll: false,
226
+ addLabel
227
+ })
228
+ ).toEqual([
229
+ {
230
+ label: 'The essentials',
231
+ secondary: false,
232
+ type: 'webapp',
233
+ value: 'cozy'
234
+ },
235
+ {
236
+ label: 'Partners',
237
+ secondary: false,
238
+ type: 'webapp',
239
+ value: 'partners'
240
+ },
241
+ {
242
+ label: 'Others',
243
+ secondary: false,
244
+ type: 'webapp',
245
+ value: 'others'
246
+ },
247
+ {
248
+ label: 'Additional apps',
249
+ secondary: false,
250
+ value: 'shortcuts'
251
+ },
252
+ {
253
+ label: 'Bar',
254
+ secondary: true,
255
+ type: 'file',
256
+ value: 'bar'
257
+ },
258
+ {
259
+ label: 'Foo',
260
+ secondary: true,
261
+ type: 'file',
262
+ value: 'foo'
263
+ },
264
+ {
265
+ label: 'Services',
266
+ secondary: false,
267
+ value: 'konnectors'
268
+ },
269
+ {
270
+ label: 'Mobile and Internet',
271
+ secondary: true,
272
+ type: 'konnector',
273
+ value: 'isp'
274
+ },
275
+ {
276
+ label: 'Telecom',
277
+ secondary: true,
278
+ type: 'konnector',
279
+ value: 'telecom'
280
+ },
281
+ {
282
+ label: 'Transportation',
283
+ secondary: true,
284
+ type: 'konnector',
285
+ value: 'transport'
286
+ }
287
+ ])
288
+ })
202
289
  })
@@ -141,14 +141,16 @@ export var generateOptionsFromApps = function generateOptionsFromApps(apps) {
141
141
  }));
142
142
  }
143
143
 
144
- if (type === APP_TYPE.FILE) {
144
+ var categories = Object.keys(catApps);
145
+
146
+ if (type === APP_TYPE.FILE && categories.length > 0) {
145
147
  allCategoryOptions.push(addLabel({
146
148
  value: 'shortcuts',
147
149
  secondary: false
148
150
  }));
149
151
  }
150
152
 
151
- var categoryOptions = Object.keys(catApps).map(function (cat) {
153
+ var categoryOptions = categories.map(function (cat) {
152
154
  return addLabel({
153
155
  value: cat,
154
156
  type: type,