mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 19:02:51 +08:00
Consolidates reusable UI primitives from `app/components/`,
`app/helpers/`, and `app/modifiers/` into a dedicated `app/ui-kit/`
directory under a unified `d-` prefix naming convention. This gives
Discourse a single, discoverable home for the building-block parts of
the UI: generic primitives (buttons, inputs, modals, selects), layout
pieces (page headers, breadcrumbs, stat tiles), and lightly
Discourse-flavored display widgets (user info, badges, cook-text).
Helpers and modifiers live in `app/ui-kit/helpers/` and
`app/ui-kit/modifiers/` respectively.
### Backward compatibility
No existing imports or template invocations need to change. Old import
paths (e.g. `discourse/components/d-button`, `discourse/helpers/d-icon`)
keep working via runtime AMD `loaderShim` entries in
`app/ui-kit-shims.js`, so plugins and themes need zero changes.
An ESLint rule (shipped via `@discourse/lint-configs` 2.46.0) auto-fixes
imports in the codebase to use the new `discourse/ui-kit/...` paths.
Existing consumer files in `app/`, `admin/`, `plugins/`, and `frontend/`
have been re-imported through that rule in a single sweep, so the
codebase stays consistent.
### Tests
Test module identifiers and file paths now match the ui-kit directory
layout (`tests/integration/ui-kit/...`, `module("Integration | ui-kit |
...")`), keeping the test tree symmetric with `app/ui-kit/`.
110 lines
3 KiB
Text
Vendored
110 lines
3 KiB
Text
Vendored
import Component from "@glimmer/component";
|
|
import { fn } from "@ember/helper";
|
|
import { action } from "@ember/object";
|
|
import { service } from "@ember/service";
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
import DButton from "discourse/ui-kit/d-button";
|
|
import dCategoryLink from "discourse/ui-kit/helpers/d-category-link";
|
|
import { i18n } from "discourse-i18n";
|
|
import getTagName from "../lib/utilities";
|
|
|
|
export default class RuleRow extends Component {
|
|
@service siteSettings;
|
|
@service dialog;
|
|
|
|
get isCategory() {
|
|
return this.args.rule.type === "normal";
|
|
}
|
|
|
|
get isMessage() {
|
|
return this.args.rule.type === "group_message";
|
|
}
|
|
|
|
get isMention() {
|
|
return this.args.rule.type === "group_mention";
|
|
}
|
|
|
|
get displayTags() {
|
|
const tags = this.args.rule.tags;
|
|
if (!tags) {
|
|
return null;
|
|
}
|
|
return tags.map((tag) => getTagName(tag)).join(", ");
|
|
}
|
|
|
|
@action
|
|
delete(rule) {
|
|
this.dialog.deleteConfirm({
|
|
message: i18n("chat_integration.channel_delete_confirm"),
|
|
didConfirm: () => {
|
|
return rule
|
|
.destroyRecord()
|
|
.then(() => this.args.refresh())
|
|
.catch(popupAjaxError);
|
|
},
|
|
});
|
|
}
|
|
|
|
<template>
|
|
<tr class="d-table__row">
|
|
<td class="d-table__cell --overview rule-filter">
|
|
{{@rule.filterName}}
|
|
</td>
|
|
|
|
<td class="d-table__cell --detail rule-category">
|
|
<div class="d-table__mobile-label">
|
|
{{i18n "chat_integration.rule_table.category"}}
|
|
</div>
|
|
{{#if this.isCategory}}
|
|
{{#if @rule.category}}
|
|
{{dCategoryLink
|
|
@rule.category
|
|
allowUncategorized="true"
|
|
link="false"
|
|
}}
|
|
{{else}}
|
|
{{i18n "chat_integration.all_categories"}}
|
|
{{/if}}
|
|
{{else if this.isMention}}
|
|
{{i18n
|
|
"chat_integration.group_mention_template"
|
|
name=@rule.group_name
|
|
}}
|
|
{{else if this.isMessage}}
|
|
{{i18n
|
|
"chat_integration.group_message_template"
|
|
name=@rule.group_name
|
|
}}
|
|
{{/if}}
|
|
</td>
|
|
|
|
{{#if this.siteSettings.tagging_enabled}}
|
|
<td class="d-table__cell --detail rule-tags">
|
|
<div class="d-table__mobile-label">
|
|
{{i18n "chat_integration.rule_table.tags"}}
|
|
</div>
|
|
{{#if this.displayTags}}
|
|
{{this.displayTags}}
|
|
{{else}}
|
|
{{i18n "chat_integration.all_tags"}}
|
|
{{/if}}
|
|
</td>
|
|
{{/if}}
|
|
|
|
<td class="d-table__cell --controls">
|
|
<DButton
|
|
@icon="pencil"
|
|
@title="chat_integration.rule_table.edit_rule"
|
|
@action={{fn @edit @rule}}
|
|
class="btn-default btn-small edit"
|
|
/>
|
|
<DButton
|
|
@icon="trash-can"
|
|
@title="chat_integration.rule_table.delete_rule"
|
|
@action={{fn this.delete @rule}}
|
|
class="btn-danger btn-small delete"
|
|
/>
|
|
</td>
|
|
</tr>
|
|
</template>
|
|
}
|