DEV: Consistent AdminConfigAreaEmptyList options (#29975)

Followup ccc8e37dde6dd16de1f1103d60065c1b5afcbc6e

The fix above was good, but I would prefer to give
the option of untranslated vs translated label like
I have for other admin components for consistency.
This commit is contained in:
Martin Brennan 2024-11-28 15:31:04 +10:00 committed by GitHub
parent cb819ab49a
commit 1f538a81a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 31 additions and 21 deletions

View File

@ -1,23 +1,33 @@
import Component from "@glimmer/component";
import { htmlSafe } from "@ember/template";
import DButton from "discourse/components/d-button";
import concatClass from "discourse/helpers/concat-class";
import { i18n } from "discourse-i18n";
const AdminConfigAreaEmptyList = <template>
<div class="admin-config-area-empty-list">
{{htmlSafe @emptyLabel}}
export default class AdminConfigAreaEmptyList extends Component {
get emptyLabel() {
if (this.args.emptyLabelTranslated) {
return this.args.emptyLabelTranslated;
}
{{#if @ctaLabel}}
<DButton
@label={{@ctaLabel}}
class={{concatClass
"btn-default btn-small admin-config-area-empty-list__cta-button"
@ctaClass
}}
@action={{@ctaAction}}
@route={{@ctaRoute}}
/>
{{/if}}
</div>
</template>;
return i18n(this.args.emptyLabel);
}
export default AdminConfigAreaEmptyList;
<template>
<div class="admin-config-area-empty-list">
{{htmlSafe this.emptyLabel}}
{{#if @ctaLabel}}
<DButton
@label={{@ctaLabel}}
class={{concatClass
"btn-default btn-small admin-config-area-empty-list__cta-button"
@ctaClass
}}
@action={{@ctaAction}}
@route={{@ctaRoute}}
/>
{{/if}}
</div>
</template>
}

View File

@ -91,7 +91,7 @@ export default class AdminConfigAreasEmojisList extends Component {
@ctaLabel="admin.emoji.add"
@ctaRoute="adminEmojis.new"
@ctaClass="admin-emojis__add-emoji"
@emptyLabel={{i18n "admin.emoji.no_emoji"}}
@emptyLabel="admin.emoji.no_emoji"
/>
{{/if}}
</template>

View File

@ -97,7 +97,7 @@ export default class AdminConfigAreasUserFieldsList extends Component {
@ctaLabel="admin.user_fields.add"
@ctaRoute="adminUserFields.new"
@ctaClass="admin-user_fields__add-emoji"
@emptyLabel={{i18n "admin.user_fields.no_user_fields"}}
@emptyLabel="admin.user_fields.no_user_fields"
/>
{{/if}}
</div>

View File

@ -72,7 +72,7 @@ export default class DashboardNewFeatures extends Component {
</AdminConfigAreaCard>
{{else}}
<AdminConfigAreaEmptyList
@emptyLabel={{i18n
@emptyLabelTranslated={{i18n
"admin.dashboard.new_features.previous_announcements"
url="https://meta.discourse.org/tags/c/announcements/67/release-notes"
}}

View File

@ -127,7 +127,7 @@
@ctaLabel="admin.permalink.add"
@ctaRoute="adminPermalinks.new"
@ctaClass="admin-permalinks__add-permalink"
@emptyLabel={{i18n "admin.permalink.no_permalinks"}}
@emptyLabel="admin.permalink.no_permalinks"
/>
{{/if}}
{{/if}}