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

Commit d158760

Browse files
authored
UX: disabled preseeded edit button, add description (#1038)
1 parent 7607477 commit d158760

File tree

4 files changed

+71
-28
lines changed

4 files changed

+71
-28
lines changed

assets/javascripts/discourse/components/ai-llms-list-editor.gjs

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
import Component from "@glimmer/component";
22
import { concat, fn } from "@ember/helper";
33
import { action } from "@ember/object";
4-
import { LinkTo } from "@ember/routing";
54
import { service } from "@ember/service";
65
import DBreadcrumbsItem from "discourse/components/d-breadcrumbs-item";
6+
import DButton from "discourse/components/d-button";
77
import DPageSubheader from "discourse/components/d-page-subheader";
88
import i18n from "discourse-common/helpers/i18n";
99
import I18n from "discourse-i18n";
1010
import AdminSectionLandingItem from "admin/components/admin-section-landing-item";
1111
import AdminSectionLandingWrapper from "admin/components/admin-section-landing-wrapper";
12+
import DTooltip from "float-kit/components/d-tooltip";
1213
import AiLlmEditor from "./ai-llm-editor";
1314

15+
function isPreseeded(llm) {
16+
if (llm.id < 0) {
17+
return true;
18+
}
19+
}
20+
1421
export default class AiLlmsListEditor extends Component {
1522
@service adminPluginNavManager;
1623
@service router;
@@ -36,6 +43,15 @@ export default class AiLlmsListEditor extends Component {
3643
return "";
3744
}
3845

46+
@action
47+
preseededDescription(llm) {
48+
if (isPreseeded(llm)) {
49+
return i18n("discourse_ai.llms.preseeded_model_description", {
50+
model: llm.name,
51+
});
52+
}
53+
}
54+
3955
sanitizedTranslationKey(id) {
4056
return id.replace(/\./g, "-");
4157
}
@@ -146,13 +162,15 @@ export default class AiLlmsListEditor extends Component {
146162
class="ai-llm-list__row d-admin-row__content"
147163
>
148164
<td class="d-admin-row__overview">
165+
149166
<div class="ai-llm-list__name">
150167
<strong>
151168
{{llm.display_name}}
152169
</strong>
153170
</div>
154171
<div class="ai-llm-list__description">
155172
{{this.modelDescription llm}}
173+
{{this.preseededDescription llm}}
156174
</div>
157175
{{#if llm.used_by}}
158176
<ul class="ai-llm-list-editor__usages">
@@ -171,15 +189,26 @@ export default class AiLlmsListEditor extends Component {
171189
}}
172190
</td>
173191
<td class="d-admin-row__controls">
174-
<LinkTo
175-
@route="adminPlugins.show.discourse-ai-llms.edit"
176-
class="btn btn-default btn-small ai-llm-list__edit-button"
177-
@model={{llm.id}}
178-
>
179-
<div class="d-button-label">
180-
{{i18n "discourse_ai.llms.edit"}}
181-
</div>
182-
</LinkTo>
192+
{{#if (isPreseeded llm)}}
193+
<DTooltip class="ai-llm-list__edit-disabled-tooltip">
194+
<:trigger>
195+
<DButton
196+
class="btn btn-default btn-small disabled"
197+
@label="discourse_ai.llms.edit"
198+
/>
199+
</:trigger>
200+
<:content>
201+
{{i18n "discourse_ai.llms.seeded_warning"}}
202+
</:content>
203+
</DTooltip>
204+
{{else}}
205+
<DButton
206+
class="btn btn-default btn-small ai-llm-list__delete-button"
207+
@label="discourse_ai.llms.edit"
208+
@route="adminPlugins.show.discourse-ai-llms.edit"
209+
@routeModels={{llm.id}}
210+
/>
211+
{{/if}}
183212
</td>
184213
</tr>
185214
{{/each}}

assets/stylesheets/modules/llms/common/ai-llms-editor.scss

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,18 @@
8787
tr:hover {
8888
background: inherit;
8989
}
90-
th,
91-
td {
92-
&:first-child {
93-
padding-left: 0;
90+
@include breakpoint("tablet", min-width) {
91+
th,
92+
td {
93+
&:first-child {
94+
padding-left: 0;
95+
}
9496
}
95-
}
96-
th,
97-
td {
98-
&:last-child {
99-
padding-right: 0;
97+
th,
98+
td {
99+
&:last-child {
100+
padding-right: 0;
101+
}
100102
}
101103
}
102104
}
@@ -158,3 +160,14 @@
158160
margin-right: 0.5em;
159161
}
160162
}
163+
164+
.ai-llm-list__seeded-model {
165+
color: var(--primary-high);
166+
font-size: var(--font-down-1);
167+
}
168+
169+
@include breakpoint("tablet") {
170+
.ai-llm-list__description {
171+
max-width: 80%;
172+
}
173+
}

config/locales/client.en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ en:
365365
mistral-mistral-large-latest: "Mistral's most powerful model"
366366
mistral-pixtral-large-latest: "Mistral's most powerful vision capable model"
367367

368+
preseeded_model_description: "Pre-configured open-source model utilizing %{model}"
369+
368370
configured:
369371
title: "Configured LLMs"
370372
preconfigured_llms: "Select your LLM"

spec/system/llms/ai_llm_spec.rb

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,20 @@
8484
)
8585
end
8686

87-
it "shows an info alert to the user about the seeded LLM" do
87+
it "seeded LLM has a description" do
8888
visit "/admin/plugins/discourse-ai/ai-llms"
89-
find("[data-llm-id='#{llm_model.name}'] .ai-llm-list__edit-button").click()
89+
90+
desc = I18n.t("js.discourse_ai.llms.preseeded_model_description", model: llm_model.name)
91+
9092
expect(page).to have_css(
91-
".alert.alert-info",
92-
text: I18n.t("js.discourse_ai.llms.seeded_warning"),
93+
"[data-llm-id='#{llm_model.name}'] .ai-llm-list__description",
94+
text: desc,
9395
)
9496
end
9597

96-
it "limits and shows disabled inputs for the seeded LLM" do
98+
it "seeded LLM has a disabled edit button" do
9799
visit "/admin/plugins/discourse-ai/ai-llms"
98-
find("[data-llm-id='cdck-hosted'] .ai-llm-list__edit-button").click()
99-
expect(page).to have_css(".ai-llm-editor__display-name[disabled]")
100-
expect(page).to have_css(".ai-llm-editor__name[disabled]")
101-
expect(page).to have_css(".ai-llm-editor__provider.is-disabled")
100+
expect(page).to have_css("[data-llm-id='cdck-hosted'] .ai-llm-list__edit-disabled-tooltip")
102101
end
103102
end
104103
end

0 commit comments

Comments
 (0)