Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions apps/deploy-web/src/components/deployments/DeploymentListRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,9 @@ export const DeploymentListRow: React.FunctionComponent<Props> = ({ deployment,
const { data: leaseStatus } = useLeaseStatus({ provider, lease, enabled: !!(provider && lease && providerCredentials.details.usable) });
const isAnonymousFreeTrialEnabled = useFlag("anonymous_free_trial");

const viewDeployment = useCallback(
(event: React.MouseEvent) => {
if ((event.target as Element).closest(`a, button, [role="button"]`)) return;
router.push(UrlService.deploymentDetails(deployment.dseq));
},
[router, deployment.dseq]
);
const viewDeployment = useCallback(() => {
router.push(UrlService.deploymentDetails(deployment.dseq));
}, [router, deployment.dseq]);

function handleMenuClick() {
setOpen(true);
Expand Down Expand Up @@ -168,7 +164,7 @@ export const DeploymentListRow: React.FunctionComponent<Props> = ({ deployment,

return (
<>
<TableRow className="cursor-pointer hover:bg-muted-foreground/10 [&>td]:p-2" role="link" onClick={viewDeployment}>
<TableRow className="hover:bg-muted-foreground/10 [&>td]:p-2">
<TableCell>
<div className="flex items-center justify-center">
<SpecDetailList
Expand All @@ -181,7 +177,9 @@ export const DeploymentListRow: React.FunctionComponent<Props> = ({ deployment,
</div>
</TableCell>
<TableCell className="max-w-[100px] text-center">
<DeploymentName deployment={deployment} deploymentServices={leaseStatus?.services} providerHostUri={provider?.hostUri} />
<a href={UrlService.deploymentDetails(deployment.dseq)} className="text-black">
<DeploymentName deployment={deployment} deploymentServices={leaseStatus?.services} providerHostUri={provider?.hostUri} />
</a>

{!isAnonymousFreeTrialEnabled && isTrialing && (
<div className="mt-2">
Expand Down Expand Up @@ -290,7 +288,7 @@ export const DeploymentListRow: React.FunctionComponent<Props> = ({ deployment,
</TableCell>

<TableCell>
<div className="flex items-center justify-end space-x-2">
<div className="flex items-center justify-end">
{isSelectable && (
<Checkbox
checked={checked}
Expand Down Expand Up @@ -343,7 +341,9 @@ export const DeploymentListRow: React.FunctionComponent<Props> = ({ deployment,
</div>

<div className="flex pr-2">
<NavArrowRight />
<Button onClick={viewDeployment} size="icon" variant="ghost" className="rounded-full">
<NavArrowRight />
</Button>
</div>
</div>
</TableCell>
Expand Down
32 changes: 17 additions & 15 deletions apps/deploy-web/src/hooks/useListSelection/useListSelection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback, useMemo, useState } from "react";
import { uniq } from "lodash";
import intersection from "lodash/intersection";
import uniq from "lodash/uniq";

export type UseListSelectionProps<T> = {
ids: T[];
Expand Down Expand Up @@ -37,19 +38,16 @@ export const useListSelection = <T>({ ids }: UseListSelectionProps<T>) => {
[ids, isBetweenIds]
);

const toggleSingleSelection = useCallback(
(id: T) => {
setSelectedItemIds(prev => {
const isAdding = !prev.includes(id);
if (isAdding) {
setIntervalSelectionAnchor(id);
}
const toggleSingleSelection = useCallback((id: T) => {
setSelectedItemIds(prev => {
const isAdding = !prev.includes(id);
if (isAdding) {
setIntervalSelectionAnchor(id);
}

return isAdding ? [...prev, id] : prev.filter(x => x !== id);
});
},
[]
);
return isAdding ? [...prev, id] : prev.filter(x => x !== id);
});
}, []);

const changeMultipleSelection = useCallback(
(id: T) => {
Expand Down Expand Up @@ -82,13 +80,17 @@ export const useListSelection = <T>({ ids }: UseListSelectionProps<T>) => {
setSelectedItemIds([]);
}, []);

const validSelectedItemIds = useMemo(() => {
return intersection(ids, selectedItemIds);
}, [ids, selectedItemIds]);

return useMemo(
() => ({
selectedItemIds,
selectedItemIds: validSelectedItemIds,
selectItem,
clearSelection,
setSelectedItemIds
}),
[selectedItemIds, selectItem, clearSelection]
[validSelectedItemIds, selectItem, clearSelection]
);
};
2 changes: 1 addition & 1 deletion packages/ui/components/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Checkbox = React.forwardRef<
return (
<div
ref={wrapperRef}
className={cn("inline-flex", expandedTouchTarget && "-m-3 cursor-pointer p-3 hover:bg-muted-foreground/10 rounded-full")}
className={cn("inline-flex", expandedTouchTarget && "hover:bg-accent cursor-pointer rounded-full p-3")}
onClick={expandedTouchTarget ? triggerCheckboxClick : undefined}
>
<CheckboxPrimitive.Root
Expand Down