diff --git a/.github/workflows/plugin-linting.yml b/.github/workflows/plugin-linting.yml
index a9303a71..2847e667 100644
--- a/.github/workflows/plugin-linting.yml
+++ b/.github/workflows/plugin-linting.yml
@@ -3,7 +3,6 @@ name: Linting
on:
push:
branches:
- - master
- main
pull_request:
schedule:
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
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..8e7dca76
--- /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/components/content-language-discovery.js b/assets/javascripts/discourse/components/content-language-discovery.js
new file mode 100644
index 00000000..fc86942b
--- /dev/null
+++ b/assets/javascripts/discourse/components/content-language-discovery.js
@@ -0,0 +1,61 @@
+import Component from '@glimmer/component';
+import { inject as service } from "@ember/service";
+import { isContentLanguage } from "../lib/multilingual";
+import {
+ contentLanguageParam,
+ getDiscoveryParam
+} from "../lib/multilingual-route";
+import I18n from "I18n";
+
+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;
+ }
+};
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..35d6177d
--- /dev/null
+++ b/assets/javascripts/discourse/connectors/before-create-topic-button/before-create-topic-button.hbs
@@ -0,0 +1 @@
+
| Actions | - - - {{#each translations as |translation|}} - {{admin-translation translation=translation removed=(action "refresh")}} - {{/each}} - -
|---|
{{i18n "search.no_results"}}
- {{/if}} -{{/if}} +| Actions | + + + {{#each this.translations as |translation|}} + {{admin-translation translation=translation removed=(action this.refresh)}} + {{/each}} + +
|---|
{{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 @@ -