mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-31 15:06:42 +00:00
♻️ refactor
This commit is contained in:
@@ -9,7 +9,7 @@ import type { ArrayElement } from "@server/types/ArrayElement";
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { CheckIcon } from "lucide-react";
|
import { CheckIcon } from "lucide-react";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import { ContainersSelector } from "./ContainersSelector";
|
import { ContainersSelector } from "./ContainersSelector";
|
||||||
import { Button } from "./ui/button";
|
import { Button } from "./ui/button";
|
||||||
import {
|
import {
|
||||||
@@ -82,6 +82,22 @@ export function ResourceTargetAddressItem({
|
|||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const sitesShown = useMemo(() => {
|
||||||
|
const allSites: Array<
|
||||||
|
Pick<SiteWithUpdateAvailable, "name" | "siteId" | "type">
|
||||||
|
> = [...sites];
|
||||||
|
if (
|
||||||
|
selectedSite !== null &&
|
||||||
|
!(
|
||||||
|
allSites.find((site) => site.siteId)?.siteId ===
|
||||||
|
selectedSite?.siteId
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
allSites.unshift(selectedSite);
|
||||||
|
}
|
||||||
|
return allSites;
|
||||||
|
}, [sites, selectedSite]);
|
||||||
|
|
||||||
const handleContainerSelectForTarget = (
|
const handleContainerSelectForTarget = (
|
||||||
hostname: string,
|
hostname: string,
|
||||||
port?: number
|
port?: number
|
||||||
@@ -137,12 +153,13 @@ export function ResourceTargetAddressItem({
|
|||||||
<Command shouldFilter={false}>
|
<Command shouldFilter={false}>
|
||||||
<CommandInput
|
<CommandInput
|
||||||
placeholder={t("siteSearch")}
|
placeholder={t("siteSearch")}
|
||||||
|
value={siteSearchQuery}
|
||||||
onValueChange={(v) => setSiteSearchQuery(v)}
|
onValueChange={(v) => setSiteSearchQuery(v)}
|
||||||
/>
|
/>
|
||||||
<CommandList>
|
<CommandList>
|
||||||
<CommandEmpty>{t("siteNotFound")}</CommandEmpty>
|
<CommandEmpty>{t("siteNotFound")}</CommandEmpty>
|
||||||
<CommandGroup>
|
<CommandGroup>
|
||||||
{sites.map((site) => (
|
{sitesShown.map((site) => (
|
||||||
<CommandItem
|
<CommandItem
|
||||||
key={site.siteId}
|
key={site.siteId}
|
||||||
value={`${site.siteId}:${site.name}`}
|
value={`${site.siteId}:${site.name}`}
|
||||||
|
|||||||
Reference in New Issue
Block a user