fix(plugins): mark ineligible saved profiles unavailable
This commit is contained in:
@@ -82,6 +82,12 @@ describe("PluginConfigForm agent profile field", () => {
|
||||
expect(screen.getByText("Unavailable: deleted-profile")).not.toBeNull();
|
||||
});
|
||||
|
||||
it("marks an ineligible saved profile as unavailable", () => {
|
||||
renderField([profile({ id: "disabled", label: "Disabled", enabled: false })], "disabled");
|
||||
|
||||
expect(screen.getByText("Unavailable: Disabled")).not.toBeNull();
|
||||
});
|
||||
|
||||
it("hides the Not set option for required fields", () => {
|
||||
renderField([profile({ id: "eligible", label: ELIGIBLE_PROFILE_LABEL })], "", {
|
||||
required: true,
|
||||
|
||||
@@ -256,14 +256,13 @@ function AgentProfileSelect({
|
||||
const selectedID = typeof value === "string" ? value : "";
|
||||
const selectedProfile = profiles.find((profile) => profile.id === selectedID);
|
||||
const eligibleProfiles = profiles.filter((profile) => utilityProfileEligibility(profile));
|
||||
let selectedLabel: string | undefined;
|
||||
if (selectedProfile) {
|
||||
selectedLabel = selectedProfile.label || selectedProfile.agent_name || selectedProfile.id;
|
||||
} else if (selectedID) {
|
||||
selectedLabel = t("settings:utilityUnavailableProfile", { name: selectedID });
|
||||
}
|
||||
const isStale =
|
||||
selectedID !== "" && !eligibleProfiles.some((profile) => profile.id === selectedID);
|
||||
const selectedProfileLabel =
|
||||
selectedProfile?.label || selectedProfile?.agent_name || selectedProfile?.id || selectedID;
|
||||
const selectedLabel = isStale
|
||||
? t("settings:utilityUnavailableProfile", { name: selectedProfileLabel })
|
||||
: selectedProfileLabel || undefined;
|
||||
|
||||
return (
|
||||
<Select
|
||||
|
||||
Reference in New Issue
Block a user