From 12d28c14e0559a665ceb2f697f2ce8cbc8c206a1 Mon Sep 17 00:00:00 2001 From: merefield Date: Mon, 20 Feb 2023 20:01:34 +0000 Subject: [PATCH 01/13] COMPATIBILITY: move admin translations to Glimmer --- .../admin-multilingual-translations.js | 31 +++++++++++++++++ .../discourse/components/admin-translation.js | 29 ++++++++++++++++ .../components/admin-translation.js.es6 | 28 --------------- .../admin-multilingual-translations.js.es6 | 24 ------------- .../admin-multilingual-translations.hbs | 31 +---------------- .../admin-multilingual-translations.hbs | 31 +++++++++++++++++ .../components/admin-translation.hbs | 34 ++++++++++--------- 7 files changed, 110 insertions(+), 98 deletions(-) create mode 100644 assets/javascripts/discourse/components/admin-multilingual-translations.js create mode 100644 assets/javascripts/discourse/components/admin-translation.js delete mode 100644 assets/javascripts/discourse/components/admin-translation.js.es6 delete mode 100644 assets/javascripts/discourse/controllers/admin-multilingual-translations.js.es6 create mode 100644 assets/javascripts/discourse/templates/components/admin-multilingual-translations.hbs diff --git a/assets/javascripts/discourse/components/admin-multilingual-translations.js b/assets/javascripts/discourse/components/admin-multilingual-translations.js new file mode 100644 index 00000000..31c4b336 --- /dev/null +++ b/assets/javascripts/discourse/components/admin-multilingual-translations.js @@ -0,0 +1,31 @@ +import MultilingualTranslation from "../models/multilingual-translation"; +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; + +export default class AdminMultilingualTranslations extends Component { + @tracked refreshing = false; + @tracked translations = []; + + constructor() { + super(...arguments); + this._refresh(); + }; + + _refresh() { + this.refreshing = true; + + MultilingualTranslation.list() + .then((result) => { + this.translations = result; + }) + .finally(() => { + this.refreshing = false; + }); + }; + + @action + refresh() { + this._refresh(); + }; +}; diff --git a/assets/javascripts/discourse/components/admin-translation.js b/assets/javascripts/discourse/components/admin-translation.js new file mode 100644 index 00000000..c82f39f2 --- /dev/null +++ b/assets/javascripts/discourse/components/admin-translation.js @@ -0,0 +1,29 @@ +import MultilingualTranslation from "../models/multilingual-translation"; +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; + +export default class AdminTranslation extends Component { + @tracked removing = false; + + @action + remove() { + this.removing = true; + + MultilingualTranslation.remove( + this.args.translation.locale, + this.args.translation.file_type + ).then((result) => { + this.removing = false; + this.args.removed(); + }); + }; + + @action + download() { + MultilingualTranslation.download( + this.args.translation.locale, + this.args.translation.file_type + ); + }; +}; diff --git a/assets/javascripts/discourse/components/admin-translation.js.es6 b/assets/javascripts/discourse/components/admin-translation.js.es6 deleted file mode 100644 index 31b5fb89..00000000 --- a/assets/javascripts/discourse/components/admin-translation.js.es6 +++ /dev/null @@ -1,28 +0,0 @@ -import MultilingualTranslation from "../models/multilingual-translation"; -import Component from "@ember/component"; - -export default Component.extend({ - tagName: "tr", - classNames: "language", - - actions: { - remove() { - this.set("removing", true); - - MultilingualTranslation.remove( - this.get("translation.locale"), - this.get("translation.file_type") - ).then((result) => { - this.set("removing", false); - this.removed(result); - }); - }, - - download() { - MultilingualTranslation.download( - this.get("translation.locale"), - this.get("translation.file_type") - ); - }, - }, -}); diff --git a/assets/javascripts/discourse/controllers/admin-multilingual-translations.js.es6 b/assets/javascripts/discourse/controllers/admin-multilingual-translations.js.es6 deleted file mode 100644 index 77b24885..00000000 --- a/assets/javascripts/discourse/controllers/admin-multilingual-translations.js.es6 +++ /dev/null @@ -1,24 +0,0 @@ -import Controller from "@ember/controller"; -import MultilingualTranslation from "../models/multilingual-translation"; - -export default Controller.extend({ - refreshing: false, - - _refresh() { - this.set("refreshing", true); - - MultilingualTranslation.list() - .then((result) => { - this.set("translations", result); - }) - .finally(() => { - this.set("refreshing", false); - }); - }, - - actions: { - refresh() { - this._refresh(); - }, - }, -}); diff --git a/assets/javascripts/discourse/templates/admin-multilingual-translations.hbs b/assets/javascripts/discourse/templates/admin-multilingual-translations.hbs index 9b1f1fa5..d27eeb85 100644 --- a/assets/javascripts/discourse/templates/admin-multilingual-translations.hbs +++ b/assets/javascripts/discourse/templates/admin-multilingual-translations.hbs @@ -1,30 +1 @@ -
-
- {{multilingual-uploader - id="multilingual-translations-uploader" - uploading=uploading - done=(action "refresh") - uploadType="translation"}} -
-
- -{{#if refreshing}} - {{loading-spinner}} -{{else}} - {{#if translations}} - - - {{table-header-toggle field="locale" labelKey="multilingual.locale" automatic=true}} - {{table-header-toggle field="file_type" labelKey="multilingual.translations.type" automatic=true}} - - - - {{#each translations as |translation|}} - {{admin-translation translation=translation removed=(action "refresh")}} - {{/each}} - -
Actions
- {{else}} -

{{i18n "search.no_results"}}

- {{/if}} -{{/if}} + diff --git a/assets/javascripts/discourse/templates/components/admin-multilingual-translations.hbs b/assets/javascripts/discourse/templates/components/admin-multilingual-translations.hbs new file mode 100644 index 00000000..37a91999 --- /dev/null +++ b/assets/javascripts/discourse/templates/components/admin-multilingual-translations.hbs @@ -0,0 +1,31 @@ +
+
+ {{multilingual-uploader + id="multilingual-translations-uploader" + uploading=uploading + done=(action "refresh") + uploadType="translation"}} +
+
+ +{{#if refreshing}} +blah + {{loading-spinner}} +{{else}} + {{#if this.translations}} + + + {{table-header-toggle field="locale" labelKey="multilingual.locale" automatic=true}} + {{table-header-toggle field="file_type" labelKey="multilingual.translations.type" automatic=true}} + + + + {{#each this.translations as |translation|}} + {{admin-translation translation=translation removed=(action this.refresh)}} + {{/each}} + +
Actions
+ {{else}} +

{{i18n "search.no_results"}}

+ {{/if}} +{{/if}} diff --git a/assets/javascripts/discourse/templates/components/admin-translation.hbs b/assets/javascripts/discourse/templates/components/admin-translation.hbs index e4a4d54b..3c1f5b12 100644 --- a/assets/javascripts/discourse/templates/components/admin-translation.hbs +++ b/assets/javascripts/discourse/templates/components/admin-translation.hbs @@ -1,18 +1,20 @@ - - {{translation.locale}} - + + + {{this.args.translation.locale}} + - - {{translation.file_type}} - + + {{this.args.translation.file_type}} + - - {{#d-button click=(action "remove")}} - {{#if removing}} - {{loading-spinner size="small"}} - {{else}} - {{d-icon "times"}} - {{i18n "multilingual.translations.remove"}} - {{/if}} - {{/d-button}} - + + + {{#if removing}} + {{loading-spinner size="small"}} + {{else}} + {{d-icon "times"}} + {{i18n "multilingual.translations.remove"}} + {{/if}} + + + From 523f37f3dc4a0b2612f465b75eed8e1c7bc3b181 Mon Sep 17 00:00:00 2001 From: merefield Date: Mon, 20 Feb 2023 20:03:07 +0000 Subject: [PATCH 02/13] COMPATIBILITY: move d-button actions to closure actions --- .../discourse/templates/admin-multilingual-languages.hbs | 2 +- assets/javascripts/discourse/templates/admin-multilingual.hbs | 2 +- .../discourse/templates/components/admin-language.hbs | 2 +- .../discourse/templates/components/language-switcher-bar.hbs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/javascripts/discourse/templates/admin-multilingual-languages.hbs b/assets/javascripts/discourse/templates/admin-multilingual-languages.hbs index ee0b7cef..7281639b 100644 --- a/assets/javascripts/discourse/templates/admin-multilingual-languages.hbs +++ b/assets/javascripts/discourse/templates/admin-multilingual-languages.hbs @@ -16,7 +16,7 @@ done=(action "languagesUploaded")}} {{d-button - action="update" + action=(action "update") class="btn-primary" icon="save" label=updateState diff --git a/assets/javascripts/discourse/templates/admin-multilingual.hbs b/assets/javascripts/discourse/templates/admin-multilingual.hbs index c6fdb950..551a9297 100644 --- a/assets/javascripts/discourse/templates/admin-multilingual.hbs +++ b/assets/javascripts/discourse/templates/admin-multilingual.hbs @@ -18,7 +18,7 @@
  • {{d-button - action="showSettings" + action=(route-action "showSettings") label="admin.plugins.change_settings_short" icon="cog"}}
  • diff --git a/assets/javascripts/discourse/templates/components/admin-language.hbs b/assets/javascripts/discourse/templates/components/admin-language.hbs index d9e6ce72..9f5f9b24 100644 --- a/assets/javascripts/discourse/templates/components/admin-language.hbs +++ b/assets/javascripts/discourse/templates/components/admin-language.hbs @@ -41,7 +41,7 @@ {{#if actionsDisabled}} {{i18n "multilingual.languages.disabled"}} {{else}} - {{#d-button click=(action "remove") disabled=removing}} + {{#d-button action=(action "remove") disabled=removing}} {{#if removing}} {{loading-spinner size="small"}} {{else}} diff --git a/assets/javascripts/discourse/templates/components/language-switcher-bar.hbs b/assets/javascripts/discourse/templates/components/language-switcher-bar.hbs index 4fbb1149..722d9074 100644 --- a/assets/javascripts/discourse/templates/components/language-switcher-bar.hbs +++ b/assets/javascripts/discourse/templates/components/language-switcher-bar.hbs @@ -1,7 +1,7 @@ {{#each visibleLanguages as |l|}}
    {{l.name}}
    {{/each}} {{#if showHiddenToggle}} - {{d-button icon="plus" action="toggleHidden" class="toggle-hidden"}} + {{d-button icon="plus" action=(action "toggleHidden") class="toggle-hidden"}} {{#if showHidden}}
    From 479376b18b3fbde1bae9def9e17a1696628fb00e Mon Sep 17 00:00:00 2001 From: merefield Date: Mon, 20 Feb 2023 21:16:03 +0000 Subject: [PATCH 03/13] COMPATIBILITY: fix and move content language discovery dropdown to Glimmer --- .../components/content-language-discovery.js | 90 +++++++++++++++++++ .../before-create-topic-button.hbs | 1 + .../content-language-discovery.hbs | 5 -- .../content-language-discovery.js.es6 | 57 ------------ .../components/content-language-discovery.hbs | 7 ++ 5 files changed, 98 insertions(+), 62 deletions(-) create mode 100644 assets/javascripts/discourse/components/content-language-discovery.js create mode 100644 assets/javascripts/discourse/connectors/before-create-topic-button/before-create-topic-button.hbs delete mode 100644 assets/javascripts/discourse/connectors/before-create-topic-button/content-language-discovery.hbs delete mode 100644 assets/javascripts/discourse/connectors/before-create-topic-button/content-language-discovery.js.es6 create mode 100644 assets/javascripts/discourse/templates/components/content-language-discovery.hbs diff --git a/assets/javascripts/discourse/components/content-language-discovery.js b/assets/javascripts/discourse/components/content-language-discovery.js new file mode 100644 index 00000000..5326b76e --- /dev/null +++ b/assets/javascripts/discourse/components/content-language-discovery.js @@ -0,0 +1,90 @@ +import Component from '@glimmer/component'; +import { inject as service } from "@ember/service"; +import { isContentLanguage } from "../lib/multilingual"; +import { + contentLanguageParam, + getDiscoveryParam, + getRouter, +} from "../lib/multilingual-route"; +import I18n from "I18n"; +// import { on } from "@ember/object/evented"; +// import { scheduleOnce } from "@ember/runloop"; + +export default class ContentLanguageDiscovery extends Component { + @service siteSettings; + @service currentUser; + @service router; + + get shouldRender() { + return ( + this.siteSettings.multilingual_enabled && + this.siteSettings.multilingual_content_languages_enabled && + this.siteSettings.multilingual_content_languages_topic_filtering_enabled && + (this.currentUser || + this.router.currentRouteName.indexOf("categories") === -1) + ); + }; + + get contentLanguages() { + let contentLangs = this.currentUser + ? this.currentUser.content_languages + : this.site.content_languages; + + if (contentLangs) { + if (this.currentUser) { + if (!contentLangs.some((l) => l.locale === "set_content_language")) { + contentLangs.push({ + icon: "plus", + locale: "set_content_language", + name: I18n.t("user.content_languages.set"), + }); + } + } else { + contentLangs.forEach((l) => { + set(l, "classNames", "guest-content-language"); + }); + } + } + return contentLangs + }; + + get hasLanguages() { + let hasLangs; + + if (this.currentUser && this.contentLanguages) { + hasLangs = + this.contentLanguages.filter((l) => + isContentLanguage(l.locale, this.siteSettings) + ).length > 0; + } else { + hasLangs = getDiscoveryParam(this, contentLanguageParam); + } + return hasLangs; + } + + // if (this.contentLanguages) { + // if (this.currentUser) { + // hasLanguages = + // this.contentLanguages.filter((l) => + // isContentLanguage(l.locale, this.siteSettings) + // ).length > 0; + + // if (!this.contentLanguages.some((l) => l.locale === "set_content_language")) { + // contentLanguages.push({ + // icon: "plus", + // locale: "set_content_language", + // name: I18n.t("user.content_languages.set"), + // }); + // } + // } else { + // hasLanguages = getDiscoveryParam(this, contentLanguageParam); + + // contentLanguages.forEach((l) => { + // set(l, "classNames", "guest-content-language"); + // }); + // } + // debugger; + + // ctx.setProperties({ contentLanguages, hasLanguages }); + +}; diff --git a/assets/javascripts/discourse/connectors/before-create-topic-button/before-create-topic-button.hbs b/assets/javascripts/discourse/connectors/before-create-topic-button/before-create-topic-button.hbs new file mode 100644 index 00000000..9ce13382 --- /dev/null +++ b/assets/javascripts/discourse/connectors/before-create-topic-button/before-create-topic-button.hbs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/javascripts/discourse/connectors/before-create-topic-button/content-language-discovery.hbs b/assets/javascripts/discourse/connectors/before-create-topic-button/content-language-discovery.hbs deleted file mode 100644 index 1a7393d5..00000000 --- a/assets/javascripts/discourse/connectors/before-create-topic-button/content-language-discovery.hbs +++ /dev/null @@ -1,5 +0,0 @@ -{{content-languages-dropdown - content=contentLanguages - options=(hash - hasLanguages=hasLanguages - )}} diff --git a/assets/javascripts/discourse/connectors/before-create-topic-button/content-language-discovery.js.es6 b/assets/javascripts/discourse/connectors/before-create-topic-button/content-language-discovery.js.es6 deleted file mode 100644 index da1d7430..00000000 --- a/assets/javascripts/discourse/connectors/before-create-topic-button/content-language-discovery.js.es6 +++ /dev/null @@ -1,57 +0,0 @@ -import { set } from "@ember/object"; -import { isContentLanguage } from "../../lib/multilingual"; -import { - contentLanguageParam, - getDiscoveryParam, - getRouter, -} from "../../lib/multilingual-route"; -import I18n from "I18n"; - -export default { - shouldRender(attrs, ctx) { - return ( - ctx.siteSettings.multilingual_enabled && - ctx.siteSettings.multilingual_content_languages_enabled && - ctx.siteSettings.multilingual_content_languages_topic_filtering_enabled && - (this.currentUser || - getRouter(ctx).currentRouteName.indexOf("categories") === -1) - ); - }, - - setupComponent(attrs, ctx) { - const currentUser = ctx.get("currentUser"); - const site = ctx.get("site"); - - let hasLanguages; - let contentLanguages = currentUser - ? currentUser.get("content_languages") - : site.get("content_languages"); - - if (!contentLanguages) { - return; - } - - if (currentUser) { - hasLanguages = - contentLanguages.filter((l) => - isContentLanguage(l.locale, ctx.siteSettings) - ).length > 0; - - if (!contentLanguages.some((l) => l.locale === "set_content_language")) { - contentLanguages.push({ - icon: "plus", - locale: "set_content_language", - name: I18n.t("user.content_languages.set"), - }); - } - } else { - hasLanguages = getDiscoveryParam(ctx, contentLanguageParam); - - contentLanguages.forEach((l) => { - set(l, "classNames", "guest-content-language"); - }); - } - - ctx.setProperties({ contentLanguages, hasLanguages }); - }, -}; diff --git a/assets/javascripts/discourse/templates/components/content-language-discovery.hbs b/assets/javascripts/discourse/templates/components/content-language-discovery.hbs new file mode 100644 index 00000000..d751bd78 --- /dev/null +++ b/assets/javascripts/discourse/templates/components/content-language-discovery.hbs @@ -0,0 +1,7 @@ +{{#if this.shouldRender}} +{{content-languages-dropdown + content=this.contentLanguages + options=(hash + hasLanguages=this.hasLanguages + )}} +{{/if}} \ No newline at end of file From f5504000f0e5c046ea817c0ec03e193b809e29ff Mon Sep 17 00:00:00 2001 From: merefield Date: Mon, 20 Feb 2023 21:21:30 +0000 Subject: [PATCH 04/13] Clean up code --- .../components/content-language-discovery.js | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/assets/javascripts/discourse/components/content-language-discovery.js b/assets/javascripts/discourse/components/content-language-discovery.js index 5326b76e..b22a29f9 100644 --- a/assets/javascripts/discourse/components/content-language-discovery.js +++ b/assets/javascripts/discourse/components/content-language-discovery.js @@ -7,8 +7,6 @@ import { getRouter, } from "../lib/multilingual-route"; import I18n from "I18n"; -// import { on } from "@ember/object/evented"; -// import { scheduleOnce } from "@ember/runloop"; export default class ContentLanguageDiscovery extends Component { @service siteSettings; @@ -61,30 +59,4 @@ export default class ContentLanguageDiscovery extends Component { } return hasLangs; } - - // if (this.contentLanguages) { - // if (this.currentUser) { - // hasLanguages = - // this.contentLanguages.filter((l) => - // isContentLanguage(l.locale, this.siteSettings) - // ).length > 0; - - // if (!this.contentLanguages.some((l) => l.locale === "set_content_language")) { - // contentLanguages.push({ - // icon: "plus", - // locale: "set_content_language", - // name: I18n.t("user.content_languages.set"), - // }); - // } - // } else { - // hasLanguages = getDiscoveryParam(this, contentLanguageParam); - - // contentLanguages.forEach((l) => { - // set(l, "classNames", "guest-content-language"); - // }); - // } - // debugger; - - // ctx.setProperties({ contentLanguages, hasLanguages }); - }; From 480e1b1266c7117f48c394e40e27e0654d90e8ea Mon Sep 17 00:00:00 2001 From: merefield Date: Mon, 20 Feb 2023 21:22:23 +0000 Subject: [PATCH 05/13] Clean up code some more --- .../discourse/components/content-language-discovery.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/assets/javascripts/discourse/components/content-language-discovery.js b/assets/javascripts/discourse/components/content-language-discovery.js index b22a29f9..d63a695d 100644 --- a/assets/javascripts/discourse/components/content-language-discovery.js +++ b/assets/javascripts/discourse/components/content-language-discovery.js @@ -3,8 +3,7 @@ import { inject as service } from "@ember/service"; import { isContentLanguage } from "../lib/multilingual"; import { contentLanguageParam, - getDiscoveryParam, - getRouter, + getDiscoveryParam } from "../lib/multilingual-route"; import I18n from "I18n"; From 1877444fe9bddb171cd17cba26e0fd1d33179ab8 Mon Sep 17 00:00:00 2001 From: merefield Date: Mon, 20 Feb 2023 21:25:51 +0000 Subject: [PATCH 06/13] linting --- .../components/admin-multilingual-translations.js | 2 +- .../discourse/components/content-language-discovery.js | 10 +++++----- .../before-create-topic-button.hbs | 2 +- .../components/admin-multilingual-translations.hbs | 1 - .../components/content-language-discovery.hbs | 2 +- .../templates/components/content-tag-groups-form.hbs | 1 - 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/assets/javascripts/discourse/components/admin-multilingual-translations.js b/assets/javascripts/discourse/components/admin-multilingual-translations.js index 31c4b336..8e7dca76 100644 --- a/assets/javascripts/discourse/components/admin-multilingual-translations.js +++ b/assets/javascripts/discourse/components/admin-multilingual-translations.js @@ -17,7 +17,7 @@ export default class AdminMultilingualTranslations extends Component { MultilingualTranslation.list() .then((result) => { - this.translations = result; + this.translations = result; }) .finally(() => { this.refreshing = false; diff --git a/assets/javascripts/discourse/components/content-language-discovery.js b/assets/javascripts/discourse/components/content-language-discovery.js index d63a695d..fc86942b 100644 --- a/assets/javascripts/discourse/components/content-language-discovery.js +++ b/assets/javascripts/discourse/components/content-language-discovery.js @@ -18,19 +18,19 @@ export default class ContentLanguageDiscovery extends Component { this.siteSettings.multilingual_content_languages_enabled && this.siteSettings.multilingual_content_languages_topic_filtering_enabled && (this.currentUser || - this.router.currentRouteName.indexOf("categories") === -1) + this.router.currentRouteName.indexOf("categories") === -1) ); }; get contentLanguages() { let contentLangs = this.currentUser - ? this.currentUser.content_languages - : this.site.content_languages; + ? this.currentUser.content_languages + : this.site.content_languages; if (contentLangs) { if (this.currentUser) { - if (!contentLangs.some((l) => l.locale === "set_content_language")) { - contentLangs.push({ + if (!contentLangs.some((l) => l.locale === "set_content_language")) { + contentLangs.push({ icon: "plus", locale: "set_content_language", name: I18n.t("user.content_languages.set"), diff --git a/assets/javascripts/discourse/connectors/before-create-topic-button/before-create-topic-button.hbs b/assets/javascripts/discourse/connectors/before-create-topic-button/before-create-topic-button.hbs index 9ce13382..35d6177d 100644 --- a/assets/javascripts/discourse/connectors/before-create-topic-button/before-create-topic-button.hbs +++ b/assets/javascripts/discourse/connectors/before-create-topic-button/before-create-topic-button.hbs @@ -1 +1 @@ - \ No newline at end of file + diff --git a/assets/javascripts/discourse/templates/components/admin-multilingual-translations.hbs b/assets/javascripts/discourse/templates/components/admin-multilingual-translations.hbs index 37a91999..235a5aff 100644 --- a/assets/javascripts/discourse/templates/components/admin-multilingual-translations.hbs +++ b/assets/javascripts/discourse/templates/components/admin-multilingual-translations.hbs @@ -9,7 +9,6 @@
    {{#if refreshing}} -blah {{loading-spinner}} {{else}} {{#if this.translations}} diff --git a/assets/javascripts/discourse/templates/components/content-language-discovery.hbs b/assets/javascripts/discourse/templates/components/content-language-discovery.hbs index d751bd78..7c169164 100644 --- a/assets/javascripts/discourse/templates/components/content-language-discovery.hbs +++ b/assets/javascripts/discourse/templates/components/content-language-discovery.hbs @@ -4,4 +4,4 @@ options=(hash hasLanguages=this.hasLanguages )}} -{{/if}} \ No newline at end of file +{{/if}} diff --git a/assets/javascripts/discourse/templates/components/content-tag-groups-form.hbs b/assets/javascripts/discourse/templates/components/content-tag-groups-form.hbs index 304025c3..d9b609ec 100644 --- a/assets/javascripts/discourse/templates/components/content-tag-groups-form.hbs +++ b/assets/javascripts/discourse/templates/components/content-tag-groups-form.hbs @@ -40,4 +40,3 @@ label="tagging.groups.content_tags.delete.btn"}} - From defc02e92f7a814c76179a765a884fe2ab6477db Mon Sep 17 00:00:00 2001 From: merefield Date: Tue, 21 Feb 2023 09:23:43 +0000 Subject: [PATCH 07/13] FIX: tests not firing on PR, try alternative --- .github/workflows/plugin-tests.yml | 46 ++++++++++++++---------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/.github/workflows/plugin-tests.yml b/.github/workflows/plugin-tests.yml index d443118e..622c4c1a 100644 --- a/.github/workflows/plugin-tests.yml +++ b/.github/workflows/plugin-tests.yml @@ -8,6 +8,10 @@ on: schedule: - cron: '0 */12 * * *' +concurrency: + group: plugin-tests-${{ format('{0}-{1}', github.head_ref || github.run_number, github.job) }} + cancel-in-progress: true + jobs: build: name: ${{ matrix.build_type }} @@ -29,10 +33,6 @@ jobs: build_type: ["backend", "frontend"] steps: - - name: Find plugin name - run: | - echo "PLUGIN_REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV - - uses: actions/checkout@v3 with: repository: discourse/discourse @@ -41,7 +41,7 @@ jobs: - name: Install plugin uses: actions/checkout@v3 with: - path: plugins/${{ env.PLUGIN_REPOSITORY_NAME }} + path: plugins/${{ github.event.repository.name }} fetch-depth: 1 - name: Setup Git @@ -78,7 +78,7 @@ jobs: - name: Lint English locale if: matrix.build_type == 'backend' - run: bundle exec ruby script/i18n_lint.rb "plugins/${{ env.PLUGIN_REPOSITORY_NAME }}/locales/{client,server}.en.yml" + run: bundle exec ruby script/i18n_lint.rb "plugins/${{ github.event.repository.name }}/locales/{client,server}.en.yml" - name: Get yarn cache directory id: yarn-cache-dir @@ -129,27 +129,25 @@ jobs: - name: Check spec existence id: check_spec - uses: andstor/file-existence-action@v1 - with: - files: "plugins/${{ env.PLUGIN_REPOSITORY_NAME }}/spec" + shell: bash + run: | + if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/spec -type f -name "*.rb" 2> /dev/null | wc -l) ]; then + echo "::set-output name=files_exist::true" + fi - - name: Check qunit existence - id: check_qunit - uses: andstor/file-existence-action@v1 - with: - files: "plugins/${{ env.PLUGIN_REPOSITORY_NAME }}/test/javascripts" + - name: Plugin RSpec + if: matrix.build_type == 'backend' && steps.check_spec.outputs.files_exist == 'true' + run: bin/rake plugin:spec[${{ github.event.repository.name }}] - - name: Plugin RSpec with Coverage - if: matrix.build_type == 'backend' + - name: Check QUnit existence + id: check_qunit + shell: bash run: | - if [ -e plugins/${{ env.PLUGIN_REPOSITORY_NAME }}/.simplecov ] - then - cp plugins/${{ env.PLUGIN_REPOSITORY_NAME }}/.simplecov .simplecov - export COVERAGE=1 + if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/test/javascripts -type f \( -name "*.js" -or -name "*.es6" \) 2> /dev/null | wc -l) ]; then + echo "::set-output name=files_exist::true" fi - bin/rake plugin:spec[${{ env.PLUGIN_REPOSITORY_NAME }}] - name: Plugin QUnit - if: matrix.build_type == 'frontend' && steps.check_qunit.outputs.files_exists == 'true' - run: bin/rake plugin:qunit['${{ env.PLUGIN_REPOSITORY_NAME }}','1200000'] - timeout-minutes: 30 + if: matrix.build_type == 'frontend' && steps.check_qunit.outputs.files_exist == 'true' + run: QUNIT_EMBER_CLI=1 bundle exec rake plugin:qunit['${{ github.event.repository.name }}','1200000'] + timeout-minutes: 10 From 9e3d65291666681c134e78d2c98d26aa2fd2b3a7 Mon Sep 17 00:00:00 2001 From: merefield Date: Tue, 21 Feb 2023 09:26:00 +0000 Subject: [PATCH 08/13] FIX: tests not firing on PR, try alternative --- .github/workflows/plugin-tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/plugin-tests.yml b/.github/workflows/plugin-tests.yml index 622c4c1a..9d390bc6 100644 --- a/.github/workflows/plugin-tests.yml +++ b/.github/workflows/plugin-tests.yml @@ -5,8 +5,6 @@ on: branches: - main pull_request: - schedule: - - cron: '0 */12 * * *' concurrency: group: plugin-tests-${{ format('{0}-{1}', github.head_ref || github.run_number, github.job) }} From a2582806d225375ff9ef5b5baae5188148bb238a Mon Sep 17 00:00:00 2001 From: merefield Date: Tue, 21 Feb 2023 09:30:58 +0000 Subject: [PATCH 09/13] FIX: tests not firing on PR, try alternative --- .github/workflows/plugin-linting.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/plugin-linting.yml b/.github/workflows/plugin-linting.yml index a9303a71..ccf6bb9c 100644 --- a/.github/workflows/plugin-linting.yml +++ b/.github/workflows/plugin-linting.yml @@ -3,11 +3,8 @@ name: Linting on: push: branches: - - master - main pull_request: - schedule: - - cron: '0 0 * * *' jobs: build: From c16150632d1980404af15725e0607f8b87117e2b Mon Sep 17 00:00:00 2001 From: merefield Date: Tue, 21 Feb 2023 10:42:02 +0000 Subject: [PATCH 10/13] bump patch --- plugin.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.rb b/plugin.rb index 9f6c5958..32f024bb 100644 --- a/plugin.rb +++ b/plugin.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # name: discourse-multilingual # about: Features to support multilingual forums -# version: 0.2.6 +# version: 0.2.7 # url: https://github.com/paviliondev/discourse-multilingual # authors: Angus McLeod, Robert Barrow # contact_emails: development@pavilion.tech From be819033dc1150c871945f4e472f0743512d442c Mon Sep 17 00:00:00 2001 From: merefield Date: Wed, 22 Feb 2023 16:29:03 +0000 Subject: [PATCH 11/13] FIX: breaking test due to discourse/discourse #19916 --- spec/components/tag_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/components/tag_spec.rb b/spec/components/tag_spec.rb index e23301cd..88f5baaa 100644 --- a/spec/components/tag_spec.rb +++ b/spec/components/tag_spec.rb @@ -5,6 +5,7 @@ describe Tag do fab!(:tag1) { Fabricate(:tag, name: "fun") } fab!(:tag2) { Fabricate(:tag, name: "fun2") } + fab!(:public_category) { Fabricate(:category) } before do SiteSetting.tagging_enabled = true @@ -16,7 +17,7 @@ end it "top_tags doesn't include content language tags" do - Fabricate(:topic, tags: [tag1, tag2, Tag.find_by(name: 'fr')]) - expect(Tag.top_tags).not_to include(Tag.find_by(name: 'fr').name) + Fabricate(:topic, category: public_category, tags: [tag1, tag2, Tag.find_by(name: 'fr')]) + expect(Tag.top_tags(category: public_category, guardian: Guardian.new(Fabricate(:user)))).not_to include(Tag.find_by(name: 'fr').name) end end From bb2329914c2f23fa504560c96974b1915f9bbe2b Mon Sep 17 00:00:00 2001 From: merefield Date: Wed, 22 Feb 2023 16:44:54 +0000 Subject: [PATCH 12/13] Revert removal of cron --- .github/workflows/plugin-linting.yml | 2 ++ .github/workflows/plugin-tests.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/plugin-linting.yml b/.github/workflows/plugin-linting.yml index ccf6bb9c..e5e2babc 100644 --- a/.github/workflows/plugin-linting.yml +++ b/.github/workflows/plugin-linting.yml @@ -5,6 +5,8 @@ on: branches: - main pull_request: + schedule: + - cron: '0 */12 * * *' jobs: build: diff --git a/.github/workflows/plugin-tests.yml b/.github/workflows/plugin-tests.yml index 9d390bc6..20b0bf3b 100644 --- a/.github/workflows/plugin-tests.yml +++ b/.github/workflows/plugin-tests.yml @@ -5,6 +5,8 @@ on: branches: - main pull_request: + schedule: + - cron: '0 0 * * *' concurrency: group: plugin-tests-${{ format('{0}-{1}', github.head_ref || github.run_number, github.job) }} From 65fda9c4543e025b45348c88752259568d415d4d Mon Sep 17 00:00:00 2001 From: merefield Date: Wed, 22 Feb 2023 16:46:15 +0000 Subject: [PATCH 13/13] Revert removal of cron --- .github/workflows/plugin-linting.yml | 2 +- .github/workflows/plugin-tests.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/plugin-linting.yml b/.github/workflows/plugin-linting.yml index e5e2babc..2847e667 100644 --- a/.github/workflows/plugin-linting.yml +++ b/.github/workflows/plugin-linting.yml @@ -6,7 +6,7 @@ on: - main pull_request: schedule: - - cron: '0 */12 * * *' + - cron: '0 0 * * *' jobs: build: diff --git a/.github/workflows/plugin-tests.yml b/.github/workflows/plugin-tests.yml index 20b0bf3b..622c4c1a 100644 --- a/.github/workflows/plugin-tests.yml +++ b/.github/workflows/plugin-tests.yml @@ -6,7 +6,7 @@ on: - main pull_request: schedule: - - cron: '0 0 * * *' + - cron: '0 */12 * * *' concurrency: group: plugin-tests-${{ format('{0}-{1}', github.head_ref || github.run_number, github.job) }}