@things-factory/auth-ui 6.1.185 → 6.1.189

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.
Files changed (29) hide show
  1. package/client/components/abstract-auth-page.ts +10 -0
  2. package/client/index.ts +11 -0
  3. package/client/pages/attribute/attribute-set-management.ts +1 -1
  4. package/client/pages/auth-provider/auth-provider-management.ts +379 -0
  5. package/client/route.ts +4 -0
  6. package/dist-client/components/abstract-auth-page.js +8 -0
  7. package/dist-client/components/abstract-auth-page.js.map +1 -1
  8. package/dist-client/index.js +10 -0
  9. package/dist-client/index.js.map +1 -1
  10. package/dist-client/pages/attribute/attribute-set-management.d.ts +0 -1
  11. package/dist-client/pages/attribute/attribute-set-management.js +1 -1
  12. package/dist-client/pages/attribute/attribute-set-management.js.map +1 -1
  13. package/dist-client/pages/auth-provider/auth-provider-management.d.ts +54 -0
  14. package/dist-client/pages/auth-provider/auth-provider-management.js +369 -0
  15. package/dist-client/pages/auth-provider/auth-provider-management.js.map +1 -0
  16. package/dist-client/pages/auth-provider/auth-provider.d.ts +1 -0
  17. package/dist-client/pages/auth-provider/auth-provider.js +381 -0
  18. package/dist-client/pages/auth-provider/auth-provider.js.map +1 -0
  19. package/dist-client/route.js +3 -0
  20. package/dist-client/route.js.map +1 -1
  21. package/dist-client/tsconfig.tsbuildinfo +1 -1
  22. package/dist-server/tsconfig.tsbuildinfo +1 -1
  23. package/package.json +5 -5
  24. package/things-factory.config.js +2 -1
  25. package/translations/en.json +8 -0
  26. package/translations/ja.json +8 -0
  27. package/translations/ko.json +8 -0
  28. package/translations/ms.json +8 -0
  29. package/translations/zh.json +8 -0
@@ -0,0 +1,54 @@
1
+ import '@operato/data-grist';
2
+ import { FetchOption } from '@operato/data-grist';
3
+ import { PageView } from '@operato/shell';
4
+ declare const AuthProviderManagementPage_base: (new (...args: any[]) => {
5
+ _storeUnsubscribe: import("redux").Unsubscribe;
6
+ connectedCallback(): void;
7
+ disconnectedCallback(): void;
8
+ stateChanged(_state: unknown): void;
9
+ readonly isConnected: boolean;
10
+ }) & (new (...args: any[]) => import("lit").LitElement) & typeof PageView;
11
+ export declare class AuthProviderManagementPage extends AuthProviderManagementPage_base {
12
+ static styles: import("lit").CSSResult[];
13
+ gristConfig: any;
14
+ mode: 'CARD' | 'GRID' | 'LIST';
15
+ authProviderTypes: {
16
+ type: string;
17
+ description?: string;
18
+ help?: string;
19
+ parameterSpec?: any[];
20
+ }[];
21
+ private grist;
22
+ private sortersControl;
23
+ get context(): {
24
+ title: string;
25
+ search: {
26
+ handler: (search: string) => void;
27
+ value: string;
28
+ };
29
+ filter: {
30
+ handler: () => void;
31
+ };
32
+ actions: {
33
+ icon: string;
34
+ emphasis: {
35
+ raised: boolean;
36
+ outlined: boolean;
37
+ dense: boolean;
38
+ danger: boolean;
39
+ };
40
+ title: string;
41
+ action: () => Promise<void>;
42
+ }[];
43
+ };
44
+ render(): import("lit-html").TemplateResult<1>;
45
+ pageInitialized(lifecycle: any): Promise<void>;
46
+ fetchHandler({ page, limit, sortings, filters }: FetchOption): Promise<{
47
+ total: any;
48
+ records: any;
49
+ }>;
50
+ private deleteAuthProvider;
51
+ private updateAuthProvider;
52
+ private synchronizeUsers;
53
+ }
54
+ export {};
@@ -0,0 +1,369 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import '@operato/data-grist';
3
+ import gql from 'graphql-tag';
4
+ import { css, html } from 'lit';
5
+ import { customElement, query, state } from 'lit/decorators.js';
6
+ import { connect } from 'pwa-helpers/connect-mixin';
7
+ import { DataGrist } from '@operato/data-grist';
8
+ import { client } from '@operato/graphql';
9
+ import { i18next, localize } from '@operato/i18n';
10
+ import { notify } from '@operato/layout';
11
+ import { PageView, store } from '@operato/shell';
12
+ import { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles';
13
+ import { isMobileDevice } from '@operato/utils';
14
+ import { OxPopup } from '@operato/popup';
15
+ import { OxPrompt } from '@operato/popup/ox-prompt.js';
16
+ let AuthProviderManagementPage = class AuthProviderManagementPage extends connect(store)(localize(i18next)(PageView)) {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.mode = isMobileDevice() ? 'CARD' : 'GRID';
20
+ this.authProviderTypes = [];
21
+ }
22
+ get context() {
23
+ var _a;
24
+ return {
25
+ title: i18next.t('title.auth-provider'),
26
+ search: {
27
+ handler: (search) => {
28
+ this.grist.searchText = search;
29
+ },
30
+ value: ((_a = this.grist) === null || _a === void 0 ? void 0 : _a.searchText) || ''
31
+ },
32
+ filter: {
33
+ handler: () => {
34
+ this.grist.toggleHeadroom();
35
+ }
36
+ },
37
+ // help: 'auth/auth-provider',
38
+ actions: [
39
+ Object.assign({ title: i18next.t('button.save'), action: this.updateAuthProvider.bind(this) }, CommonButtonStyles.save),
40
+ Object.assign({ title: i18next.t('button.delete'), action: this.deleteAuthProvider.bind(this) }, CommonButtonStyles.delete)
41
+ ]
42
+ };
43
+ }
44
+ render() {
45
+ const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID');
46
+ return html `
47
+ <ox-grist
48
+ .mode=${mode}
49
+ .config=${this.gristConfig}
50
+ .fetchHandler=${this.fetchHandler.bind(this)}
51
+ ?url-params-sensitive=${this.active}
52
+ >
53
+ <div slot="headroom">
54
+ <div id="filters">
55
+ <ox-filters-form autofocus without-search></ox-filters-form>
56
+ </div>
57
+
58
+ <div id="sorters">
59
+ Sort
60
+ <mwc-icon
61
+ @click=${e => {
62
+ const target = e.currentTarget;
63
+ this.sortersControl.open({
64
+ right: 0,
65
+ top: target.offsetTop + target.offsetHeight
66
+ });
67
+ }}
68
+ >expand_more</mwc-icon
69
+ >
70
+ <ox-popup id="sorter-control">
71
+ <ox-sorters-control> </ox-sorters-control>
72
+ </ox-popup>
73
+ </div>
74
+ </div>
75
+ </ox-grist>
76
+ `;
77
+ }
78
+ async pageInitialized(lifecycle) {
79
+ this.gristConfig = {
80
+ list: {
81
+ fields: ['entity', 'description']
82
+ },
83
+ columns: [
84
+ { type: 'gutter', gutterName: 'sequence' },
85
+ { type: 'gutter', gutterName: 'row-selector', multiple: true },
86
+ {
87
+ type: 'gutter',
88
+ gutterName: 'button',
89
+ title: i18next.t('title.auth-provider'),
90
+ icon: 'sync',
91
+ handlers: {
92
+ click: (columns, data, column, record, rowIndex) => {
93
+ if (!record.id)
94
+ return;
95
+ this.synchronizeUsers(record.id);
96
+ }
97
+ }
98
+ },
99
+ {
100
+ type: 'select',
101
+ name: 'type',
102
+ header: i18next.t('field.type'),
103
+ record: {
104
+ editable: true,
105
+ options: () => ['', ...this.authProviderTypes.map(({ type }) => type)]
106
+ },
107
+ filter: 'search',
108
+ sortable: true,
109
+ width: 150
110
+ },
111
+ {
112
+ type: 'boolean',
113
+ name: 'active',
114
+ header: i18next.t('field.active'),
115
+ record: {
116
+ editable: true
117
+ },
118
+ sortable: true,
119
+ width: 150
120
+ },
121
+ {
122
+ type: 'string',
123
+ name: 'tenantId',
124
+ header: i18next.t('field.tenant-id'),
125
+ record: {
126
+ editable: true
127
+ },
128
+ width: 200
129
+ },
130
+ {
131
+ type: 'string',
132
+ name: 'clientId',
133
+ header: i18next.t('field.client-id'),
134
+ record: {
135
+ editable: true
136
+ },
137
+ width: 200
138
+ },
139
+ {
140
+ type: 'string',
141
+ name: 'clientSecret',
142
+ header: i18next.t('field.client-secret'),
143
+ record: {
144
+ editable: true
145
+ },
146
+ width: 200
147
+ },
148
+ {
149
+ type: 'string',
150
+ name: 'privateKey',
151
+ header: i18next.t('field.private-key'),
152
+ record: {
153
+ editable: true
154
+ },
155
+ width: 200
156
+ },
157
+ {
158
+ type: 'parameters',
159
+ name: 'params',
160
+ header: i18next.t('field.params'),
161
+ record: {
162
+ editable: true,
163
+ options: async (value, column, record, row, field) => {
164
+ const { description, help, parameterSpec: spec } = record.type ? this.authProviderTypes[record.type] : {};
165
+ const context = this.grist;
166
+ return { description, help, spec, context };
167
+ },
168
+ renderer: 'json5'
169
+ },
170
+ width: 200
171
+ },
172
+ {
173
+ type: 'datetime',
174
+ name: 'updatedAt',
175
+ header: i18next.t('field.updated_at'),
176
+ record: {
177
+ editable: false
178
+ },
179
+ sortable: true,
180
+ width: 180
181
+ }
182
+ ],
183
+ rows: {
184
+ selectable: {
185
+ multiple: true
186
+ }
187
+ },
188
+ sorters: [
189
+ {
190
+ name: 'type'
191
+ }
192
+ ]
193
+ };
194
+ }
195
+ async fetchHandler({ page, limit, sortings = [], filters = [] }) {
196
+ const response = await client.query({
197
+ query: gql `
198
+ query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {
199
+ authProviderTypes {
200
+ items {
201
+ type
202
+ description
203
+ help
204
+ parameterSpec {
205
+ type
206
+ label
207
+ name
208
+ placeholder
209
+ property
210
+ }
211
+ }
212
+ total
213
+ }
214
+
215
+ responses: authProviders(filters: $filters, pagination: $pagination, sortings: $sortings) {
216
+ items {
217
+ id
218
+ type
219
+ active
220
+ tenantId
221
+ clientId
222
+ clientSecret
223
+ privateKey
224
+ params
225
+ updatedAt
226
+ }
227
+ total
228
+ }
229
+ }
230
+ `,
231
+ variables: {
232
+ filters,
233
+ pagination: { page, limit },
234
+ sortings
235
+ }
236
+ });
237
+ this.authProviderTypes = response.data.authProviderTypes.items;
238
+ return {
239
+ total: response.data.responses.total || 0,
240
+ records: response.data.responses.items || []
241
+ };
242
+ }
243
+ async deleteAuthProvider() {
244
+ if (await OxPrompt.open({
245
+ title: i18next.t('text.are_you_sure'),
246
+ text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),
247
+ confirmButton: { text: i18next.t('button.confirm') },
248
+ cancelButton: { text: i18next.t('button.cancel') }
249
+ })) {
250
+ const ids = this.grist.selected.map(record => record.id);
251
+ if (ids && ids.length > 0) {
252
+ const response = await client.mutate({
253
+ mutation: gql `
254
+ mutation ($ids: [String!]!) {
255
+ deleteAuthProviders(ids: $ids)
256
+ }
257
+ `,
258
+ variables: {
259
+ ids
260
+ }
261
+ });
262
+ if (!response.errors) {
263
+ this.grist.fetch();
264
+ notify({
265
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })
266
+ });
267
+ }
268
+ }
269
+ }
270
+ }
271
+ async updateAuthProvider() {
272
+ let patches = this.grist.dirtyRecords;
273
+ if (patches && patches.length) {
274
+ patches = patches.map(patch => {
275
+ let patchField = patch.id ? { id: patch.id } : {};
276
+ const dirtyFields = patch.__dirtyfields__;
277
+ for (let key in dirtyFields) {
278
+ patchField[key] = dirtyFields[key].after;
279
+ }
280
+ if (patchField['reportTemplate'] instanceof FileList) {
281
+ patchField['reportTemplate'] = patchField['reportTemplate'][0];
282
+ }
283
+ patchField.cuFlag = patch.__dirty__;
284
+ return patchField;
285
+ });
286
+ const response = await client.mutate({
287
+ mutation: gql `
288
+ mutation ($patches: [AuthProviderPatch!]!) {
289
+ updateMultipleAuthProvider(patches: $patches) {
290
+ id
291
+ }
292
+ }
293
+ `,
294
+ variables: {
295
+ patches
296
+ }
297
+ });
298
+ if (!response.errors) {
299
+ this.grist.fetch();
300
+ }
301
+ }
302
+ }
303
+ async synchronizeUsers(id) {
304
+ if (await OxPrompt.open({
305
+ title: i18next.t('text.are_you_sure'),
306
+ text: i18next.t('text.sure_to_x', { x: i18next.t('text.synchronize') }),
307
+ confirmButton: { text: i18next.t('button.confirm') },
308
+ cancelButton: { text: i18next.t('button.cancel') }
309
+ })) {
310
+ if (id && id.length > 0) {
311
+ const response = await client.mutate({
312
+ mutation: gql `
313
+ mutation ($id: String!) {
314
+ synchronizeAuthProviderUsers(id: $id)
315
+ }
316
+ `,
317
+ variables: {
318
+ id
319
+ }
320
+ });
321
+ if (!response.errors) {
322
+ this.grist.fetch();
323
+ notify({
324
+ message: i18next.t('text.info_x_successfully', { x: i18next.t('text.synchronize') })
325
+ });
326
+ }
327
+ }
328
+ }
329
+ }
330
+ };
331
+ AuthProviderManagementPage.styles = [
332
+ ScrollbarStyles,
333
+ CommonGristStyles,
334
+ css `
335
+ :host {
336
+ display: flex;
337
+
338
+ width: 100%;
339
+
340
+ --grid-record-emphasized-background-color: red;
341
+ --grid-record-emphasized-color: yellow;
342
+ }
343
+ `
344
+ ];
345
+ __decorate([
346
+ state(),
347
+ __metadata("design:type", Object)
348
+ ], AuthProviderManagementPage.prototype, "gristConfig", void 0);
349
+ __decorate([
350
+ state(),
351
+ __metadata("design:type", String)
352
+ ], AuthProviderManagementPage.prototype, "mode", void 0);
353
+ __decorate([
354
+ state(),
355
+ __metadata("design:type", Array)
356
+ ], AuthProviderManagementPage.prototype, "authProviderTypes", void 0);
357
+ __decorate([
358
+ query('ox-grist'),
359
+ __metadata("design:type", DataGrist)
360
+ ], AuthProviderManagementPage.prototype, "grist", void 0);
361
+ __decorate([
362
+ query('#sorter-control'),
363
+ __metadata("design:type", OxPopup)
364
+ ], AuthProviderManagementPage.prototype, "sortersControl", void 0);
365
+ AuthProviderManagementPage = __decorate([
366
+ customElement('auth-provider-management')
367
+ ], AuthProviderManagementPage);
368
+ export { AuthProviderManagementPage };
369
+ //# sourceMappingURL=auth-provider-management.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-provider-management.js","sourceRoot":"","sources":["../../../client/pages/auth-provider/auth-provider-management.ts"],"names":[],"mappings":";AAAA,OAAO,qBAAqB,CAAA;AAE5B,OAAO,GAAG,MAAM,aAAa,CAAA;AAC7B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAY,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AAEnD,OAAO,EAAwC,SAAS,EAA+B,MAAM,qBAAqB,CAAA;AAClH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,MAAM,EAAa,MAAM,iBAAiB,CAAA;AACnD,OAAO,EAAE,QAAQ,EA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IACH,CAAC;;AAtWM,iCAAM,GAAG;IACd,eAAe;IACf,iBAAiB;IACjB,GAAG,CAAA;;;;;;;;;KASF;CACF,CAAA;AAED;IAAC,KAAK,EAAE;;+DAAiB;AACzB;IAAC,KAAK,EAAE;;wDAAoE;AAC5E;IAAC,KAAK,EAAE;;qEAAuG;AAE/G;IAAC,KAAK,CAAC,UAAU,CAAC;8BAAiB,SAAS;yDAAA;AAC5C;IAAC,KAAK,CAAC,iBAAiB,CAAC;8BAA0B,OAAO;kEAAA;AArB/C,0BAA0B;IADtC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,0BAA0B,CAwWtC;SAxWY,0BAA0B","sourcesContent":["import '@operato/data-grist'\n\nimport gql from 'graphql-tag'\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { connect } from 'pwa-helpers/connect-mixin'\n\nimport { getEditor, getRenderer, ColumnConfig, DataGrist, FetchOption, SortersControl } from '@operato/data-grist'\nimport { client } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify, openPopup } from '@operato/layout'\nimport { PageView, store } from '@operato/shell'\nimport { CommonButtonStyles, CommonGristStyles, ScrollbarStyles } from '@operato/styles'\nimport { isMobileDevice, sleep } from '@operato/utils'\nimport { OxPopup } from '@operato/popup'\nimport { OxPrompt } from '@operato/popup/ox-prompt.js'\n\n@customElement('auth-provider-management')\nexport class AuthProviderManagementPage extends connect(store)(localize(i18next)(PageView)) {\n static styles = [\n ScrollbarStyles,\n CommonGristStyles,\n css`\n :host {\n display: flex;\n\n width: 100%;\n\n --grid-record-emphasized-background-color: red;\n --grid-record-emphasized-color: yellow;\n }\n `\n ]\n\n @state() gristConfig: any\n @state() mode: 'CARD' | 'GRID' | 'LIST' = isMobileDevice() ? 'CARD' : 'GRID'\n @state() authProviderTypes: { type: string; description?: string; help?: string; parameterSpec?: any[] }[] = []\n\n @query('ox-grist') private grist!: DataGrist\n @query('#sorter-control') private sortersControl!: OxPopup\n\n get context() {\n return {\n title: i18next.t('title.auth-provider'),\n search: {\n handler: (search: string) => {\n this.grist.searchText = search\n },\n value: this.grist?.searchText || ''\n },\n filter: {\n handler: () => {\n this.grist.toggleHeadroom()\n }\n },\n // help: 'auth/auth-provider',\n actions: [\n {\n title: i18next.t('button.save'),\n action: this.updateAuthProvider.bind(this),\n ...CommonButtonStyles.save\n },\n {\n title: i18next.t('button.delete'),\n action: this.deleteAuthProvider.bind(this),\n ...CommonButtonStyles.delete\n }\n ]\n }\n }\n\n render() {\n const mode = this.mode || (isMobileDevice() ? 'CARD' : 'GRID')\n\n return html`\n <ox-grist\n .mode=${mode}\n .config=${this.gristConfig}\n .fetchHandler=${this.fetchHandler.bind(this)}\n ?url-params-sensitive=${this.active}\n >\n <div slot=\"headroom\">\n <div id=\"filters\">\n <ox-filters-form autofocus without-search></ox-filters-form>\n </div>\n\n <div id=\"sorters\">\n Sort\n <mwc-icon\n @click=${e => {\n const target = e.currentTarget\n this.sortersControl.open({\n right: 0,\n top: target.offsetTop + target.offsetHeight\n })\n }}\n >expand_more</mwc-icon\n >\n <ox-popup id=\"sorter-control\">\n <ox-sorters-control> </ox-sorters-control>\n </ox-popup>\n </div>\n </div>\n </ox-grist>\n `\n }\n\n async pageInitialized(lifecycle) {\n this.gristConfig = {\n list: {\n fields: ['entity', 'description']\n },\n columns: [\n { type: 'gutter', gutterName: 'sequence' },\n { type: 'gutter', gutterName: 'row-selector', multiple: true },\n {\n type: 'gutter',\n gutterName: 'button',\n title: i18next.t('title.auth-provider'),\n icon: 'sync',\n handlers: {\n click: (columns, data, column, record, rowIndex) => {\n if (!record.id) return\n this.synchronizeUsers(record.id)\n }\n }\n },\n {\n type: 'select',\n name: 'type',\n header: i18next.t('field.type'),\n record: {\n editable: true,\n options: () => ['', ...this.authProviderTypes.map(({ type }) => type)]\n },\n filter: 'search',\n sortable: true,\n width: 150\n },\n {\n type: 'boolean',\n name: 'active',\n header: i18next.t('field.active'),\n record: {\n editable: true\n },\n sortable: true,\n width: 150\n },\n {\n type: 'string',\n name: 'tenantId',\n header: i18next.t('field.tenant-id'),\n record: {\n editable: true\n },\n width: 200\n },\n {\n type: 'string',\n name: 'clientId',\n header: i18next.t('field.client-id'),\n record: {\n editable: true\n },\n width: 200\n },\n {\n type: 'string',\n name: 'clientSecret',\n header: i18next.t('field.client-secret'),\n record: {\n editable: true\n },\n width: 200\n },\n {\n type: 'string',\n name: 'privateKey',\n header: i18next.t('field.private-key'),\n record: {\n editable: true\n },\n width: 200\n },\n {\n type: 'parameters',\n name: 'params',\n header: i18next.t('field.params'),\n record: {\n editable: true,\n options: async (value, column, record, row, field) => {\n const {\n description,\n help,\n parameterSpec: spec\n } = record.type ? this.authProviderTypes[record.type] : ({} as any)\n const context = this.grist\n\n return { description, help, spec, context }\n },\n renderer: 'json5'\n },\n width: 200\n },\n {\n type: 'datetime',\n name: 'updatedAt',\n header: i18next.t('field.updated_at'),\n record: {\n editable: false\n },\n sortable: true,\n width: 180\n }\n ],\n rows: {\n selectable: {\n multiple: true\n }\n },\n sorters: [\n {\n name: 'type'\n }\n ]\n }\n }\n\n async fetchHandler({ page, limit, sortings = [], filters = [] }: FetchOption) {\n const response = await client.query({\n query: gql`\n query ($filters: [Filter!], $pagination: Pagination, $sortings: [Sorting!]) {\n authProviderTypes {\n items {\n type\n description\n help\n parameterSpec {\n type\n label\n name\n placeholder\n property\n }\n }\n total\n }\n\n responses: authProviders(filters: $filters, pagination: $pagination, sortings: $sortings) {\n items {\n id\n type\n active\n tenantId\n clientId\n clientSecret\n privateKey\n params\n updatedAt\n }\n total\n }\n }\n `,\n variables: {\n filters,\n pagination: { page, limit },\n sortings\n }\n })\n\n this.authProviderTypes = response.data.authProviderTypes.items\n\n return {\n total: response.data.responses.total || 0,\n records: response.data.responses.items || []\n }\n }\n\n private async deleteAuthProvider() {\n if (\n await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.sure_to_x', { x: i18next.t('text.delete') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\n const ids = this.grist.selected.map(record => record.id)\n if (ids && ids.length > 0) {\n const response = await client.mutate({\n mutation: gql`\n mutation ($ids: [String!]!) {\n deleteAuthProviders(ids: $ids)\n }\n `,\n variables: {\n ids\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n notify({\n message: i18next.t('text.info_x_successfully', { x: i18next.t('text.delete') })\n })\n }\n }\n }\n }\n\n private async updateAuthProvider() {\n let patches = this.grist.dirtyRecords\n if (patches && patches.length) {\n patches = patches.map(patch => {\n let patchField: any = patch.id ? { id: patch.id } : {}\n const dirtyFields = patch.__dirtyfields__\n for (let key in dirtyFields) {\n patchField[key] = dirtyFields[key].after\n }\n if (patchField['reportTemplate'] instanceof FileList) {\n patchField['reportTemplate'] = patchField['reportTemplate'][0]\n }\n patchField.cuFlag = patch.__dirty__\n\n return patchField\n })\n\n const response = await client.mutate({\n mutation: gql`\n mutation ($patches: [AuthProviderPatch!]!) {\n updateMultipleAuthProvider(patches: $patches) {\n id\n }\n }\n `,\n variables: {\n patches\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n }\n }\n }\n\n private async synchronizeUsers(id: string) {\n if (\n await OxPrompt.open({\n title: i18next.t('text.are_you_sure'),\n text: i18next.t('text.sure_to_x', { x: i18next.t('text.synchronize') }),\n confirmButton: { text: i18next.t('button.confirm') },\n cancelButton: { text: i18next.t('button.cancel') }\n })\n ) {\n if (id && id.length > 0) {\n const response = await client.mutate({\n mutation: gql`\n mutation ($id: String!) {\n synchronizeAuthProviderUsers(id: $id)\n }\n `,\n variables: {\n id\n }\n })\n\n if (!response.errors) {\n this.grist.fetch()\n notify({\n message: i18next.t('text.info_x_successfully', { x: i18next.t('text.synchronize') })\n })\n }\n }\n }\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export {};