-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add instance termination warning to the enclave manager UI (#2356)
## Description We describe the instance termination policy on the tier page and on the cloud UI but those might not be seen until the user starts using the EM UI. The user sees the enclaves deletion as a bug because the instance replacement is done in the background. This change adds an instance termination warning message to the EM UI. Most of the work was done in the following PR to make the cloud instance config available to the EM UI: #2350 ![image](https://github.com/kurtosis-tech/kurtosis/assets/125146/84294828-c603-4f90-bbb9-a457b0428d40) ## Is this change user facing? YES
- Loading branch information
1 parent
a407cb6
commit bb39d2c
Showing
5 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
enclave-manager/web/packages/app/src/emui/enclaves/components/InstanceTermination.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { ExternalLinkIcon } from "@chakra-ui/icons"; | ||
import { Box, Link, Text } from "@chakra-ui/react"; | ||
import { useEffect, useState } from "react"; | ||
import { | ||
KURTOSIS_CLOUD_INSTANCE_MAX_UPTIME_IN_HOURS, | ||
KURTOSIS_CLOUD_SUBSCRIPTION_URL, | ||
} from "../../../client/constants"; | ||
import { useKurtosisClient } from "../../../client/enclaveManager/KurtosisClientContext"; | ||
|
||
export const InstanceTerminationWarning = () => { | ||
const [cloudInstanceRemainingHours, setCloudInstanceRemainingHours] = useState(0); | ||
const kurtosisClient = useKurtosisClient(); | ||
|
||
useEffect(() => { | ||
if (kurtosisClient.isRunningInCloud()) { | ||
fetchCloudInstanceCreationTime(); | ||
} | ||
}); | ||
|
||
const fetchCloudInstanceCreationTime = async () => { | ||
try { | ||
const cloudInstanceConfigResponse = await kurtosisClient.getCloudInstanceConfig(); | ||
const upTime = Math.floor((Date.now() - new Date(cloudInstanceConfigResponse.created).getTime()) / (3600 * 1000)); | ||
const remainingHours = KURTOSIS_CLOUD_INSTANCE_MAX_UPTIME_IN_HOURS - upTime - 1; | ||
setCloudInstanceRemainingHours(remainingHours); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
if (cloudInstanceRemainingHours <= 0) { | ||
return null; | ||
} | ||
return ( | ||
<Box borderWidth="1px" borderRadius="lg" borderColor="red" p={1}> | ||
<Text fontSize="xs"> | ||
Your cloud instance will terminate in {cloudInstanceRemainingHours} hour(s) if you do not have a{" "} | ||
<Link href={`${KURTOSIS_CLOUD_SUBSCRIPTION_URL}`} isExternal> | ||
subscription <ExternalLinkIcon mx="1px" /> | ||
</Link> | ||
</Text> | ||
</Box> | ||
); | ||
}; |