Exclude wildcard resources

This commit is contained in:
Owen
2026-04-25 15:51:39 -07:00
parent 7c7d1f641e
commit bf1870608b
3 changed files with 18 additions and 17 deletions

View File

@@ -143,6 +143,7 @@ export type ResourceWithTargets = {
domainId: string | null; domainId: string | null;
niceId: string; niceId: string;
headerAuthId: number | null; headerAuthId: number | null;
wildcard: boolean;
targets: Array<{ targets: Array<{
targetId: number; targetId: number;
ip: string; ip: string;
@@ -176,6 +177,7 @@ function queryResourcesBase() {
enabled: resources.enabled, enabled: resources.enabled,
domainId: resources.domainId, domainId: resources.domainId,
niceId: resources.niceId, niceId: resources.niceId,
wildcard: resources.wildcard,
headerAuthId: resourceHeaderAuth.headerAuthId, headerAuthId: resourceHeaderAuth.headerAuthId,
headerAuthExtendedCompatibilityId: headerAuthExtendedCompatibilityId:
resourceHeaderAuthExtendedCompatibility.headerAuthExtendedCompatibilityId, resourceHeaderAuthExtendedCompatibility.headerAuthExtendedCompatibilityId,
@@ -456,6 +458,7 @@ export async function listResources(
http: row.http, http: row.http,
protocol: row.protocol, protocol: row.protocol,
proxyPort: row.proxyPort, proxyPort: row.proxyPort,
wildcard: row.wildcard,
enabled: row.enabled, enabled: row.enabled,
domainId: row.domainId, domainId: row.domainId,
headerAuthId: row.headerAuthId, headerAuthId: row.headerAuthId,

View File

@@ -47,15 +47,7 @@ import {
PopoverTrigger PopoverTrigger
} from "@app/components/ui/popover"; } from "@app/components/ui/popover";
import { CaretSortIcon } from "@radix-ui/react-icons"; import { CaretSortIcon } from "@radix-ui/react-icons";
import { import { ChevronsUpDown } from "lucide-react";
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList
} from "@app/components/ui/command";
import { CheckIcon, ChevronsUpDown } from "lucide-react";
import { Checkbox } from "@app/components/ui/checkbox"; import { Checkbox } from "@app/components/ui/checkbox";
import { GenerateAccessTokenResponse } from "@server/routers/accessToken"; import { GenerateAccessTokenResponse } from "@server/routers/accessToken";
import { constructShareLink } from "@app/lib/shareLinks"; import { constructShareLink } from "@app/lib/shareLinks";
@@ -275,10 +267,11 @@ export default function CreateShareLinkForm({
</PopoverTrigger> </PopoverTrigger>
<PopoverContent className="p-0"> <PopoverContent className="p-0">
<ResourceSelector <ResourceSelector
orgId={ excludeWildcard
org.org orgId={
.orgId org.org
} .orgId
}
selectedResource={ selectedResource={
selectedResource selectedResource
} }

View File

@@ -17,19 +17,21 @@ import { useDebounce } from "use-debounce";
export type SelectedResource = Pick< export type SelectedResource = Pick<
ListResourcesResponse["resources"][number], ListResourcesResponse["resources"][number],
"name" | "resourceId" | "fullDomain" | "niceId" | "ssl" "name" | "resourceId" | "fullDomain" | "niceId" | "ssl" | "wildcard"
>; >;
export type ResourceSelectorProps = { export type ResourceSelectorProps = {
orgId: string; orgId: string;
selectedResource?: SelectedResource | null; selectedResource?: SelectedResource | null;
onSelectResource: (resource: SelectedResource) => void; onSelectResource: (resource: SelectedResource) => void;
excludeWildcard?: boolean;
}; };
export function ResourceSelector({ export function ResourceSelector({
orgId, orgId,
selectedResource, selectedResource,
onSelectResource onSelectResource,
excludeWildcard = false
}: ResourceSelectorProps) { }: ResourceSelectorProps) {
const t = useTranslations(); const t = useTranslations();
const [resourceSearchQuery, setResourceSearchQuery] = useState(""); const [resourceSearchQuery, setResourceSearchQuery] = useState("");
@@ -46,10 +48,13 @@ export function ResourceSelector({
// always include the selected resource in the list of resources shown // always include the selected resource in the list of resources shown
const resourcesShown = useMemo(() => { const resourcesShown = useMemo(() => {
const allResources: Array<SelectedResource> = [...resources]; const allResources: Array<SelectedResource> = excludeWildcard
? resources.filter((r) => !r.wildcard)
: [...resources];
if ( if (
debouncedSearchQuery.trim().length === 0 && debouncedSearchQuery.trim().length === 0 &&
selectedResource && selectedResource &&
!(excludeWildcard && selectedResource.wildcard) &&
!allResources.find( !allResources.find(
(resource) => (resource) =>
resource.resourceId === selectedResource?.resourceId resource.resourceId === selectedResource?.resourceId
@@ -58,7 +63,7 @@ export function ResourceSelector({
allResources.unshift(selectedResource); allResources.unshift(selectedResource);
} }
return allResources; return allResources;
}, [debouncedSearchQuery, resources, selectedResource]); }, [debouncedSearchQuery, resources, selectedResource, excludeWildcard]);
return ( return (
<Command shouldFilter={false}> <Command shouldFilter={false}>