|
| 1 | +import { ExclamationCircleIcon } from "@heroicons/react/20/solid"; |
| 2 | +import { useLocation } from "@remix-run/react"; |
| 3 | +import { AnimatePresence, motion } from "framer-motion"; |
| 4 | +import { useOptionalEnvironment } from "~/hooks/useEnvironment"; |
| 5 | +import { useOptionalOrganization } from "~/hooks/useOrganizations"; |
| 6 | +import { useOptionalProject } from "~/hooks/useProject"; |
| 7 | +import { v3QueuesPath } from "~/utils/pathBuilder"; |
| 8 | +import { environmentFullTitle } from "../environments/EnvironmentLabel"; |
| 9 | +import { LinkButton } from "../primitives/Buttons"; |
| 10 | +import { Icon } from "../primitives/Icon"; |
| 11 | +import { Paragraph } from "../primitives/Paragraph"; |
| 12 | + |
| 13 | +export function EnvironmentPausedBanner() { |
| 14 | + const organization = useOptionalOrganization(); |
| 15 | + const project = useOptionalProject(); |
| 16 | + const environment = useOptionalEnvironment(); |
| 17 | + const location = useLocation(); |
| 18 | + |
| 19 | + const hideButton = location.pathname.endsWith("/queues"); |
| 20 | + |
| 21 | + return ( |
| 22 | + <AnimatePresence initial={false}> |
| 23 | + {organization && project && environment && environment.paused ? ( |
| 24 | + <motion.div |
| 25 | + className="flex h-10 items-center justify-between overflow-hidden border-y border-amber-400/20 bg-warning/20 py-0 pl-3 pr-2" |
| 26 | + initial={{ opacity: 0, height: 0 }} |
| 27 | + animate={{ opacity: 1, height: "2.5rem" }} |
| 28 | + exit={{ opacity: 0, height: 0 }} |
| 29 | + > |
| 30 | + <div className="flex items-center gap-2"> |
| 31 | + <Icon icon={ExclamationCircleIcon} className="h-5 w-5 text-amber-400" /> |
| 32 | + <Paragraph variant="small" className="text-amber-200"> |
| 33 | + {environmentFullTitle(environment)} environment paused. No new runs will be dequeued |
| 34 | + and executed. |
| 35 | + </Paragraph> |
| 36 | + </div> |
| 37 | + {hideButton ? null : ( |
| 38 | + <div> |
| 39 | + <LinkButton |
| 40 | + variant="tertiary/small" |
| 41 | + to={v3QueuesPath(organization, project, environment)} |
| 42 | + > |
| 43 | + Manage |
| 44 | + </LinkButton> |
| 45 | + </div> |
| 46 | + )} |
| 47 | + </motion.div> |
| 48 | + ) : null} |
| 49 | + </AnimatePresence> |
| 50 | + ); |
| 51 | +} |
| 52 | + |
| 53 | +export function useShowEnvironmentPausedBanner() { |
| 54 | + const environment = useOptionalEnvironment(); |
| 55 | + const shouldShow = environment?.paused ?? false; |
| 56 | + return { shouldShow }; |
| 57 | +} |
0 commit comments