Browse Source

Merge branch 'develop' of gitlab.2iopenservice.com:opentalent/app into develop

Olivier Massot 1 năm trước cách đây
mục cha
commit
f276feb2b4

+ 6 - 0
config/abilities/pages/billing.yaml

@@ -45,3 +45,9 @@
     conditions:
       - {function: organizationHasAnyModule, parameters: ['Jvs']}
       - {function: accessHasAnyRoleAbility, parameters: [{action: 'manage', subject: 'billings-administration'}]}
+      -
+  afi_page:
+    action: 'display'
+    conditions:
+      - {function: organizationHasAnyModule, parameters: ['AFI']}
+      - {function: accessHasAnyRoleAbility, parameters: [{action: 'manage', subject: 'billings-administration'}]}

+ 1 - 0
lang/fr.json

@@ -1,4 +1,5 @@
 {
+  "afi_export": "Export AFI",
   "item": "Détails",
   "organization_breadcrumbs": "Fiche de la structure",
   "subscription_breadcrumbs": "Mon abonnement",

+ 4 - 0
services/layout/menuBuilder/billingMenuBuilder.ts

@@ -46,6 +46,10 @@ export default class BillingMenuBuilder extends AbstractMenuBuilder {
       children.push(this.createItem('jvs_export', {name: 'fas fa-align-justify'}, '/jvs/list/', MENU_LINK_TYPE.V1))
     }
 
+    if (this.ability.can('display', 'afi_page')) {
+      children.push(this.createItem('afi_export', {name: 'fas fa-align-justify'}, '/afis/list/', MENU_LINK_TYPE.V1))
+    }
+
     if (children.length > 1) {
       // Plusieurs éléments, on retourne un groupe
       return this.createGroup('billing', {name: 'fas fa-euro-sign'}, children)

+ 9 - 1
tests/units/services/layout/menuBuilder/billingMenuBuilder.test.ts

@@ -41,7 +41,7 @@ describe('build', () => {
         expect(result.label).toEqual('billing')
         expect(result.icon).toEqual({name: 'fas fa-euro-sign'})
         // @ts-ignore
-        expect(result.children.length).toEqual(8)
+        expect(result.children.length).toEqual(9)
     })
 
     test('has no items', () => {
@@ -112,4 +112,12 @@ describe('build', () => {
             {label: 'jvs_export', icon: {name: 'fas fa-align-justify'}, to: 'https://mydomain.com/#/jvs/list/', type: MENU_LINK_TYPE.V1, active: false}
         )
     })
+
+    test('has only rights for menu afi_export', () => {
+        ability.can = vi.fn((action: string, subject: string) => action === 'display' && subject === 'afi_page')
+
+        expect(menuBuilder.build()).toEqual(
+            {label: 'afi_export', icon: {name: 'fas fa-align-justify'}, to: 'https://mydomain.com/#/afis/list/', type: MENU_LINK_TYPE.V1, active: false}
+        )
+    })
 })