Skip to content

Commit

Permalink
DEVPROD-8684: Clarify volume expiration policy in spawn volume table (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
SupaJoon authored Aug 15, 2024
1 parent 5570962 commit b01dd57
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions apps/spruce/src/pages/spawn/spawnVolume/SpawnVolumeTable.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { useMemo, useRef } from "react";
import styled from "@emotion/styled";
import { InfoSprinkle } from "@leafygreen-ui/info-sprinkle";
import { LeafyGreenTableRow, useLeafyGreenTable } from "@leafygreen-ui/table";
import { formatDistanceToNow } from "date-fns";
import { DoesNotExpire } from "components/Spawn";
import { StyledRouterLink, WordBreak } from "components/styles";
import { BaseTable } from "components/Table/BaseTable";
import { getSpawnHostRoute } from "constants/routes";
import { size } from "constants/tokens";
import { useQueryParam } from "hooks/useQueryParam";
import { MyVolume, QueryParams, TableVolume } from "types/spawn";
import { SpawnVolumeCard } from "./SpawnVolumeCard";
Expand Down Expand Up @@ -113,9 +116,19 @@ const columns = [
cell: ({ getValue, row }) => {
const expiration = getValue();
const { noExpiration } = row.original;
return noExpiration || !expiration
? DoesNotExpire
: formatDistanceToNow(expiration);
const isUnexpirable = noExpiration || !expiration;
return (
<>
{isUnexpirable ? DoesNotExpire : formatDistanceToNow(expiration)}
{!isUnexpirable && row.original.hostID && (
<InfoContainer>
<InfoSprinkle>
Expiration is not applicable to mounted volumes.
</InfoSprinkle>
</InfoContainer>
)}
</>
);
},
},
{
Expand All @@ -124,3 +137,8 @@ const columns = [
cell: ({ row }) => <SpawnVolumeTableActions volume={row.original} />,
},
];

const InfoContainer = styled.div`
position: relative;
left: ${size.xxs};
`;

0 comments on commit b01dd57

Please sign in to comment.