@things-factory/auth-ui 10.1.3 → 10.1.6
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/dist-client/components/change-password.d.ts +11 -0
- package/dist-client/components/change-password.js +103 -6
- package/dist-client/components/change-password.js.map +1 -1
- package/dist-client/components/role-detail.d.ts +144 -0
- package/dist-client/components/role-detail.js +698 -0
- package/dist-client/components/role-detail.js.map +1 -0
- package/dist-client/components/user-detail.d.ts +151 -0
- package/dist-client/components/user-detail.js +631 -0
- package/dist-client/components/user-detail.js.map +1 -0
- package/dist-client/components/user-invite.d.ts +80 -0
- package/dist-client/components/user-invite.js +422 -0
- package/dist-client/components/user-invite.js.map +1 -0
- package/dist-client/entries/auth/activate.d.ts +0 -1
- package/dist-client/entries/auth/activate.js +0 -8
- package/dist-client/entries/auth/activate.js.map +1 -1
- package/dist-client/pages/role/role-list-page.d.ts +112 -0
- package/dist-client/pages/role/role-list-page.js +514 -0
- package/dist-client/pages/role/role-list-page.js.map +1 -0
- package/dist-client/pages/role/role-privilege-page.d.ts +123 -0
- package/dist-client/pages/role/role-privilege-page.js +801 -0
- package/dist-client/pages/role/role-privilege-page.js.map +1 -0
- package/dist-client/pages/user/user-list-page.d.ts +88 -0
- package/dist-client/pages/user/user-list-page.js +474 -0
- package/dist-client/pages/user/user-list-page.js.map +1 -0
- package/dist-client/route.js +5 -2
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/things-factory.config.js +3 -2
- package/translations/en.json +46 -3
- package/translations/ja.json +0 -2
- package/translations/ko.json +47 -4
- package/translations/ms.json +0 -2
- package/translations/zh.json +0 -2
- package/dist-client/components/contact-us.d.ts +0 -20
- package/dist-client/components/contact-us.js +0 -121
- package/dist-client/components/contact-us.js.map +0 -1
|
@@ -0,0 +1,698 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import '@material/web/icon/icon.js';
|
|
3
|
+
import '@material/web/button/elevated-button.js';
|
|
4
|
+
import '@material/web/button/outlined-button.js';
|
|
5
|
+
import '@material/web/textfield/filled-text-field.js';
|
|
6
|
+
import '@material/web/checkbox/checkbox.js';
|
|
7
|
+
import gql from 'graphql-tag';
|
|
8
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
9
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
10
|
+
import { client, gqlContext } from '@operato/graphql';
|
|
11
|
+
import { i18next, localize } from '@operato/i18n';
|
|
12
|
+
import { OxPrompt } from '@operato/popup/ox-prompt.js';
|
|
13
|
+
import { ButtonContainerStyles, ScrollbarStyles } from '@operato/styles';
|
|
14
|
+
import { getDomain, hasPrivilege } from '@things-factory/auth-base/dist-client';
|
|
15
|
+
/** 아는 축은 사람 말로 쓰고, 그 순서로 세운다. 모르는 축은 자기 이름으로 뒤에 붙는다. */
|
|
16
|
+
const KNOWN_AXES = ['query', 'mutation', 'execute'];
|
|
17
|
+
const AXIS_LABEL = {
|
|
18
|
+
query: 'label.read',
|
|
19
|
+
mutation: 'label.write',
|
|
20
|
+
execute: 'label.execute'
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* 한 역할이 무엇을 열 수 있나 — **모듈 × 읽기·쓰기** 격자로 고친다.
|
|
24
|
+
*
|
|
25
|
+
* ── 옛 화면이 무엇을 잘못했나 (`components/role-privilege-editor.ts`) ────────
|
|
26
|
+
* 세 개가 함께 있었고 셋 다 조용했다.
|
|
27
|
+
*
|
|
28
|
+
* **① A 의 이름이 B 에 저장된다.** 이름 입력이 `roleChanged` 를 매 글자마다 페이지로 올리고,
|
|
29
|
+
* 페이지가 그것을 `updateRoleObj` 한 칸에 담아 **모든** 권한 편집기에 내려 줬다. 저장은
|
|
30
|
+
* `{ ...updateRoleObj, privileges }` 였다. A 를 열어 이름을 고치고 B 를 열어 저장하면 B 의
|
|
31
|
+
* 이름이 A 가 된다. 여기서는 이름·설명이 **이 컴포넌트의 상태**다 — 페이지가 들지 않는다.
|
|
32
|
+
*
|
|
33
|
+
* **② 이름으로 남을 찾는다.** 권한을 읽을 때 `role(name:)` 를 썼는데, 그 질의의 범위는
|
|
34
|
+
* 「내 도메인 + 부모」다. 부모에 같은 이름의 역할이 있으면 **다른 역할의 권한을 그렸고**,
|
|
35
|
+
* 저장은 손에 든 id 로 갔다. 여기서는 `rolePrivileges(roleId:)` 하나로 읽는다.
|
|
36
|
+
*
|
|
37
|
+
* **③ 저장 범위를 DOM 에서 만든다.** `querySelectorAll('input:checked')` 로 보냈다. 접히거나
|
|
38
|
+
* 안 그려진 것은 「끈 것」이 되어 **조용히 떨어졌다.** 여기서는 서버가 준 전체 목록이 범위이고,
|
|
39
|
+
* 검색으로 걸러도 안 보이는 칸은 그대로 유지된다.
|
|
40
|
+
*
|
|
41
|
+
* ── 왜 격자인가 ─────────────────────────────────────────────────────────────
|
|
42
|
+
* 옛 화면은 84줄을 한 줄씩 늘어놓고 `description` 을 라벨로 썼다. 「board 를 편집할 수 있나」를
|
|
43
|
+
* 알려면 그 줄을 눈으로 찾아야 했다. 모듈이 행이고 읽기·쓰기가 열이면 **한 모듈에서 무엇이
|
|
44
|
+
* 열려 있나가 한 줄로 보인다.**
|
|
45
|
+
*
|
|
46
|
+
* 열은 **데이터가 정한다.** `execute` 는 아직 서버에 없으므로 열이 나오지 않고, 선언이 서면
|
|
47
|
+
* 화면을 고치지 않고 열이 생긴다 — 없는 것을 있는 것처럼 그리지 않는다.
|
|
48
|
+
*
|
|
49
|
+
* ── 빈 칸과 유령 ────────────────────────────────────────────────────────────
|
|
50
|
+
* 칸이 아예 없는 것(`—`)은 「끈 것」이 아니라 **그 모듈에 그런 권한이 선언되지 않았다**는 뜻이다.
|
|
51
|
+
* 유령(이 배포의 어떤 코드도 요구하지 않는 권한)은 취소선으로 보이고, **켜는 것만 막는다** —
|
|
52
|
+
* 이미 켜져 있는 것은 떼야 하니까.
|
|
53
|
+
*/
|
|
54
|
+
let RoleDetail = class RoleDetail extends localize(i18next)(LitElement) {
|
|
55
|
+
constructor() {
|
|
56
|
+
super(...arguments);
|
|
57
|
+
this.name = '';
|
|
58
|
+
this.description = '';
|
|
59
|
+
/** 서버가 준 전체 권한. **이것이 저장 범위다** — 화면이 무엇을 그렸는지와 무관하다. */
|
|
60
|
+
this.rows = [];
|
|
61
|
+
this.axes = [];
|
|
62
|
+
this.assigned = new Set();
|
|
63
|
+
this.holders = [];
|
|
64
|
+
/*
|
|
65
|
+
* 지금 어느 도메인에 있나 — **subdomain 으로 견준다.**
|
|
66
|
+
*
|
|
67
|
+
* 프로필이 실어 주는 `domain` 에는 `id` 가 없다(`auth-private-process-router.ts` — name·
|
|
68
|
+
* subdomain·type·theme 만 담는다). 그래서 역할 쪽에서도 `subdomain` 을 함께 읽어 그것으로
|
|
69
|
+
* 견준다. 두 도메인이 같은 subdomain 을 가질 수 없으므로 id 와 같은 답을 준다.
|
|
70
|
+
*/
|
|
71
|
+
this.mySubdomain = '';
|
|
72
|
+
/** 지우기만 선언이 다르다 — 소유권 우회가 없다. 그 선언을 그대로 되묻는다. */
|
|
73
|
+
this.mayDelete = false;
|
|
74
|
+
this.keyword = '';
|
|
75
|
+
this.loading = true;
|
|
76
|
+
this.failed = false;
|
|
77
|
+
this.working = false;
|
|
78
|
+
this.message = '';
|
|
79
|
+
}
|
|
80
|
+
static { this.styles = [
|
|
81
|
+
ButtonContainerStyles,
|
|
82
|
+
/* The grid scrolls, so it needs the app's 5px bar. Measured 15px here before this line. */
|
|
83
|
+
ScrollbarStyles,
|
|
84
|
+
css `
|
|
85
|
+
:host {
|
|
86
|
+
display: flex;
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
gap: var(--spacing-medium, 8px);
|
|
89
|
+
padding: var(--spacing-large, 12px);
|
|
90
|
+
min-width: min(560px, 92vw);
|
|
91
|
+
max-height: 78vh;
|
|
92
|
+
background-color: var(--md-sys-color-surface);
|
|
93
|
+
color: var(--md-sys-color-on-surface);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
md-filled-text-field {
|
|
97
|
+
width: 100%;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
[section] {
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: baseline;
|
|
103
|
+
gap: 8px;
|
|
104
|
+
margin-top: var(--spacing-medium, 8px);
|
|
105
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
106
|
+
font-size: 0.8rem;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
[section] [count] {
|
|
110
|
+
color: var(--md-sys-color-outline);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* 격자만 흐르게 둔다 — 이름과 단추는 언제나 제자리에 있어야 한다. */
|
|
114
|
+
/*
|
|
115
|
+
* flex: 1 alone gave this box 69px on a 458px-tall popup whose cap is 644px: a flex
|
|
116
|
+
* column that shrinks to its content leaves nothing for the child that asked to grow,
|
|
117
|
+
* so 32 module rows of 31px were read through a 2.2-row window. The floor is what makes
|
|
118
|
+
* the table legible; flex: 1 still lets it take the rest when the popup is taller.
|
|
119
|
+
*/
|
|
120
|
+
[scroll] {
|
|
121
|
+
flex: 1;
|
|
122
|
+
min-height: min(320px, 40vh);
|
|
123
|
+
overflow: auto;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
table {
|
|
127
|
+
width: 100%;
|
|
128
|
+
border-collapse: collapse;
|
|
129
|
+
font-size: 0.85rem;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
thead th {
|
|
133
|
+
position: sticky;
|
|
134
|
+
top: 0;
|
|
135
|
+
z-index: 1;
|
|
136
|
+
padding: 6px 8px;
|
|
137
|
+
background-color: var(--md-sys-color-surface);
|
|
138
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
139
|
+
font-weight: 500;
|
|
140
|
+
text-align: center;
|
|
141
|
+
border-bottom: 1px solid var(--md-sys-color-outline-variant);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
thead th:first-child {
|
|
145
|
+
text-align: left;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
tbody td {
|
|
149
|
+
padding: 4px 8px;
|
|
150
|
+
border-bottom: 1px solid var(--md-sys-color-surface-variant);
|
|
151
|
+
text-align: center;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
tbody td:first-child {
|
|
155
|
+
text-align: left;
|
|
156
|
+
white-space: nowrap;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* 칸이 없는 것은 「끈 것」이 아니다 — 조용한 색으로 그렇게 말한다. */
|
|
160
|
+
[absent] {
|
|
161
|
+
color: var(--md-sys-color-outline);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
[ghost] {
|
|
165
|
+
text-decoration: line-through;
|
|
166
|
+
color: var(--md-sys-color-outline);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
[note] {
|
|
170
|
+
padding: 8px 10px;
|
|
171
|
+
border-radius: var(--md-sys-shape-corner-small, 6px);
|
|
172
|
+
font-size: 0.82rem;
|
|
173
|
+
line-height: 1.5;
|
|
174
|
+
background-color: var(--md-sys-color-surface-variant);
|
|
175
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
[note][attention] {
|
|
179
|
+
background-color: var(--md-sys-color-error-container);
|
|
180
|
+
color: var(--md-sys-color-on-error-container);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
ul[holders] {
|
|
184
|
+
display: flex;
|
|
185
|
+
flex-wrap: wrap;
|
|
186
|
+
gap: 4px 8px;
|
|
187
|
+
list-style: none;
|
|
188
|
+
margin: 0;
|
|
189
|
+
padding: 0;
|
|
190
|
+
font-size: 0.82rem;
|
|
191
|
+
color: var(--md-sys-color-on-surface-variant);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
[invalid] {
|
|
195
|
+
color: var(--md-sys-color-error);
|
|
196
|
+
font-size: 0.8rem;
|
|
197
|
+
min-height: 1.1rem;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/* 되돌릴 수 없는 조치 — 선으로 갈라 두고 색은 글자에만 쓴다. */
|
|
201
|
+
[danger-zone] {
|
|
202
|
+
margin-top: var(--spacing-small, 4px);
|
|
203
|
+
border-top: 1px solid var(--md-sys-color-outline-variant);
|
|
204
|
+
padding-top: var(--spacing-small, 4px);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
[danger-zone] md-outlined-button {
|
|
208
|
+
--md-outlined-button-label-text-color: var(--md-sys-color-error);
|
|
209
|
+
--md-outlined-button-outline-color: var(--md-sys-color-outline-variant);
|
|
210
|
+
--md-outlined-button-hover-label-text-color: var(--md-sys-color-error);
|
|
211
|
+
--md-outlined-button-hover-state-layer-color: var(--md-sys-color-error);
|
|
212
|
+
--md-outlined-button-pressed-label-text-color: var(--md-sys-color-error);
|
|
213
|
+
}
|
|
214
|
+
`
|
|
215
|
+
]; }
|
|
216
|
+
get creating() {
|
|
217
|
+
return !this.role?.id;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* **부모 도메인의 역할은 여기서 못 고친다.**
|
|
221
|
+
*
|
|
222
|
+
* 목록은 상속으로 부모 역할까지 보여 준다 — 실제로 부여할 수 있는 범위가 그것이기 때문이다.
|
|
223
|
+
* 그런데 `updateRole`·`deleteRole` 은 `domain.id` 하나로 좁혀 찾으므로 부모 것은 못 찾는다.
|
|
224
|
+
* 그래서 여기서는 **읽기 전용으로 두고 어디로 가야 하는지 말한다** — 눌리는 단추를 두고 서버가
|
|
225
|
+
* 거절하면 그것은 안내가 아니라 오류다.
|
|
226
|
+
*/
|
|
227
|
+
get inherited() {
|
|
228
|
+
const subdomain = this.role?.domain?.subdomain;
|
|
229
|
+
return Boolean(subdomain && this.mySubdomain && subdomain !== this.mySubdomain);
|
|
230
|
+
}
|
|
231
|
+
/** 저장할 수 있나 — 단추와 처리기가 같은 답을 본다. */
|
|
232
|
+
get savable() {
|
|
233
|
+
return !this.loading && !this.failed && !this.working && !this.inherited && Boolean(this.name.trim());
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* 지울 수 있나.
|
|
237
|
+
*
|
|
238
|
+
* 서버가 **가진 사람이 있으면 거절한다**(`deleteRole` — 「cannot delete role because it is
|
|
239
|
+
* currently in use」). 그러니 사람 목록이 비어 있을 때만 내준다. 그리고 이 하나만 선언이 다르다 —
|
|
240
|
+
* `@privilege(category:"user", privilege:"mutation")` 로 **소유권 우회가 없다.** 만들기·고치기는
|
|
241
|
+
* 소유자에게 열려 있는데 지우기만 권한을 요구한다.
|
|
242
|
+
*/
|
|
243
|
+
get deletable() {
|
|
244
|
+
return (!this.creating && !this.inherited && !this.loading && !this.working && this.mayDelete && this.holders.length === 0);
|
|
245
|
+
}
|
|
246
|
+
/** 보여 줄 행. **저장 범위가 아니다.** */
|
|
247
|
+
get visible() {
|
|
248
|
+
const keyword = this.keyword.trim().toLowerCase();
|
|
249
|
+
return keyword ? this.rows.filter(row => row.category.toLowerCase().includes(keyword)) : this.rows;
|
|
250
|
+
}
|
|
251
|
+
render() {
|
|
252
|
+
return html `
|
|
253
|
+
<md-filled-text-field
|
|
254
|
+
type="text"
|
|
255
|
+
label=${i18next.t('field.name')}
|
|
256
|
+
.value=${this.name}
|
|
257
|
+
?readonly=${this.inherited}
|
|
258
|
+
@input=${(e) => (this.name = e.target.value)}
|
|
259
|
+
></md-filled-text-field>
|
|
260
|
+
|
|
261
|
+
<md-filled-text-field
|
|
262
|
+
type="text"
|
|
263
|
+
label=${i18next.t('field.description')}
|
|
264
|
+
.value=${this.description}
|
|
265
|
+
?readonly=${this.inherited}
|
|
266
|
+
@input=${(e) => (this.description = e.target.value)}
|
|
267
|
+
></md-filled-text-field>
|
|
268
|
+
|
|
269
|
+
<div invalid>${this.message}</div>
|
|
270
|
+
|
|
271
|
+
${this.inherited
|
|
272
|
+
? html `<div note attention>
|
|
273
|
+
${i18next.t('text.role belongs to x domain and is edited there', {
|
|
274
|
+
x: this.role?.domain?.name || this.role?.domain?.subdomain
|
|
275
|
+
})}
|
|
276
|
+
</div>`
|
|
277
|
+
: nothing}
|
|
278
|
+
|
|
279
|
+
<div section>
|
|
280
|
+
${i18next.t('field.privileges')}
|
|
281
|
+
<span count>${i18next.t('text.x of y on', { x: this.assigned.size, y: this.cellCount() })}</span>
|
|
282
|
+
</div>
|
|
283
|
+
|
|
284
|
+
${this.renderPrivileges()} ${this.renderHolders()}
|
|
285
|
+
|
|
286
|
+
<div class="button-container">
|
|
287
|
+
<md-elevated-button ?disabled=${!this.savable} @click=${() => this.onSave()}>
|
|
288
|
+
${i18next.t('button.save')}
|
|
289
|
+
</md-elevated-button>
|
|
290
|
+
<md-elevated-button @click=${() => this.dispatchEvent(new CustomEvent('close'))}>
|
|
291
|
+
${i18next.t('button.cancel')}
|
|
292
|
+
</md-elevated-button>
|
|
293
|
+
</div>
|
|
294
|
+
|
|
295
|
+
${this.renderDangerZone()}
|
|
296
|
+
`;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* 역할 지우기.
|
|
300
|
+
*
|
|
301
|
+
* **왜 안 되는지를 말한다.** 서버는 가진 사람이 있으면 거절하는데(`deleteRole`), 옛 화면은
|
|
302
|
+
* 언제나 단추를 보여 주고 눌린 뒤에 401 을 받았다. 여기서는 사람이 있으면 단추 대신 그 사실을
|
|
303
|
+
* 적는다 — 관리자가 다음에 할 일(사람에게서 역할을 떼는 것)이 그 문장에서 나온다.
|
|
304
|
+
*/
|
|
305
|
+
renderDangerZone() {
|
|
306
|
+
if (this.creating || this.inherited || this.loading) {
|
|
307
|
+
return nothing;
|
|
308
|
+
}
|
|
309
|
+
return html `
|
|
310
|
+
<div danger-zone>
|
|
311
|
+
${this.holders.length
|
|
312
|
+
? html `<div note>${i18next.t('text.remove the role from x people first', { x: this.holders.length })}</div>`
|
|
313
|
+
: html `<div class="button-container">
|
|
314
|
+
<md-outlined-button ?disabled=${!this.deletable} @click=${() => this.onDelete()}>
|
|
315
|
+
${i18next.t('button.delete role')}
|
|
316
|
+
</md-outlined-button>
|
|
317
|
+
</div>`}
|
|
318
|
+
</div>
|
|
319
|
+
`;
|
|
320
|
+
}
|
|
321
|
+
renderPrivileges() {
|
|
322
|
+
if (this.loading) {
|
|
323
|
+
return html `<div note>${i18next.t('text.loading')}</div>`;
|
|
324
|
+
}
|
|
325
|
+
if (this.failed) {
|
|
326
|
+
return html `<div note attention>${i18next.t('text.failed to fetch')}</div>`;
|
|
327
|
+
}
|
|
328
|
+
if (!this.rows.length) {
|
|
329
|
+
/*
|
|
330
|
+
* 권한 마스터는 부팅 때 `@privilege` 선언으로 채워진다. 비어 있다는 것은 이 배포가 아직
|
|
331
|
+
* 아무것도 선언하지 않았다는 뜻이므로, 역할에 붙일 것이 없다.
|
|
332
|
+
*/
|
|
333
|
+
return html `<div note attention>${i18next.t('text.no privilege declared in this deployment')}</div>`;
|
|
334
|
+
}
|
|
335
|
+
return html `
|
|
336
|
+
<md-filled-text-field
|
|
337
|
+
type="text"
|
|
338
|
+
label=${i18next.t('field.module')}
|
|
339
|
+
placeholder=${i18next.t('text.filter by module name')}
|
|
340
|
+
.value=${this.keyword}
|
|
341
|
+
@input=${(e) => (this.keyword = e.target.value)}
|
|
342
|
+
>
|
|
343
|
+
<md-icon slot="leading-icon">search</md-icon>
|
|
344
|
+
</md-filled-text-field>
|
|
345
|
+
|
|
346
|
+
<div scroll>
|
|
347
|
+
<table>
|
|
348
|
+
<thead>
|
|
349
|
+
<tr>
|
|
350
|
+
<th>${i18next.t('field.module')}</th>
|
|
351
|
+
${this.axes.map(axis => html `<th>${AXIS_LABEL[axis] ? i18next.t(AXIS_LABEL[axis]) : axis}</th>`)}
|
|
352
|
+
</tr>
|
|
353
|
+
</thead>
|
|
354
|
+
<tbody>
|
|
355
|
+
${this.visible.map(row => html `
|
|
356
|
+
<tr>
|
|
357
|
+
<td>${row.category}</td>
|
|
358
|
+
${this.axes.map(axis => this.renderCell(row, axis))}
|
|
359
|
+
</tr>
|
|
360
|
+
`)}
|
|
361
|
+
</tbody>
|
|
362
|
+
</table>
|
|
363
|
+
</div>
|
|
364
|
+
|
|
365
|
+
${this.visible.length === 0
|
|
366
|
+
? html `<div note>${i18next.t('text.nothing matches x', { x: this.keyword })}</div>`
|
|
367
|
+
: nothing}
|
|
368
|
+
`;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* 한 칸.
|
|
372
|
+
*
|
|
373
|
+
* ⚠ **설명이 없다.** `description` 은 권한 행의 칸인데 **아무도 채우지 않는다** — 부팅 동기화가
|
|
374
|
+
* `{ category, name }` 둘만 저장하고(`auth-base/server/index.ts:34-36`), `createPrivilege` 는
|
|
375
|
+
* 그 칸을 받지만 그것을 부르는 화면이 없다. 그래서 713개 선언이 전부 빈 설명이다.
|
|
376
|
+
*
|
|
377
|
+
* 없을 때 `${'$'}{category} ${'$'}{axis}` 를 보여 주던 것을 걷어냈다 — 그건 **코드 낱말을 한 번 더**
|
|
378
|
+
* 보여 주는 것이고, 관리자가 「배울 것이 없다」고 한 자리가 정확히 그것이다. 지금은 없다고
|
|
379
|
+
* 말한다. 지어내지 않는다.
|
|
380
|
+
*
|
|
381
|
+
* 글이 어디서 오는지는 UX 레인이 정하고 있다(`privilege.category.*` 키가 en·ko 에 이미 하나
|
|
382
|
+
* 있고 나머지 45개가 비어 있다). 그 키가 오면 이 자리는 tooltip 이 아니라 **본문**으로 옮긴다.
|
|
383
|
+
*/
|
|
384
|
+
renderCell(row, axis) {
|
|
385
|
+
const cell = row.cells[axis];
|
|
386
|
+
if (!cell) {
|
|
387
|
+
/* 없는 것과 끈 것을 눈으로 갈라 놓는다. */
|
|
388
|
+
return html `<td absent title=${i18next.t('text.not declared for this module')}>—</td>`;
|
|
389
|
+
}
|
|
390
|
+
const on = this.assigned.has(cell.id);
|
|
391
|
+
return html `
|
|
392
|
+
<td>
|
|
393
|
+
<md-checkbox
|
|
394
|
+
.checked=${on}
|
|
395
|
+
?disabled=${this.inherited || (cell.deprecated && !on)}
|
|
396
|
+
aria-label=${`${row.category} ${axis}`}
|
|
397
|
+
title=${cell.deprecated
|
|
398
|
+
? i18next.t('text.privilege no longer declared')
|
|
399
|
+
: cell.description || i18next.t('text.no description for this privilege')}
|
|
400
|
+
@change=${(e) => this.onToggle(cell.id, e.target.checked)}
|
|
401
|
+
></md-checkbox>
|
|
402
|
+
${cell.deprecated ? html `<span ghost>·</span>` : nothing}
|
|
403
|
+
</td>
|
|
404
|
+
`;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* 이 역할을 가진 사람.
|
|
408
|
+
*
|
|
409
|
+
* 「권한을 어디서 찾나」의 반대 방향이다 — 권한을 고르기 전에 **이걸 바꾸면 누가 영향을
|
|
410
|
+
* 받는지** 보이는 것이 사람 목록이다. 새로 만드는 자리에는 아직 없다.
|
|
411
|
+
*/
|
|
412
|
+
renderHolders() {
|
|
413
|
+
if (this.creating || this.loading) {
|
|
414
|
+
return nothing;
|
|
415
|
+
}
|
|
416
|
+
return html `
|
|
417
|
+
<div section>
|
|
418
|
+
${i18next.t('label.user')} <span count>${this.holders.length}</span>
|
|
419
|
+
</div>
|
|
420
|
+
${this.holders.length
|
|
421
|
+
? html `<ul holders>
|
|
422
|
+
${this.holders.map(holder => html `<li>${holder.name || holder.email}</li>`)}
|
|
423
|
+
</ul>`
|
|
424
|
+
: html `<div note>${i18next.t('text.no one holds this role yet')}</div>`}
|
|
425
|
+
`;
|
|
426
|
+
}
|
|
427
|
+
cellCount() {
|
|
428
|
+
return this.rows.reduce((sum, row) => sum + Object.keys(row.cells).length, 0);
|
|
429
|
+
}
|
|
430
|
+
connectedCallback() {
|
|
431
|
+
super.connectedCallback();
|
|
432
|
+
this.checkGates();
|
|
433
|
+
}
|
|
434
|
+
/** 서버 선언을 그대로 되묻고, 지금 도메인을 프로필에서 읽는다. */
|
|
435
|
+
async checkGates() {
|
|
436
|
+
this.mayDelete = Boolean(await hasPrivilege({ category: 'user', privilege: 'mutation' }));
|
|
437
|
+
this.mySubdomain = (await getDomain())?.subdomain || '';
|
|
438
|
+
}
|
|
439
|
+
updated(changes) {
|
|
440
|
+
if (changes.has('role')) {
|
|
441
|
+
this.name = this.role?.name || '';
|
|
442
|
+
this.description = this.role?.description || '';
|
|
443
|
+
this.keyword = '';
|
|
444
|
+
this.message = '';
|
|
445
|
+
this.fetch();
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* 한 번의 질의로 **전체 목록과 이 역할이 가진 것**을 함께 읽는다(`rolePrivileges(roleId:)`).
|
|
450
|
+
*
|
|
451
|
+
* 새로 만드는 자리는 역할이 없으니 `privileges` 로 목록만 읽는다 — 그때 켜진 것은 없다.
|
|
452
|
+
*/
|
|
453
|
+
async fetch() {
|
|
454
|
+
this.loading = true;
|
|
455
|
+
this.failed = false;
|
|
456
|
+
this.holders = [];
|
|
457
|
+
const response = this.creating
|
|
458
|
+
? await client.query({
|
|
459
|
+
query: gql `
|
|
460
|
+
query {
|
|
461
|
+
privileges {
|
|
462
|
+
items {
|
|
463
|
+
id
|
|
464
|
+
name
|
|
465
|
+
category
|
|
466
|
+
description
|
|
467
|
+
deprecated
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
`,
|
|
472
|
+
context: gqlContext()
|
|
473
|
+
})
|
|
474
|
+
: await client.query({
|
|
475
|
+
query: gql `
|
|
476
|
+
query ($roleId: String!, $filters: [Filter!]) {
|
|
477
|
+
rolePrivileges(roleId: $roleId) {
|
|
478
|
+
id
|
|
479
|
+
name
|
|
480
|
+
category
|
|
481
|
+
description
|
|
482
|
+
assigned
|
|
483
|
+
deprecated
|
|
484
|
+
}
|
|
485
|
+
roles(filters: $filters) {
|
|
486
|
+
items {
|
|
487
|
+
users {
|
|
488
|
+
id
|
|
489
|
+
name
|
|
490
|
+
email
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
`,
|
|
496
|
+
variables: {
|
|
497
|
+
roleId: this.role.id,
|
|
498
|
+
filters: [{ name: 'id', operator: 'eq', value: this.role.id }]
|
|
499
|
+
},
|
|
500
|
+
context: gqlContext()
|
|
501
|
+
});
|
|
502
|
+
if (response.errors?.length) {
|
|
503
|
+
/* 실패를 「권한이 하나도 없다」로 그리지 않는다 — 저장하면 실제로 그렇게 된다. */
|
|
504
|
+
this.failed = true;
|
|
505
|
+
this.loading = false;
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
const privileges = this.creating
|
|
509
|
+
? response.data?.privileges?.items || []
|
|
510
|
+
: response.data?.rolePrivileges || [];
|
|
511
|
+
this.build(privileges);
|
|
512
|
+
this.holders = response.data?.roles?.items?.[0]?.users || [];
|
|
513
|
+
this.loading = false;
|
|
514
|
+
}
|
|
515
|
+
/** 평평한 목록을 격자로 세운다. 열은 데이터에 있는 축만. */
|
|
516
|
+
build(privileges) {
|
|
517
|
+
const byCategory = new Map();
|
|
518
|
+
const axes = new Set();
|
|
519
|
+
const assigned = new Set();
|
|
520
|
+
for (const privilege of privileges) {
|
|
521
|
+
const { id, name, category, description, deprecated } = privilege;
|
|
522
|
+
if (!id || !name || !category) {
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
axes.add(name);
|
|
526
|
+
if (privilege.assigned) {
|
|
527
|
+
assigned.add(id);
|
|
528
|
+
}
|
|
529
|
+
const row = byCategory.get(category) || { category, cells: {} };
|
|
530
|
+
row.cells[name] = { id, assigned: Boolean(privilege.assigned), deprecated: Boolean(deprecated), description };
|
|
531
|
+
byCategory.set(category, row);
|
|
532
|
+
}
|
|
533
|
+
const known = KNOWN_AXES.filter(axis => axes.has(axis));
|
|
534
|
+
const rest = [...axes].filter(axis => !KNOWN_AXES.includes(axis)).sort();
|
|
535
|
+
this.axes = [...known, ...rest];
|
|
536
|
+
this.rows = [...byCategory.values()].sort((a, b) => a.category.localeCompare(b.category));
|
|
537
|
+
this.assigned = assigned;
|
|
538
|
+
}
|
|
539
|
+
onToggle(id, checked) {
|
|
540
|
+
const next = new Set(this.assigned);
|
|
541
|
+
checked ? next.add(id) : next.delete(id);
|
|
542
|
+
this.assigned = next;
|
|
543
|
+
}
|
|
544
|
+
/**
|
|
545
|
+
* 저장.
|
|
546
|
+
*
|
|
547
|
+
* **범위는 `rows` 다.** 검색으로 걸러 놓고 저장해도 안 보이던 칸은 켜진 채로 간다 — 옛 화면이
|
|
548
|
+
* DOM 을 훑어 조용히 떼던 자리다.
|
|
549
|
+
*/
|
|
550
|
+
async onSave() {
|
|
551
|
+
if (!this.savable) {
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
this.working = true;
|
|
555
|
+
this.message = '';
|
|
556
|
+
try {
|
|
557
|
+
const privileges = [...this.assigned].map(id => ({ id }));
|
|
558
|
+
const response = this.creating
|
|
559
|
+
? await client.mutate({
|
|
560
|
+
mutation: gql `
|
|
561
|
+
mutation ($role: NewRole!) {
|
|
562
|
+
createRole(role: $role) {
|
|
563
|
+
id
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
`,
|
|
567
|
+
variables: {
|
|
568
|
+
role: { name: this.name.trim(), description: this.description.trim(), privileges }
|
|
569
|
+
},
|
|
570
|
+
context: gqlContext()
|
|
571
|
+
})
|
|
572
|
+
: await client.mutate({
|
|
573
|
+
mutation: gql `
|
|
574
|
+
mutation ($id: String!, $patch: RolePatch!) {
|
|
575
|
+
updateRole(id: $id, patch: $patch) {
|
|
576
|
+
id
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
`,
|
|
580
|
+
variables: {
|
|
581
|
+
id: this.role.id,
|
|
582
|
+
patch: { name: this.name.trim(), description: this.description.trim(), privileges }
|
|
583
|
+
},
|
|
584
|
+
context: gqlContext()
|
|
585
|
+
});
|
|
586
|
+
if (response.errors?.length) {
|
|
587
|
+
this.message = response.errors[0]?.message || '';
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
590
|
+
this.dispatchEvent(new CustomEvent('role-updated', { bubbles: true, composed: true }));
|
|
591
|
+
}
|
|
592
|
+
finally {
|
|
593
|
+
this.working = false;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* 역할을 지운다.
|
|
598
|
+
*
|
|
599
|
+
* **누가 잃는지 먼저 말한다.** 옛 화면은 「역할을 삭제하시겠습니까」만 물었다 — 그 역할을 가진
|
|
600
|
+
* 사람이 몇인지는 같은 화면에 있었는데도 확인 문구에 없었다.
|
|
601
|
+
*/
|
|
602
|
+
async onDelete() {
|
|
603
|
+
if (!this.deletable) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
const confirmed = await OxPrompt.open({
|
|
607
|
+
type: 'warning',
|
|
608
|
+
title: i18next.t('button.delete role'),
|
|
609
|
+
text: i18next.t('text.are_you_sure_to_delete_x', { x: i18next.t('label.role') }),
|
|
610
|
+
confirmButton: { text: i18next.t('button.delete') },
|
|
611
|
+
cancelButton: { text: i18next.t('button.cancel') }
|
|
612
|
+
});
|
|
613
|
+
if (!confirmed) {
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
this.working = true;
|
|
617
|
+
try {
|
|
618
|
+
const response = await client.mutate({
|
|
619
|
+
mutation: gql `
|
|
620
|
+
mutation ($id: String!) {
|
|
621
|
+
deleteRole(id: $id)
|
|
622
|
+
}
|
|
623
|
+
`,
|
|
624
|
+
variables: { id: this.role.id },
|
|
625
|
+
context: gqlContext()
|
|
626
|
+
});
|
|
627
|
+
if (response.errors?.length) {
|
|
628
|
+
this.message = response.errors[0]?.message || '';
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
this.dispatchEvent(new CustomEvent('role-updated', { bubbles: true, composed: true }));
|
|
632
|
+
}
|
|
633
|
+
finally {
|
|
634
|
+
this.working = false;
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
__decorate([
|
|
639
|
+
property({ type: Object }),
|
|
640
|
+
__metadata("design:type", Object)
|
|
641
|
+
], RoleDetail.prototype, "role", void 0);
|
|
642
|
+
__decorate([
|
|
643
|
+
state(),
|
|
644
|
+
__metadata("design:type", String)
|
|
645
|
+
], RoleDetail.prototype, "name", void 0);
|
|
646
|
+
__decorate([
|
|
647
|
+
state(),
|
|
648
|
+
__metadata("design:type", String)
|
|
649
|
+
], RoleDetail.prototype, "description", void 0);
|
|
650
|
+
__decorate([
|
|
651
|
+
state(),
|
|
652
|
+
__metadata("design:type", Array)
|
|
653
|
+
], RoleDetail.prototype, "rows", void 0);
|
|
654
|
+
__decorate([
|
|
655
|
+
state(),
|
|
656
|
+
__metadata("design:type", Array)
|
|
657
|
+
], RoleDetail.prototype, "axes", void 0);
|
|
658
|
+
__decorate([
|
|
659
|
+
state(),
|
|
660
|
+
__metadata("design:type", Set)
|
|
661
|
+
], RoleDetail.prototype, "assigned", void 0);
|
|
662
|
+
__decorate([
|
|
663
|
+
state(),
|
|
664
|
+
__metadata("design:type", Array)
|
|
665
|
+
], RoleDetail.prototype, "holders", void 0);
|
|
666
|
+
__decorate([
|
|
667
|
+
state(),
|
|
668
|
+
__metadata("design:type", String)
|
|
669
|
+
], RoleDetail.prototype, "mySubdomain", void 0);
|
|
670
|
+
__decorate([
|
|
671
|
+
state(),
|
|
672
|
+
__metadata("design:type", Boolean)
|
|
673
|
+
], RoleDetail.prototype, "mayDelete", void 0);
|
|
674
|
+
__decorate([
|
|
675
|
+
state(),
|
|
676
|
+
__metadata("design:type", String)
|
|
677
|
+
], RoleDetail.prototype, "keyword", void 0);
|
|
678
|
+
__decorate([
|
|
679
|
+
state(),
|
|
680
|
+
__metadata("design:type", Boolean)
|
|
681
|
+
], RoleDetail.prototype, "loading", void 0);
|
|
682
|
+
__decorate([
|
|
683
|
+
state(),
|
|
684
|
+
__metadata("design:type", Boolean)
|
|
685
|
+
], RoleDetail.prototype, "failed", void 0);
|
|
686
|
+
__decorate([
|
|
687
|
+
state(),
|
|
688
|
+
__metadata("design:type", Boolean)
|
|
689
|
+
], RoleDetail.prototype, "working", void 0);
|
|
690
|
+
__decorate([
|
|
691
|
+
state(),
|
|
692
|
+
__metadata("design:type", String)
|
|
693
|
+
], RoleDetail.prototype, "message", void 0);
|
|
694
|
+
RoleDetail = __decorate([
|
|
695
|
+
customElement('role-detail')
|
|
696
|
+
], RoleDetail);
|
|
697
|
+
export { RoleDetail };
|
|
698
|
+
//# sourceMappingURL=role-detail.js.map
|