UX: disabled preseeded edit button, add description (#1038)
This commit is contained in:
parent
7607477ff9
commit
d15876025f
|
@ -1,16 +1,23 @@
|
||||||
import Component from "@glimmer/component";
|
import Component from "@glimmer/component";
|
||||||
import { concat, fn } from "@ember/helper";
|
import { concat, fn } from "@ember/helper";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import { LinkTo } from "@ember/routing";
|
|
||||||
import { service } from "@ember/service";
|
import { service } from "@ember/service";
|
||||||
import DBreadcrumbsItem from "discourse/components/d-breadcrumbs-item";
|
import DBreadcrumbsItem from "discourse/components/d-breadcrumbs-item";
|
||||||
|
import DButton from "discourse/components/d-button";
|
||||||
import DPageSubheader from "discourse/components/d-page-subheader";
|
import DPageSubheader from "discourse/components/d-page-subheader";
|
||||||
import i18n from "discourse-common/helpers/i18n";
|
import i18n from "discourse-common/helpers/i18n";
|
||||||
import I18n from "discourse-i18n";
|
import I18n from "discourse-i18n";
|
||||||
import AdminSectionLandingItem from "admin/components/admin-section-landing-item";
|
import AdminSectionLandingItem from "admin/components/admin-section-landing-item";
|
||||||
import AdminSectionLandingWrapper from "admin/components/admin-section-landing-wrapper";
|
import AdminSectionLandingWrapper from "admin/components/admin-section-landing-wrapper";
|
||||||
|
import DTooltip from "float-kit/components/d-tooltip";
|
||||||
import AiLlmEditor from "./ai-llm-editor";
|
import AiLlmEditor from "./ai-llm-editor";
|
||||||
|
|
||||||
|
function isPreseeded(llm) {
|
||||||
|
if (llm.id < 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default class AiLlmsListEditor extends Component {
|
export default class AiLlmsListEditor extends Component {
|
||||||
@service adminPluginNavManager;
|
@service adminPluginNavManager;
|
||||||
@service router;
|
@service router;
|
||||||
|
@ -36,6 +43,15 @@ export default class AiLlmsListEditor extends Component {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
preseededDescription(llm) {
|
||||||
|
if (isPreseeded(llm)) {
|
||||||
|
return i18n("discourse_ai.llms.preseeded_model_description", {
|
||||||
|
model: llm.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sanitizedTranslationKey(id) {
|
sanitizedTranslationKey(id) {
|
||||||
return id.replace(/\./g, "-");
|
return id.replace(/\./g, "-");
|
||||||
}
|
}
|
||||||
|
@ -146,6 +162,7 @@ export default class AiLlmsListEditor extends Component {
|
||||||
class="ai-llm-list__row d-admin-row__content"
|
class="ai-llm-list__row d-admin-row__content"
|
||||||
>
|
>
|
||||||
<td class="d-admin-row__overview">
|
<td class="d-admin-row__overview">
|
||||||
|
|
||||||
<div class="ai-llm-list__name">
|
<div class="ai-llm-list__name">
|
||||||
<strong>
|
<strong>
|
||||||
{{llm.display_name}}
|
{{llm.display_name}}
|
||||||
|
@ -153,6 +170,7 @@ export default class AiLlmsListEditor extends Component {
|
||||||
</div>
|
</div>
|
||||||
<div class="ai-llm-list__description">
|
<div class="ai-llm-list__description">
|
||||||
{{this.modelDescription llm}}
|
{{this.modelDescription llm}}
|
||||||
|
{{this.preseededDescription llm}}
|
||||||
</div>
|
</div>
|
||||||
{{#if llm.used_by}}
|
{{#if llm.used_by}}
|
||||||
<ul class="ai-llm-list-editor__usages">
|
<ul class="ai-llm-list-editor__usages">
|
||||||
|
@ -171,15 +189,26 @@ export default class AiLlmsListEditor extends Component {
|
||||||
}}
|
}}
|
||||||
</td>
|
</td>
|
||||||
<td class="d-admin-row__controls">
|
<td class="d-admin-row__controls">
|
||||||
<LinkTo
|
{{#if (isPreseeded llm)}}
|
||||||
@route="adminPlugins.show.discourse-ai-llms.edit"
|
<DTooltip class="ai-llm-list__edit-disabled-tooltip">
|
||||||
class="btn btn-default btn-small ai-llm-list__edit-button"
|
<:trigger>
|
||||||
@model={{llm.id}}
|
<DButton
|
||||||
>
|
class="btn btn-default btn-small disabled"
|
||||||
<div class="d-button-label">
|
@label="discourse_ai.llms.edit"
|
||||||
{{i18n "discourse_ai.llms.edit"}}
|
/>
|
||||||
</div>
|
</:trigger>
|
||||||
</LinkTo>
|
<:content>
|
||||||
|
{{i18n "discourse_ai.llms.seeded_warning"}}
|
||||||
|
</:content>
|
||||||
|
</DTooltip>
|
||||||
|
{{else}}
|
||||||
|
<DButton
|
||||||
|
class="btn btn-default btn-small ai-llm-list__delete-button"
|
||||||
|
@label="discourse_ai.llms.edit"
|
||||||
|
@route="adminPlugins.show.discourse-ai-llms.edit"
|
||||||
|
@routeModels={{llm.id}}
|
||||||
|
/>
|
||||||
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
|
@ -87,16 +87,18 @@
|
||||||
tr:hover {
|
tr:hover {
|
||||||
background: inherit;
|
background: inherit;
|
||||||
}
|
}
|
||||||
th,
|
@include breakpoint("tablet", min-width) {
|
||||||
td {
|
th,
|
||||||
&:first-child {
|
td {
|
||||||
padding-left: 0;
|
&:first-child {
|
||||||
|
padding-left: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
th,
|
||||||
th,
|
td {
|
||||||
td {
|
&:last-child {
|
||||||
&:last-child {
|
padding-right: 0;
|
||||||
padding-right: 0;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,3 +160,14 @@
|
||||||
margin-right: 0.5em;
|
margin-right: 0.5em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ai-llm-list__seeded-model {
|
||||||
|
color: var(--primary-high);
|
||||||
|
font-size: var(--font-down-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@include breakpoint("tablet") {
|
||||||
|
.ai-llm-list__description {
|
||||||
|
max-width: 80%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -365,6 +365,8 @@ en:
|
||||||
mistral-mistral-large-latest: "Mistral's most powerful model"
|
mistral-mistral-large-latest: "Mistral's most powerful model"
|
||||||
mistral-pixtral-large-latest: "Mistral's most powerful vision capable model"
|
mistral-pixtral-large-latest: "Mistral's most powerful vision capable model"
|
||||||
|
|
||||||
|
preseeded_model_description: "Pre-configured open-source model utilizing %{model}"
|
||||||
|
|
||||||
configured:
|
configured:
|
||||||
title: "Configured LLMs"
|
title: "Configured LLMs"
|
||||||
preconfigured_llms: "Select your LLM"
|
preconfigured_llms: "Select your LLM"
|
||||||
|
|
|
@ -84,21 +84,20 @@ RSpec.describe "Managing LLM configurations", type: :system, js: true do
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "shows an info alert to the user about the seeded LLM" do
|
it "seeded LLM has a description" do
|
||||||
visit "/admin/plugins/discourse-ai/ai-llms"
|
visit "/admin/plugins/discourse-ai/ai-llms"
|
||||||
find("[data-llm-id='#{llm_model.name}'] .ai-llm-list__edit-button").click()
|
|
||||||
|
desc = I18n.t("js.discourse_ai.llms.preseeded_model_description", model: llm_model.name)
|
||||||
|
|
||||||
expect(page).to have_css(
|
expect(page).to have_css(
|
||||||
".alert.alert-info",
|
"[data-llm-id='#{llm_model.name}'] .ai-llm-list__description",
|
||||||
text: I18n.t("js.discourse_ai.llms.seeded_warning"),
|
text: desc,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "limits and shows disabled inputs for the seeded LLM" do
|
it "seeded LLM has a disabled edit button" do
|
||||||
visit "/admin/plugins/discourse-ai/ai-llms"
|
visit "/admin/plugins/discourse-ai/ai-llms"
|
||||||
find("[data-llm-id='cdck-hosted'] .ai-llm-list__edit-button").click()
|
expect(page).to have_css("[data-llm-id='cdck-hosted'] .ai-llm-list__edit-disabled-tooltip")
|
||||||
expect(page).to have_css(".ai-llm-editor__display-name[disabled]")
|
|
||||||
expect(page).to have_css(".ai-llm-editor__name[disabled]")
|
|
||||||
expect(page).to have_css(".ai-llm-editor__provider.is-disabled")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue