Skip to content

Commit dc5be55

Browse files
committed
refactor: enhance tab handling in identities, agents, and roles components
- Updated tab rendering logic to support separators for better organization. - Refactored tab definitions to include optional properties for background and text colors. - Improved consistency in tab structure across identities, agents, and roles pages.
1 parent 381dc04 commit dc5be55

File tree

4 files changed

+67
-46
lines changed

4 files changed

+67
-46
lines changed

apps/web/src/pages/identities/table.vue

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,18 @@ q-page.grid
4949
q-btn(:to='toPathWithQueries(`/identities/table/${row._id}`)' color='primary' icon='mdi-eye' size='sm' flat round dense)
5050
q-btn-dropdown(:class="[$q.dark.isActive ? 'text-white' : 'text-black']" dropdown-icon="mdi-dots-horizontal" size='sm' flat round dense)
5151
q-list(dense)
52-
q-item(
53-
v-for="tab in tabs.filter(tab => tab.name !== 'index')" :key="tab.name"
54-
v-show='typeof tab?.condition === "function" ? tab.condition() : true'
55-
@click='tab?.action(row)'
56-
clickable v-close-popup
57-
)
58-
q-item-section(avatar)
59-
q-icon(:name="tab.icon" :class="tab.textColor ? `text-${tab.textColor}` : 'text-primary'")
60-
q-item-section
61-
q-item-label(v-text="tab.label")
52+
template(v-for="tab in tabs" :key="tab.name")
53+
q-separator(v-if="tab.type === 'separator'")
54+
q-item(
55+
v-else-if="tab.type !== 'separator'"
56+
v-show='typeof tab?.condition === "function" ? tab.condition() : true'
57+
@click='tab?.action(row)'
58+
clickable v-close-popup
59+
)
60+
q-item-section(avatar)
61+
q-icon(:name="tab.icon" :class="tab.textColor ? `text-${tab.textColor}` : 'text-primary'")
62+
q-item-section
63+
q-item-label(v-text="tab.label")
6264
q-separator
6365
q-item(clickable v-close-popup @click="deleteIdentity(row)" :disable='!hasPermission("/management/identities", "delete")')
6466
q-tooltip.text-body2.bg-negative.text-white(
@@ -90,6 +92,8 @@ type TabItem = {
9092
label: string
9193
action: Function
9294
bgColor?: string
95+
textColor?: string
96+
type?: 'separator'
9397
condition?: () => boolean
9498
}
9599
@@ -189,30 +193,39 @@ export default defineNuxtComponent({
189193
name: 'index',
190194
icon: 'mdi-card-account-details',
191195
label: 'Fiche identité',
196+
bgColor: 'primary',
197+
textColor: 'primary',
192198
action: (i) => navigateToTab(`/identities/table/${i._id}`),
193199
condition: () => hasPermission('/management/identities', 'read'),
194200
},
195201
{
196202
name: 'audits',
197203
icon: 'mdi-clipboard-text-clock',
198204
label: 'Historique des changements',
205+
bgColor: 'lime-8',
206+
textColor: 'lime-8',
199207
action: (i) => navigateToTab(`/identities/table/${i._id}/audits`),
200208
condition: () => hasPermission('/core/audits', 'read'),
201209
},
202210
{
203211
name: 'jobs',
204212
icon: 'mdi-book-clock',
205213
label: 'Journaux des tâches',
214+
bgColor: 'info',
215+
textColor: 'info',
206216
action: (i) => navigateToTab(`/identities/table/${i._id}/jobs`),
207217
condition: () => hasPermission('/core/jobs', 'read'),
208218
},
209219
{
210220
name: 'lifecycle',
211221
icon: 'mdi-timeline-clock-outline',
212222
label: 'Historique des cycles de vie',
223+
bgColor: 'info',
224+
textColor: 'info',
213225
action: (i) => navigateToTab(`/identities/table/${i._id}/lifecycle`),
214226
condition: () => hasPermission('/management/lifecycle', 'read'),
215227
},
228+
{ type: 'separator' },
216229
{
217230
name: 'debug',
218231
icon: 'mdi-bug',

apps/web/src/pages/identities/table/[_id].vue

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,27 @@ q-card.flex.column.fit.absolute(flat)
99
span(v-if='isNew') Nouvelle identitée
1010
span(v-else v-text='identity?.inetOrgPerson?.cn || "Identité sans nom"')
1111
q-tabs.full-height(:model-value='tab' v-if='!isSmall && !isNew')
12-
q-tab.q-px-none(
13-
v-for="tab in tabs" :key="tab.name"
14-
@click='tab?.action(identity)'
15-
v-show='typeof tab?.condition === "function" ? tab.condition() : true'
16-
:class="[tab.textColor ? `text-${tab.textColor}` : 'text-primary']"
17-
:name="tab.name"
18-
:icon="tab.icon"
19-
)
20-
q-popup-proxy(context-menu :offset="[0, 10]")
21-
q-list(dense bordered separator)
22-
q-item(@click='tab?.action()' clickable)
23-
q-item-section(avatar)
24-
q-icon(name="mdi-open-in-new" :class="tab.textColor ? `text-${tab.textColor}` : 'text-primary'")
25-
q-item-section
26-
q-item-label Ouvrir dans un nouvel onglet
27-
q-tooltip.text-body2(
28-
:delay="200"
29-
v-text="tab.label" :class="tab.bgColor ? `bg-${tab.bgColor}` : 'bg-primary'"
12+
template(v-for="tab in tabs" :key="tab.name")
13+
q-separator.q-mx-xs(v-if="tab.type === 'separator'" inset vertical)
14+
q-tab.q-px-none(
15+
v-else-if="tab.type !== 'separator'"
16+
@click='tab?.action(identity)'
17+
v-show='typeof tab?.condition === "function" ? tab.condition() : true'
18+
:class="[tab.textColor ? `text-${tab.textColor}` : 'text-primary']"
19+
:name="tab.name"
20+
:icon="tab.icon"
3021
)
22+
q-popup-proxy(context-menu :offset="[0, 10]")
23+
q-list(dense bordered separator)
24+
q-item(@click='tab?.action()' clickable)
25+
q-item-section(avatar)
26+
q-icon(name="mdi-open-in-new" :class="tab.textColor ? `text-${tab.textColor}` : 'text-primary'")
27+
q-item-section
28+
q-item-label Ouvrir dans un nouvel onglet
29+
q-tooltip.text-body2(
30+
:delay="200"
31+
v-text="tab.label" :class="tab.bgColor ? `bg-${tab.bgColor}` : 'bg-primary'"
32+
)
3133
q-separator(v-for='_ in 2' :key='_')
3234
q-card-section.col.q-pa-none.overflow-auto
3335
nuxt-page(:identity='identity' ref='page')

apps/web/src/pages/settings/agents/[_id].vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ q-card.flex.column.fit.absolute(flat)
88
span(v-if='isNew') Nouvel agent
99
span(v-else v-text='agent?.username || "Agent sans nom"')
1010
q-tabs.full-height(:model-value='tab' v-if='!isSmall && !isNew')
11-
q-tab.q-px-none(
12-
v-for="tab in tabs" :key="tab.name"
13-
@click='tab?.action(agent)'
14-
v-show='typeof tab?.condition === "function" ? tab.condition() : true'
15-
:class="[tab.textColor ? `text-${tab.textColor}` : 'text-primary']"
16-
:name="tab.name"
17-
:icon="tab.icon"
18-
)
11+
template(v-for="tab in tabs" :key="tab.name")
12+
q-separator.q-mx-xs(v-if="tab.type === 'separator'" inset vertical)
13+
q-tab.q-px-none(
14+
v-else-if="tab.type !== 'separator'"
15+
@click='tab?.action(agent)'
16+
v-show='typeof tab?.condition === "function" ? tab.condition() : true'
17+
:class="[tab.textColor ? `text-${tab.textColor}` : 'text-primary']"
18+
:name="tab.name"
19+
:icon="tab.icon"
20+
)
1921
q-separator(v-for='_ in 2' :key='_')
2022
q-card-section.col.q-pa-none.overflow-auto
2123
nuxt-page(:data='{ agent }' ref='page')
@@ -95,6 +97,7 @@ export default defineNuxtComponent({
9597
label: 'Fiche agent',
9698
action: (i) => this.navigateToTab(`/settings/agents/${this.isNew ? NewTargetId : i._id}`),
9799
},
100+
{ type: 'separator' },
98101
{
99102
name: 'debug',
100103
icon: 'mdi-bug',

apps/web/src/pages/settings/roles/[_id].vue

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ q-card.flex.column.fit.absolute(flat)
88
span(v-if='isNew') Nouvel agent
99
span(v-else v-text='role?.name || "Rôle sans nom"')
1010
q-tabs.full-height(:model-value='tab' v-if='!isSmall && !isNew')
11-
q-tab.q-px-none(
12-
v-for="tab in tabs" :key="tab.name"
13-
@click='tab?.action(role)'
14-
v-show='typeof tab?.condition === "function" ? tab.condition() : true'
15-
:class="[tab.textColor ? `text-${tab.textColor}` : 'text-primary']"
16-
:name="tab.name"
17-
:icon="tab.icon"
18-
)
11+
template(v-for="tab in tabs" :key="tab.name")
12+
q-separator.q-mx-xs(v-if="tab.type === 'separator'" inset vertical)
13+
q-tab.q-px-none(
14+
v-else-if="tab.type !== 'separator'"
15+
@click='tab?.action(role)'
16+
v-show='typeof tab?.condition === "function" ? tab.condition() : true'
17+
:class="[tab.textColor ? `text-${tab.textColor}` : 'text-primary']"
18+
:name="tab.name"
19+
:icon="tab.icon"
20+
)
1921
q-separator(v-for='_ in 2' :key='_')
2022
q-card-section.col.q-pa-none.overflow-auto
2123
nuxt-page(:data='{ role }' ref='page')
@@ -26,8 +28,8 @@ import type { components, operations } from '#build/types/service-api'
2628
import type { _Transform } from 'nuxt/dist/app/composables/asyncData'
2729
import { NewTargetId } from '~/constants/variables'
2830
29-
type Agent = components['schemas']['AgentsDto']
30-
type Response = operations['AgentsController_read']['responses']['200']['content']['application/json']
31+
type Role = components['schemas']['RolesDto']
32+
type Response = operations['RolesController_read']['responses']['200']['content']['application/json']
3133
3234
export default defineNuxtComponent({
3335
name: 'SettingsAgentsIdPage',
@@ -95,6 +97,7 @@ export default defineNuxtComponent({
9597
label: 'Fiche de rôle',
9698
action: (i) => this.navigateToTab(`/settings/roles/${this.isNew ? NewTargetId : i._id}`),
9799
},
100+
{ type: 'separator' },
98101
{
99102
name: 'debug',
100103
icon: 'mdi-bug',

0 commit comments

Comments
 (0)