diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..e8056df5 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2024 Mehdi Benadel + +# SPDX-License-Identifier: AGPL-3.0-only + +root = true + +[**.{ts,json,js,css}] +quote_type = single +end_of_line = lf +charset = utf-8 +# Please set your autosave delay to 1 second to avoid getting kicked out of the last line at each input +trim_trailing_whitespace = true +insert_final_newline = true +indent_style = space +indent_size = 2 \ No newline at end of file diff --git a/client/.eslintrc.json b/client/.eslintrc.json index 7132d963..caad67fd 100644 --- a/client/.eslintrc.json +++ b/client/.eslintrc.json @@ -5,7 +5,8 @@ "es6": true }, "extends": [ - "standard-with-typescript" + "standard-with-typescript", + "plugin:lit/recommended" ], "globals": {}, "parser": "@typescript-eslint/parser", diff --git a/client/common/configuration/elements/channel-configuration.ts b/client/common/configuration/elements/channel-configuration.ts index e75501c3..81d5ca1d 100644 --- a/client/common/configuration/elements/channel-configuration.ts +++ b/client/common/configuration/elements/channel-configuration.ts @@ -18,17 +18,17 @@ import { LivechatElement } from '../../lib/elements/livechat' export class ChannelConfigurationElement extends LivechatElement { @provide({ context: registerClientOptionsContext }) @property({ attribute: false }) - public registerClientOptions: RegisterClientOptions | undefined + public registerClientOptions?: RegisterClientOptions @property({ attribute: false }) - public channelId: number | undefined + public channelId?: number @provide({ context: channelConfigurationContext }) @state() - public _channelConfiguration: ChannelConfiguration | undefined + public _channelConfiguration?: ChannelConfiguration @provide({ context: channelDetailsServiceContext }) - private _channelDetailsService: ChannelDetailsService | undefined + private _channelDetailsService?: ChannelDetailsService @state() public _formStatus: boolean | any = undefined @@ -43,19 +43,22 @@ export class ChannelConfigurationElement extends LivechatElement { args: () => [this.registerClientOptions] }) - private readonly _saveConfig = (ev?: Event): void => { - ev?.preventDefault() + private readonly _saveConfig = (event?: Event): void => { + event?.preventDefault() if (this._channelDetailsService && this._channelConfiguration) { this._channelDetailsService.saveOptions(this._channelConfiguration.channel.id, this._channelConfiguration.configuration) .then(() => { this._formStatus = { success: true } - console.log('Configuration has been updated') + this.registerClientOptions + ?.peertubeHelpers.notifier.info('Livechat configuration has been properly updated.') this.requestUpdate('_formStatus') }) - .catch((error) => { - this._formStatus = error - console.log(`An error occurred : ${JSON.stringify(this._formStatus)}`) + .catch((error: Error) => { + console.error(`An error occurred. ${error.name}: ${error.message}`) + this.registerClientOptions + ?.peertubeHelpers.notifier.error( + `An error occurred. ${(error.name && error.message) ? `${error.name}: ${error.message}` : ''}`) this.requestUpdate('_formStatus') }) } @@ -342,18 +345,6 @@ export class ChannelConfigurationElement extends LivechatElement {
- ${(this._formStatus && this._formStatus.success === undefined) - ? html`` - : '' - } - ${(this._formStatus && this._formStatus.success === true) - ? html`` - : '' - } ` }) diff --git a/client/common/configuration/elements/channel-home.ts b/client/common/configuration/elements/channel-home.ts index d9ba165d..2ded9c4f 100644 --- a/client/common/configuration/elements/channel-home.ts +++ b/client/common/configuration/elements/channel-home.ts @@ -18,13 +18,13 @@ import { LivechatElement } from '../../lib/elements/livechat' export class ChannelHomeElement extends LivechatElement { @provide({ context: registerClientOptionsContext }) @property({ attribute: false }) - public registerClientOptions: RegisterClientOptions | undefined + public registerClientOptions?: RegisterClientOptions @state() - public _channels: ChannelLiveChatInfos[] | undefined + public _channels?: ChannelLiveChatInfos[] @provide({ context: channelDetailsServiceContext }) - private _channelDetailsService: ChannelDetailsService | undefined + private _channelDetailsService?: ChannelDetailsService @state() public _formStatus: boolean | any = undefined diff --git a/client/common/lib/elements/dynamic-table-form.ts b/client/common/lib/elements/dynamic-table-form.ts index e15c520f..10fc5880 100644 --- a/client/common/lib/elements/dynamic-table-form.ts +++ b/client/common/lib/elements/dynamic-table-form.ts @@ -380,7 +380,7 @@ export class DynamicTableFormElement extends LivechatElement { /> ${(propertySchema.datalist) ? html` - ${(propertySchema.datalist ?? []).map((value) => html`` : nothing} ` diff --git a/client/common/lib/elements/help-button.ts b/client/common/lib/elements/help-button.ts index 5ac2c15b..01c50dac 100644 --- a/client/common/lib/elements/help-button.ts +++ b/client/common/lib/elements/help-button.ts @@ -18,7 +18,7 @@ import { LivechatElement } from './livechat' @customElement('livechat-help-button') export class HelpButtonElement extends LivechatElement { @consume({ context: registerClientOptionsContext, subscribe: true }) - public registerClientOptions: RegisterClientOptions | undefined + public registerClientOptions?: RegisterClientOptions @property({ attribute: false }) public buttonTitle: string | DirectiveResult = ptTr(LOC_ONLINE_HELP) diff --git a/package-lock.json b/package-lock.json index c86d41e1..dd9cc77d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,6 +42,7 @@ "eslint-config-standard": "^16.0.3", "eslint-config-standard-with-typescript": "^20.0.0", "eslint-plugin-import": "^2.25.2", + "eslint-plugin-lit": "^1.13.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.1.1", "eslint-plugin-standard": "^5.0.0", @@ -6726,6 +6727,23 @@ "node": ">=0.10.0" } }, + "node_modules/eslint-plugin-lit": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-lit/-/eslint-plugin-lit-1.13.0.tgz", + "integrity": "sha512-vKc67q6YQ+naYO1QuFpqMoTs3535yp8+0WB/8bzZRLr5NSOb4C6vZrD4se7S9XZtym5TxSVlIqa9QTWYISykQg==", + "dev": true, + "dependencies": { + "parse5": "^6.0.1", + "parse5-htmlparser2-tree-adapter": "^6.0.1", + "requireindex": "^1.2.0" + }, + "engines": { + "node": ">= 12" + }, + "peerDependencies": { + "eslint": ">= 5" + } + }, "node_modules/eslint-plugin-node": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz", @@ -9851,6 +9869,21 @@ "parse-torrent": "bin/cmd.js" } }, + "node_modules/parse5": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", + "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==", + "dev": true + }, + "node_modules/parse5-htmlparser2-tree-adapter": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz", + "integrity": "sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==", + "dev": true, + "dependencies": { + "parse5": "^6.0.1" + } + }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -10426,6 +10459,15 @@ "node": ">=0.10.0" } }, + "node_modules/requireindex": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.2.0.tgz", + "integrity": "sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==", + "dev": true, + "engines": { + "node": ">=0.10.5" + } + }, "node_modules/requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", @@ -17703,6 +17745,17 @@ } } }, + "eslint-plugin-lit": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-lit/-/eslint-plugin-lit-1.13.0.tgz", + "integrity": "sha512-vKc67q6YQ+naYO1QuFpqMoTs3535yp8+0WB/8bzZRLr5NSOb4C6vZrD4se7S9XZtym5TxSVlIqa9QTWYISykQg==", + "dev": true, + "requires": { + "parse5": "^6.0.1", + "parse5-htmlparser2-tree-adapter": "^6.0.1", + "requireindex": "^1.2.0" + } + }, "eslint-plugin-node": { "version": "11.1.0", "resolved": "https://registry.npmjs.org/eslint-plugin-node/-/eslint-plugin-node-11.1.0.tgz", @@ -19859,6 +19912,21 @@ "simple-sha1": "^3.1.0" } }, + "parse5": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", + "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==", + "dev": true + }, + "parse5-htmlparser2-tree-adapter": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-6.0.1.tgz", + "integrity": "sha512-qPuWvbLgvDGilKc5BoicRovlT4MtYT6JfJyBOMDsKoiT+GiuP5qyrPCnR9HcPECIJJmZh5jRndyNThnhhb/vlA==", + "dev": true, + "requires": { + "parse5": "^6.0.1" + } + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -20262,6 +20330,12 @@ "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", "dev": true }, + "requireindex": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/requireindex/-/requireindex-1.2.0.tgz", + "integrity": "sha512-L9jEkOi3ASd9PYit2cwRfyppc9NoABujTP8/5gFcbERmo5jUoAKovIC3fsF17pkTnGsrByysqX+Kxd2OTNI1ww==", + "dev": true + }, "requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", diff --git a/package.json b/package.json index b4265de1..06f9ea27 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "eslint-config-standard": "^16.0.3", "eslint-config-standard-with-typescript": "^20.0.0", "eslint-plugin-import": "^2.25.2", + "eslint-plugin-lit": "^1.13.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^5.1.1", "eslint-plugin-standard": "^5.0.0",