Skip to content

Commit b2ca82e

Browse files
committed
Fix AsyncCommandDropdown check icon
1 parent c824db2 commit b2ca82e

File tree

3 files changed

+26
-16
lines changed

3 files changed

+26
-16
lines changed

src/components/service/panel/content/deployed/settings/sections/networking-section.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { validateDomain } from "@/lib/helpers/validate-domain";
1818
import { validatePort } from "@/lib/helpers/validate-port";
1919
import { useAppForm } from "@/lib/hooks/use-app-form";
2020
import { TServiceShallow } from "@/server/trpc/api/services/types";
21+
import { useStore } from "@tanstack/react-form";
2122
import { GlobeIcon, GlobeLockIcon, NetworkIcon, PenIcon, PlusIcon, Trash2Icon } from "lucide-react";
2223

2324
type TProps = {
@@ -77,6 +78,19 @@ function AllServiceTypesSection({ service }: { service: TServiceShallow }) {
7778
},
7879
});
7980

81+
const changeCount = useStore(form.store, (s) => {
82+
let count = 0;
83+
s.values.externalEndpoints.forEach((endpoint, index) => {
84+
if (endpoint.host !== endpointsData?.endpoints.external[index]?.host) {
85+
count++;
86+
}
87+
if (endpoint.port !== endpointsData?.endpoints.external[index]?.port.port.toString()) {
88+
count++;
89+
}
90+
});
91+
return count;
92+
});
93+
8094
return (
8195
<SettingsSection title="Networking" id="networking" Icon={NetworkIcon}>
8296
{(service.type === "github" || service.type === "docker-image") && (
@@ -268,20 +282,19 @@ function AllServiceTypesSection({ service }: { service: TServiceShallow }) {
268282
variant="outline-process"
269283
className="text-foreground has-hover:hover:text-foreground active:text-foreground w-full"
270284
onClick={() => {
271-
field.state.value.forEach((_, i) =>
272-
form.setFieldValue(
273-
`externalEndpoints[${i}].isEditing`,
274-
false,
275-
),
276-
);
285+
form.reset();
277286
}}
278287
>
279288
Cancel
280289
</Button>
281290
</div>
282291
<div className="w-1/2 pl-1.5">
283-
<Button variant="process" className="w-full">
284-
Save
292+
<Button
293+
disabled={changeCount < 1}
294+
variant="process"
295+
className="w-full"
296+
>
297+
Apply{changeCount > 0 ? ` (${changeCount})` : ""}
285298
</Button>
286299
</div>
287300
</div>

src/components/settings/settings-section.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
DialogTrigger,
1010
} from "@/components/ui/dialog";
1111
import { cn } from "@/components/ui/utils";
12-
import { CheckIcon, RotateCcwIcon } from "lucide-react";
1312
import { FC, HTMLAttributes, ReactNode } from "react";
1413

1514
export function SettingsSection({
@@ -59,7 +58,7 @@ export function SettingsSection({
5958
{title}
6059
</h3>
6160
</div>
62-
{changeCount !== undefined && changeCount > 0 && (
61+
{/* {changeCount !== undefined && changeCount > 0 && (
6362
<div className="-mr-2.25 flex shrink-0 items-center justify-end gap-1.25 py-1.25 sm:-mr-2.75">
6463
<ResetTrigger changeCount={changeCount} onClickResetChanges={onClickResetChanges}>
6564
<Button
@@ -78,7 +77,7 @@ export function SettingsSection({
7877
</SubmitButtonElement>
7978
</SubmitTriggerElement>
8079
</div>
81-
)}
80+
)} */}
8281
</div>
8382
<div
8483
className={cn(
@@ -98,16 +97,14 @@ export function SettingsSection({
9897
aria-label="Reset changes"
9998
variant="outline-process"
10099
>
101-
<RotateCcwIcon className="size-5 scale-90" />
102-
<p className="min-w-0 shrink truncate">Revert</p>
100+
Cancel
103101
</Button>
104102
</ResetTrigger>
105103
</div>
106104
<div className="w-1/2 p-1.5">
107105
<SubmitTriggerElement>
108106
<SubmitButtonElement className="w-full" variant="process">
109-
<CheckIcon className="size-5" />
110-
<p className="min-w-0 shrink truncate">Apply ({changeCount})</p>
107+
Apply ({changeCount})
111108
</SubmitButtonElement>
112109
</SubmitTriggerElement>
113110
</div>

src/lib/hooks/use-app-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ function AsyncCommandDropdown({
413413
value={item.value}
414414
key={item.value}
415415
className="group/item px-3"
416-
data-checked={field.state.value === item ? true : undefined}
416+
data-checked={field.state.value === item.value ? true : undefined}
417417
>
418418
{CommandItemElement ? (
419419
<CommandItemElement item={item} />

0 commit comments

Comments
 (0)