Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/plugin-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: Linting
on:
push:
branches:
- master
- main
pull_request:
schedule:
Expand Down
46 changes: 22 additions & 24 deletions .github/workflows/plugin-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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();
};
};
29 changes: 29 additions & 0 deletions assets/javascripts/discourse/components/admin-translation.js
Original file line number Diff line number Diff line change
@@ -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
);
};
};
28 changes: 0 additions & 28 deletions assets/javascripts/discourse/components/admin-translation.js.es6

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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;
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<ContentLanguageDiscovery/>

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
done=(action "languagesUploaded")}}

{{d-button
action="update"
action=(action "update")
class="btn-primary"
icon="save"
label=updateState
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1 @@
<div class="controls">
<div class="buttons">
{{multilingual-uploader
id="multilingual-translations-uploader"
uploading=uploading
done=(action "refresh")
uploadType="translation"}}
</div>
</div>

{{#if refreshing}}
{{loading-spinner}}
{{else}}
{{#if translations}}
<table class="table translations-list grid">
<thead>
{{table-header-toggle field="locale" labelKey="multilingual.locale" automatic=true}}
{{table-header-toggle field="file_type" labelKey="multilingual.translations.type" automatic=true}}
<th>Actions</th>
</thead>
<tbody>
{{#each translations as |translation|}}
{{admin-translation translation=translation removed=(action "refresh")}}
{{/each}}
</tbody>
</table>
{{else}}
<p>{{i18n "search.no_results"}}</p>
{{/if}}
{{/if}}
<AdminMultilingualTranslations/>
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</a>
<li>
{{d-button
action="showSettings"
action=(route-action "showSettings")
label="admin.plugins.change_settings_short"
icon="cog"}}
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
Loading