-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathcedar-policy-list.component.html
More file actions
179 lines (168 loc) · 10.6 KB
/
cedar-policy-list.component.html
File metadata and controls
179 lines (168 loc) · 10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<div class="policy-list">
@if (loading()) {
<app-content-loader></app-content-loader>
}
@if (!loading() && policies().length === 0 && !showAddForm) {
<div class="empty-state">
No policies defined. Add a policy to grant permissions.
</div>
}
@for (group of groupedPolicies(); track group.label) {
<div class="policy-group">
<div class="policy-group__header" (click)="toggleGroup(group.label)">
<div class="policy-group__icon-box policy-group__icon-box--{{ group.colorClass }}">
<mat-icon>{{ group.icon }}</mat-icon>
</div>
<span class="policy-group__label">{{ group.label }}</span>
<span class="policy-group__count">{{ group.policies.length }}</span>
<mat-icon class="policy-group__chevron" [class.policy-group__chevron--collapsed]="isCollapsed(group.label)">expand_more</mat-icon>
</div>
@if (!isCollapsed(group.label)) {
<div class="policy-group__items">
@for (entry of group.policies; track entry.originalIndex) {
<div class="policy-item">
@if (editingIndex !== entry.originalIndex) {
<!-- Display mode -->
<div class="policy-item__content">
<mat-icon class="policy-item__action-icon" [matTooltip]="getActionLabel(entry.item.action)">{{ getActionIcon(entry.item.action) }}</mat-icon>
<span class="policy-item__label">{{ getShortActionLabel(entry.item.action) }}</span>
@if (entry.item.tableName) {
<span class="policy-item__table">
{{ getTableDisplayName(entry.item.tableName) }}
</span>
}
@if (entry.item.dashboardId) {
<span class="policy-item__table">
{{ getDashboardDisplayName(entry.item.dashboardId) }}
</span>
}
</div>
<div class="policy-item__actions">
<button mat-icon-button type="button" (click)="startEdit(entry.originalIndex)" matTooltip="Edit">
<mat-icon>edit</mat-icon>
</button>
<button mat-icon-button type="button" (click)="removePolicy(entry.originalIndex)" matTooltip="Delete">
<mat-icon>delete</mat-icon>
</button>
</div>
} @else {
<!-- Edit mode -->
<div class="policy-item__edit-form">
<mat-form-field appearance="outline" class="policy-field">
<mat-label>Action</mat-label>
<mat-select [(ngModel)]="editAction" [ngModelOptions]="{standalone: true}">
@for (actionGroup of editActionGroups; track actionGroup.group) {
<mat-optgroup [label]="actionGroup.group">
@for (action of actionGroup.actions; track action.value) {
<mat-option [value]="action.value">
{{ getActionLabel(action.value) }}
</mat-option>
}
</mat-optgroup>
}
</mat-select>
</mat-form-field>
@if (editNeedsTable) {
<mat-form-field appearance="outline" class="policy-field">
<mat-label>Table</mat-label>
<mat-select [(ngModel)]="editTableName" [ngModelOptions]="{standalone: true}">
<mat-option value="*">All tables</mat-option>
@for (table of availableTables(); track table.tableName) {
<mat-option [value]="table.tableName"
[class.policy-option--used]="usedTables().has(table.tableName)"
[attr.data-hint]="getTableUsedHint(table.tableName) || null">
{{ table.displayName }}
</mat-option>
}
</mat-select>
</mat-form-field>
}
@if (editNeedsDashboard) {
<mat-form-field appearance="outline" class="policy-field">
<mat-label>Dashboard</mat-label>
<mat-select [(ngModel)]="editDashboardId" [ngModelOptions]="{standalone: true}">
<mat-option value="*">All dashboards</mat-option>
@for (dashboard of availableDashboards(); track dashboard.id) {
<mat-option [value]="dashboard.id"
[class.policy-option--used]="usedDashboards().has(dashboard.id)"
[attr.data-hint]="getDashboardUsedHint(dashboard.id) || null">
{{ dashboard.name }}
</mat-option>
}
</mat-select>
</mat-form-field>
}
<div class="policy-item__edit-actions">
<button mat-button color="primary" type="button" (click)="saveEdit(entry.originalIndex)"
[disabled]="!editAction || (editNeedsTable && !editTableName) || (editNeedsDashboard && !editDashboardId)">
Save
</button>
<button mat-button type="button" (click)="cancelEdit()">Cancel</button>
</div>
</div>
}
</div>
}
</div>
}
</div>
}
<!-- Add form -->
@if (showAddForm) {
<div class="policy-item policy-item--add">
<div class="policy-item__edit-form">
<mat-form-field appearance="outline" class="policy-field">
<mat-label>Action</mat-label>
<mat-select [(ngModel)]="newAction" [ngModelOptions]="{standalone: true}">
@for (group of addActionGroups(); track group.group) {
<mat-optgroup [label]="group.group">
@for (action of group.actions; track action.value) {
<mat-option [value]="action.value">
{{ getActionLabel(action.value) }}
</mat-option>
}
</mat-optgroup>
}
</mat-select>
</mat-form-field>
@if (needsTable) {
<mat-form-field appearance="outline" class="policy-field">
<mat-label>Table</mat-label>
<mat-select [(ngModel)]="newTableName" [ngModelOptions]="{standalone: true}">
<mat-option value="*">All tables</mat-option>
@for (table of availableTables(); track table.tableName) {
<mat-option [value]="table.tableName"
[class.policy-option--used]="usedTables().has(table.tableName)"
[attr.data-hint]="getTableUsedHint(table.tableName) || null">
{{ table.displayName }}
</mat-option>
}
</mat-select>
</mat-form-field>
}
@if (needsDashboard) {
<mat-form-field appearance="outline" class="policy-field">
<mat-label>Dashboard</mat-label>
<mat-select [(ngModel)]="newDashboardId" [ngModelOptions]="{standalone: true}">
<mat-option value="*">All dashboards</mat-option>
@for (dashboard of availableDashboards(); track dashboard.id) {
<mat-option [value]="dashboard.id"
[class.policy-option--used]="usedDashboards().has(dashboard.id)"
[attr.data-hint]="getDashboardUsedHint(dashboard.id) || null">
{{ dashboard.name }}
</mat-option>
}
</mat-select>
</mat-form-field>
}
<div class="policy-item__edit-actions">
<button mat-button color="primary" type="button" (click)="addPolicy()"
[disabled]="!newAction || (needsTable && !newTableName) || (needsDashboard && !newDashboardId)">
Add
</button>
<button mat-button type="button" (click)="resetAddForm()">Cancel</button>
</div>
</div>
</div>
}
</div>