@things-factory/notification 10.1.255 → 10.1.257
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/tsconfig.tsbuildinfo +1 -1
- package/dist-client/viewparts/notice-channel-setting-let.d.ts +4 -3
- package/dist-client/viewparts/notice-channel-setting-let.js +16 -42
- package/dist-client/viewparts/notice-channel-setting-let.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -6
|
@@ -19,14 +19,15 @@ declare const NoticeChannelSettingLet_base: (new (...args: any[]) => LitElement)
|
|
|
19
19
|
*/
|
|
20
20
|
export declare class NoticeChannelSettingLet extends NoticeChannelSettingLet_base {
|
|
21
21
|
static styles: import("lit").CSSResult[];
|
|
22
|
-
setting?: NoticeChannelSetting;
|
|
23
22
|
entries: {
|
|
24
23
|
teamsChannelWebhook: string;
|
|
25
24
|
};
|
|
26
|
-
|
|
25
|
+
private settingRead;
|
|
26
|
+
private saving;
|
|
27
|
+
get setting(): NoticeChannelSetting | undefined;
|
|
28
|
+
get busy(): boolean;
|
|
27
29
|
render(): import("lit-html").TemplateResult<1> | typeof nothing;
|
|
28
30
|
private webhookRow;
|
|
29
|
-
connectedCallback(): Promise<void>;
|
|
30
31
|
private save;
|
|
31
32
|
}
|
|
32
33
|
export {};
|
|
@@ -6,7 +6,7 @@ import '@things-factory/setting-base';
|
|
|
6
6
|
import gql from 'graphql-tag';
|
|
7
7
|
import { css, html, LitElement, nothing } from 'lit';
|
|
8
8
|
import { customElement, state } from 'lit/decorators.js';
|
|
9
|
-
import {
|
|
9
|
+
import { MutationController, QueryController } from '@operato/graphql';
|
|
10
10
|
import { i18next, localize } from '@operato/i18n';
|
|
11
11
|
import { notify } from '@operato/layout';
|
|
12
12
|
const SETTING = `email teamsChannel { set host }`;
|
|
@@ -19,7 +19,9 @@ let NoticeChannelSettingLet = class NoticeChannelSettingLet extends localize(i18
|
|
|
19
19
|
constructor() {
|
|
20
20
|
super(...arguments);
|
|
21
21
|
this.entries = { teamsChannelWebhook: '' };
|
|
22
|
-
|
|
22
|
+
/* Refused for one who may not change the domain's attributes - the card then stays empty. */
|
|
23
|
+
this.settingRead = new QueryController(this, gql `query { noticeChannelSetting { ${SETTING} } }`);
|
|
24
|
+
this.saving = new MutationController(this, gql `mutation ($patch: NoticeChannelSettingPatch!) { updateNoticeChannelSetting(patch: $patch) { ${SETTING} } }`, { refetch: () => [this.settingRead] });
|
|
23
25
|
}
|
|
24
26
|
static { this.styles = [
|
|
25
27
|
css `
|
|
@@ -74,6 +76,12 @@ let NoticeChannelSettingLet = class NoticeChannelSettingLet extends localize(i18
|
|
|
74
76
|
}
|
|
75
77
|
`
|
|
76
78
|
]; }
|
|
79
|
+
get setting() {
|
|
80
|
+
return this.settingRead.data?.noticeChannelSetting || undefined;
|
|
81
|
+
}
|
|
82
|
+
get busy() {
|
|
83
|
+
return this.saving.pending;
|
|
84
|
+
}
|
|
77
85
|
render() {
|
|
78
86
|
const setting = this.setting;
|
|
79
87
|
if (!setting)
|
|
@@ -121,53 +129,19 @@ let NoticeChannelSettingLet = class NoticeChannelSettingLet extends localize(i18
|
|
|
121
129
|
</div>
|
|
122
130
|
`;
|
|
123
131
|
}
|
|
124
|
-
async connectedCallback() {
|
|
125
|
-
super.connectedCallback();
|
|
126
|
-
const response = await client
|
|
127
|
-
.query({ query: gql `query { noticeChannelSetting { ${SETTING} } }`, fetchPolicy: 'no-cache', errorPolicy: 'all' })
|
|
128
|
-
.catch(() => undefined);
|
|
129
|
-
/* refused - this person may not change the domain's attributes, so the card stays empty */
|
|
130
|
-
this.setting = response?.data?.noticeChannelSetting || undefined;
|
|
131
|
-
}
|
|
132
132
|
async save(patch) {
|
|
133
|
-
this.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
});
|
|
140
|
-
if (response.errors?.length) {
|
|
141
|
-
notify({ level: 'error', message: response.errors[0].message });
|
|
142
|
-
this.requestUpdate();
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
this.setting = response.data.updateNoticeChannelSetting;
|
|
146
|
-
const cleared = Object.keys(patch).filter(field => field in this.entries);
|
|
147
|
-
if (cleared.length)
|
|
148
|
-
this.entries = { ...this.entries, ...Object.fromEntries(cleared.map(field => [field, ''])) };
|
|
149
|
-
notify({ level: 'info', message: i18next.t('text.notice channels saved') });
|
|
150
|
-
}
|
|
151
|
-
catch (error) {
|
|
152
|
-
notify({ level: 'error', message: String(error?.message || error) });
|
|
153
|
-
}
|
|
154
|
-
finally {
|
|
155
|
-
this.busy = false;
|
|
156
|
-
}
|
|
133
|
+
if (!(await this.saving.run({ patch })))
|
|
134
|
+
return;
|
|
135
|
+
const cleared = Object.keys(patch).filter(field => field in this.entries);
|
|
136
|
+
if (cleared.length)
|
|
137
|
+
this.entries = { ...this.entries, ...Object.fromEntries(cleared.map(field => [field, ''])) };
|
|
138
|
+
notify({ level: 'info', message: i18next.t('text.notice channels saved') });
|
|
157
139
|
}
|
|
158
140
|
};
|
|
159
|
-
__decorate([
|
|
160
|
-
state(),
|
|
161
|
-
__metadata("design:type", Object)
|
|
162
|
-
], NoticeChannelSettingLet.prototype, "setting", void 0);
|
|
163
141
|
__decorate([
|
|
164
142
|
state(),
|
|
165
143
|
__metadata("design:type", Object)
|
|
166
144
|
], NoticeChannelSettingLet.prototype, "entries", void 0);
|
|
167
|
-
__decorate([
|
|
168
|
-
state(),
|
|
169
|
-
__metadata("design:type", Object)
|
|
170
|
-
], NoticeChannelSettingLet.prototype, "busy", void 0);
|
|
171
145
|
NoticeChannelSettingLet = __decorate([
|
|
172
146
|
customElement('notice-channel-setting-let')
|
|
173
147
|
], NoticeChannelSettingLet);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notice-channel-setting-let.js","sourceRoot":"","sources":["../../client/viewparts/notice-channel-setting-let.ts"],"names":[],"mappings":";AAAA,OAAO,yCAAyC,CAAA;AAChD,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C,EAAE,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;QAChH,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAA;IAC7E,CAAC;;AAzEQ;IAAR,KAAK,EAAE;;wDAAuE;AAvDpE,uBAAuB;IADnC,aAAa,CAAC,4BAA4B,CAAC;GAC/B,uBAAuB,CAiInC","sourcesContent":["import '@material/web/button/outlined-button.js'\nimport '@material/web/button/text-button.js'\nimport '@material/web/switch/switch.js'\nimport '@things-factory/setting-base'\n\nimport gql from 'graphql-tag'\nimport { css, html, LitElement, nothing } from 'lit'\nimport { customElement, state } from 'lit/decorators.js'\n\nimport { MutationController, QueryController } from '@operato/graphql'\nimport { i18next, localize } from '@operato/i18n'\nimport { notify } from '@operato/layout'\n\ntype SecretState = { set: boolean; host?: string }\ntype NoticeChannelSetting = { email: boolean; teamsChannel: SecretState }\n\nconst SETTING = `email teamsChannel { set host }`\n\n/**\n * Where notices go beyond the app and web push in this domain (ADR-0164): mail, and the Teams channel that takes a\n * notice to everyone. Shown to those who may change the domain's attributes; for anyone else the card stays empty. The\n * webhook address goes in and never comes back - the card shows only that it is set, and its host.\n */\n@customElement('notice-channel-setting-let')\nexport class NoticeChannelSettingLet extends localize(i18next)(LitElement) {\n static styles = [\n css`\n div[row] {\n display: flex;\n flex-direction: column;\n gap: var(--spacing-small, 4px);\n border-bottom: var(--border-dim-color);\n margin-bottom: var(--spacing-medium);\n padding-bottom: var(--spacing-medium);\n }\n\n div[row]:last-child {\n border-bottom: none;\n margin-bottom: 0;\n }\n\n label {\n display: flex;\n gap: 10px;\n align-items: center;\n\n font: var(--label-font);\n color: var(--md-sys-color-on-surface);\n text-transform: var(--label-text-transform);\n }\n\n [state] {\n font: var(--input-font);\n color: var(--md-sys-color-on-surface-variant);\n /* a host is data - the card's capitalized labels must not reach it */\n text-transform: none;\n }\n\n div[entry] {\n display: flex;\n gap: var(--spacing-small, 4px);\n align-items: center;\n }\n\n input {\n background-color: var(--input-field-background, var(--md-sys-color-surface-container-highest));\n color: var(--input-field-color, var(--md-sys-color-on-surface));\n border: var(--border-dim-color);\n border-radius: var(--border-radius);\n margin: var(--input-margin);\n padding: var(--input-padding);\n font: var(--input-font);\n\n flex: 1;\n min-width: 0;\n }\n `\n ]\n\n @state() entries: { teamsChannelWebhook: string } = { teamsChannelWebhook: '' }\n\n /* Refused for one who may not change the domain's attributes - the card then stays empty. */\n private settingRead = new QueryController(this, gql`query { noticeChannelSetting { ${SETTING} } }`)\n private saving = new MutationController(\n this,\n gql`mutation ($patch: NoticeChannelSettingPatch!) { updateNoticeChannelSetting(patch: $patch) { ${SETTING} } }`,\n { refetch: () => [this.settingRead] }\n )\n\n get setting(): NoticeChannelSetting | undefined {\n return this.settingRead.data?.noticeChannelSetting || undefined\n }\n\n get busy() {\n return this.saving.pending\n }\n\n render() {\n const setting = this.setting\n if (!setting) return nothing\n\n return html`\n <setting-let>\n <span slot=\"title\">${i18next.t('title.notice channels')}</span>\n\n <div slot=\"content\" row>\n <label>\n <md-switch ?selected=${setting.email} ?disabled=${this.busy} @change=${e => this.save({ email: e.target.selected })}></md-switch>\n ${i18next.t('label.notice by email')}\n </label>\n </div>\n\n ${this.webhookRow('teamsChannelWebhook', i18next.t('label.teams channel webhook'), setting.teamsChannel)}\n </setting-let>\n `\n }\n\n private webhookRow(field: 'teamsChannelWebhook', label: string, secret: SecretState) {\n const entry = this.entries[field]\n\n return html`\n <div slot=\"content\" row>\n <label>${label}</label>\n <span state>\n ${secret.set ? i18next.t('text.notice webhook set', { host: secret.host || '-' }) : i18next.t('text.notice webhook not set')}\n </span>\n <div entry>\n <input\n type=\"url\"\n placeholder=\"https://\"\n autocomplete=\"off\"\n .value=${entry}\n @input=${e => (this.entries = { ...this.entries, [field]: e.target.value })}\n />\n <md-outlined-button ?disabled=${this.busy || !entry.trim()} @click=${() => this.save({ [field]: entry.trim() })}\n >${i18next.t('button.notice webhook save')}</md-outlined-button\n >\n ${secret.set\n ? html`<md-text-button ?disabled=${this.busy} @click=${() => this.save({ [field]: '' })}\n >${i18next.t('button.notice webhook clear')}</md-text-button\n >`\n : nothing}\n </div>\n </div>\n `\n }\n\n private async save(patch: Record<string, unknown>) {\n if (!(await this.saving.run({ patch }))) return\n const cleared = Object.keys(patch).filter(field => field in this.entries)\n if (cleared.length) this.entries = { ...this.entries, ...Object.fromEntries(cleared.map(field => [field, ''])) }\n notify({ level: 'info', message: i18next.t('text.notice channels saved') })\n }\n}\n"]}
|