Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit a288b8d

Browse files
UX: Rough edges
Use I18n in more places, fix text formatting, make stat tiles consistent visually with usage page
1 parent 2f7557f commit a288b8d

File tree

4 files changed

+56
-38
lines changed

4 files changed

+56
-38
lines changed

assets/javascripts/discourse/components/ai-spam.gjs

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { ajax } from "discourse/lib/ajax";
1313
import { popupAjaxError } from "discourse/lib/ajax-error";
1414
import i18n from "discourse-common/helpers/i18n";
1515
import getURL from "discourse-common/lib/get-url";
16+
import AdminConfigAreaCard from "admin/components/admin-config-area-card";
17+
import AdminPageSubheader from "admin/components/admin-page-subheader";
1618
import ComboBox from "select-kit/components/combo-box";
1719
import SpamTestModal from "./modal/spam-test-modal";
1820

@@ -109,7 +111,7 @@ export default class AiSpam extends Component {
109111
this.modal.show(SpamTestModal, {
110112
model: {
111113
customInstructions: this.customInstructions,
112-
}
114+
},
113115
});
114116
}
115117

@@ -143,9 +145,10 @@ export default class AiSpam extends Component {
143145
<template>
144146
<div class="ai-spam">
145147
<section class="ai-spam__settings">
146-
<h3 class="ai-spam__settings-title">{{i18n
147-
"discourse_ai.spam.title"
148-
}}</h3>
148+
<AdminPageSubheader
149+
@titleLabel="discourse_ai.spam.title"
150+
@descriptionLabel="discourse_ai.spam.spam_description"
151+
/>
149152

150153
<div class="control-group ai-spam__enabled">
151154
<DToggleSwitch
@@ -197,7 +200,7 @@ export default class AiSpam extends Component {
197200
>{{this.customInstructions}}</textarea>
198201
<DButton
199202
@action={{this.save}}
200-
@label="save"
203+
@label="discourse_ai.spam.save_button"
201204
class="ai-spam__instructions-save btn-primary"
202205
/>
203206
<DButton
@@ -208,26 +211,29 @@ export default class AiSpam extends Component {
208211
</div>
209212
</section>
210213

211-
<section class="ai-spam__stats">
212-
<h3 class="ai-spam__stats-title">{{i18n
213-
"discourse_ai.spam.last_seven_days"
214-
}}</h3>
215-
216-
<div class="ai-spam__metrics">
217-
{{#each this.metrics as |metric|}}
218-
<div class="ai-spam__metrics-item">
219-
<span class="ai-spam__metrics-label">{{i18n metric.label}}</span>
220-
{{#if metric.href}}
221-
<a href={{metric.href}} class="ai-spam__metrics-value">
222-
{{metric.value}}
223-
</a>
224-
{{else}}
225-
<span class="ai-spam__metrics-value">{{metric.value}}</span>
226-
{{/if}}
227-
</div>
228-
{{/each}}
229-
</div>
230-
</section>
214+
<AdminConfigAreaCard
215+
@heading="discourse_ai.spam.last_seven_days"
216+
class="ai-spam__stats"
217+
>
218+
<:content>
219+
<div class="ai-spam__metrics">
220+
{{#each this.metrics as |metric|}}
221+
<div class="ai-spam__metrics-item">
222+
<span class="ai-spam__metrics-label">{{i18n
223+
metric.label
224+
}}</span>
225+
{{#if metric.href}}
226+
<a href={{metric.href}} class="ai-spam__metrics-value">
227+
{{metric.value}}
228+
</a>
229+
{{else}}
230+
<span class="ai-spam__metrics-value">{{metric.value}}</span>
231+
{{/if}}
232+
</div>
233+
{{/each}}
234+
</div>
235+
</:content>
236+
</AdminConfigAreaCard>
231237
</div>
232238
</template>
233239
}

assets/javascripts/discourse/components/modal/spam-test-modal.gjs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { tracked } from "@glimmer/tracking";
33
import { fn } from "@ember/helper";
44
import { on } from "@ember/modifier";
55
import { action } from "@ember/object";
6-
import { eq } from "truth-helpers";
76
import DButton from "discourse/components/d-button";
87
import DModal from "discourse/components/d-modal";
98
import withEventValue from "discourse/helpers/with-event-value";
@@ -27,12 +26,14 @@ export default class SpamTestModal extends Component {
2726
type: "POST",
2827
data: {
2928
post_url: this.postUrl,
30-
custom_instructions: this.args.model.customInstructions
29+
custom_instructions: this.args.model.customInstructions,
3130
},
3231
}
3332
);
3433

35-
this.testResult = response.is_spam ? "Spam" : "Not Spam";
34+
this.testResult = response.is_spam
35+
? I18n.t("discourse_ai.usage.test_modal.spam")
36+
: I18n.t("discourse_ai.usage.test_modal.not_spam");
3637
this.scanLog = response.log;
3738
} catch (error) {
3839
popupAjaxError(error);
@@ -41,6 +42,10 @@ export default class SpamTestModal extends Component {
4142
}
4243
}
4344

45+
get isSpam() {
46+
return this.testResult === I18n.t("discourse_ai.usage.test_modal.spam");
47+
}
48+
4449
<template>
4550
<DModal
4651
@title={{I18n.t "discourse_ai.spam.test_modal.title"}}
@@ -67,7 +72,7 @@ export default class SpamTestModal extends Component {
6772
<h3>{{I18n.t "discourse_ai.spam.test_modal.result"}}</h3>
6873
<div
6974
class="spam-test-modal__verdict
70-
{{if (eq this.testResult 'Spam') 'is-spam' 'not-spam'}}"
75+
{{if this.isSpam 'is-spam' 'not-spam'}}"
7176
>
7277
{{this.testResult}}
7378
</div>

assets/stylesheets/modules/llms/common/spam.scss

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,23 @@
5858
}
5959

6060
&__metrics-item {
61-
background: var(--primary-very-low);
61+
display: flex;
62+
flex-direction: column;
6263
padding: 1em;
64+
background: var(--primary-very-low);
6365
border-radius: 0.25em;
64-
text-align: center;
6566
}
6667

6768
&__metrics-label {
68-
display: block;
69-
font-weight: bold;
69+
color: var(--primary-medium);
70+
font-size: 0.875em;
7071
margin-bottom: 0.5em;
7172
}
7273

7374
&__metrics-value {
74-
font-size: var(--font-up-2);
75+
color: var(--primary);
76+
font-size: 1.5em;
77+
font-weight: bold;
7578
}
7679
}
7780

config/locales/client.en.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ en:
128128

129129
spam:
130130
short_title: "Spam"
131-
title: "Configure AI Spam handling"
131+
title: "Configure spam handling"
132132
select_llm: "Select LLM"
133133
custom_instructions: "Custom instructions"
134134
custom_instructions_help: "Custom instructions specific to your site to help guide the AI in identifying spam, e.g. 'Be more aggressive about scanning posts not in English'."
@@ -141,15 +141,19 @@ en:
141141
enable: "Enable"
142142
spam_tip: "AI spam detection will scan the first 3 posts by all new users on public topics. It will flag them for review and block users if they are likely spam."
143143
settings_saved: "Settings saved"
144+
spam_description: "Identifies potential spam using the selected LLM and flags it for site moderators to inspect in the review queue."
144145
no_llms: "No LLMs available"
145146
test_button: "Test..."
147+
save_button: "Save changes"
146148
test_modal:
147-
title: "Test Spam Detection"
149+
title: "Test spam detection"
148150
post_url_label: "Post URL or ID"
149151
post_url_placeholder: "https://your-forum.com/t/topic/123/4 or post ID"
150152
result: "Result"
151-
scan_log: "Scan Log"
152-
run: "Run Test"
153+
scan_log: "Scan log"
154+
run: "Run test"
155+
spam: "Spam"
156+
not_spam: "Not spam"
153157

154158
usage:
155159
short_title: "Usage"

0 commit comments

Comments
 (0)