ProvisionerStatus.tsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  1. import React, { useContext, useEffect, useRef, useState } from "react";
  2. import { integrationList } from "shared/common";
  3. import styled, { keyframes } from "styled-components";
  4. import { readableDate } from "shared/string_utils";
  5. import {
  6. Infrastructure,
  7. KindMap,
  8. Operation,
  9. OperationStatus,
  10. OperationType,
  11. TFResourceState,
  12. TFState,
  13. } from "shared/types";
  14. import api from "shared/api";
  15. import Placeholder from "./Placeholder";
  16. import Loading from "./Loading";
  17. import { Context } from "shared/Context";
  18. import { useWebsockets } from "shared/hooks/useWebsockets";
  19. import Description from "./Description";
  20. type Props = {
  21. infras: Infrastructure[];
  22. project_id: number;
  23. setInfraStatus: (infra: Infrastructure) => void;
  24. auto_expanded?: boolean;
  25. can_delete?: boolean;
  26. set_max_width?: boolean;
  27. };
  28. const nameMap: { [key: string]: string } = {
  29. eks: "Elastic Kubernetes Service (EKS)",
  30. ecr: "Elastic Container Registry (ECR)",
  31. doks: "DigitalOcean Kubernetes Service (DOKS)",
  32. docr: "DigitalOcean Container Registry (DOCR)",
  33. gke: "Google Kubernetes Engine (GKE)",
  34. gcr: "Google Container Registry (GCR)",
  35. rds: "Amazon Relational Database (RDS)",
  36. };
  37. const ProvisionerStatus: React.FC<Props> = ({
  38. infras,
  39. project_id,
  40. auto_expanded,
  41. set_max_width,
  42. can_delete,
  43. setInfraStatus,
  44. }) => {
  45. const renderV1Infra = (infra: Infrastructure) => {
  46. return (
  47. <V1InfraObject
  48. key={infra.id}
  49. infra={infra}
  50. is_expanded={auto_expanded}
  51. is_collapsible={!auto_expanded}
  52. set_max_width={set_max_width}
  53. />
  54. );
  55. };
  56. const updateInfraStatus = (infra: Infrastructure) => {
  57. // in order for this to propagate to parent, we check that all tracked infras (including
  58. // the reported infra) are in a final state
  59. setInfraStatus(infra);
  60. };
  61. const renderV2Infra = (infra: Infrastructure) => {
  62. return (
  63. <V2InfraObject
  64. key={infra.id}
  65. project_id={project_id}
  66. infra={infra}
  67. is_expanded={auto_expanded}
  68. is_collapsible={!auto_expanded}
  69. set_max_width={set_max_width}
  70. can_delete={can_delete}
  71. updateInfraStatus={updateInfraStatus}
  72. />
  73. );
  74. };
  75. const renderInfras = () => {
  76. return infras.map((infra) => {
  77. if (infra.api_version == "v2") {
  78. return renderV2Infra(infra);
  79. }
  80. return renderV1Infra(infra);
  81. });
  82. };
  83. return <StyledProvisionerStatus>{renderInfras()}</StyledProvisionerStatus>;
  84. };
  85. export default ProvisionerStatus;
  86. type V1InfraObjectProps = {
  87. infra: Infrastructure;
  88. is_expanded: boolean;
  89. is_collapsible: boolean;
  90. set_max_width?: boolean;
  91. };
  92. const V1InfraObject: React.FC<V1InfraObjectProps> = ({
  93. infra,
  94. is_expanded,
  95. is_collapsible,
  96. set_max_width,
  97. }) => {
  98. const [isExpanded, setIsExpanded] = useState(is_expanded);
  99. const renderTimestampSection = () => {
  100. let timestampLabel = "Started at";
  101. switch (infra.status) {
  102. case "created":
  103. timestampLabel = "Created at";
  104. break;
  105. case "deleted":
  106. case "destroyed":
  107. timestampLabel = "Deleted at";
  108. break;
  109. case "errored":
  110. timestampLabel = "Errored at";
  111. break;
  112. }
  113. return (
  114. <Timestamp>
  115. {timestampLabel} {readableDate(infra.updated_at)}
  116. </Timestamp>
  117. );
  118. };
  119. const renderErrorSection = () => {
  120. let errors: string[] = [];
  121. if (infra.status == "destroyed" || infra.status == "deleted") {
  122. errors.push("This infrastructure was destroyed.");
  123. }
  124. if (errors.length > 0) {
  125. return (
  126. <>
  127. <Description>
  128. Encountered the following errors while provisioning:
  129. </Description>
  130. <ErrorWrapper>
  131. {errors.map((error, index) => {
  132. return <ExpandedError key={index}>{error}</ExpandedError>;
  133. })}
  134. </ErrorWrapper>
  135. </>
  136. );
  137. }
  138. };
  139. const renderExpandedContents = () => {
  140. if (isExpanded) {
  141. let errors: string[] = [];
  142. if (infra.status == "destroyed" || infra.status == "deleted") {
  143. errors.push("This infrastructure was destroyed.");
  144. }
  145. let error = null;
  146. if (errors.length > 0) {
  147. error = errors.map((error, index) => {
  148. return <ExpandedError key={index}>{error}</ExpandedError>;
  149. });
  150. }
  151. return (
  152. <StyledV1Card>
  153. <Description>
  154. Infrastructure is {infra.status}, last updated at{" "}
  155. {readableDate(infra.updated_at)}
  156. </Description>
  157. {renderErrorSection()}
  158. </StyledV1Card>
  159. );
  160. }
  161. };
  162. return (
  163. <StyledInfraObject key={infra.id} set_max_width={set_max_width}>
  164. <InfraHeader
  165. is_clickable={is_collapsible}
  166. onClick={() => {
  167. if (is_collapsible) {
  168. setIsExpanded((val) => {
  169. return !val;
  170. });
  171. }
  172. }}
  173. >
  174. <Flex>
  175. {integrationList[infra.kind] && (
  176. <Icon src={integrationList[infra.kind].icon} />
  177. )}
  178. {KindMap[infra.kind]?.provider_name}
  179. </Flex>
  180. <Flex>
  181. {renderTimestampSection()}
  182. <ExpandIconContainer hidden={!is_collapsible}>
  183. <i className="material-icons expand-icon">
  184. {isExpanded ? "expand_less" : "expand_more"}
  185. </i>
  186. </ExpandIconContainer>
  187. </Flex>
  188. </InfraHeader>
  189. {renderExpandedContents()}
  190. </StyledInfraObject>
  191. );
  192. };
  193. type V2InfraObjectProps = {
  194. infra: Infrastructure;
  195. project_id: number;
  196. is_expanded: boolean;
  197. is_collapsible: boolean;
  198. set_max_width?: boolean;
  199. can_delete?: boolean;
  200. updateInfraStatus: (infra: Infrastructure) => void;
  201. };
  202. const V2InfraObject: React.FC<V2InfraObjectProps> = ({
  203. infra,
  204. project_id,
  205. is_expanded,
  206. is_collapsible,
  207. set_max_width,
  208. can_delete,
  209. updateInfraStatus,
  210. }) => {
  211. const [isExpanded, setIsExpanded] = useState(is_expanded);
  212. const [isInProgress, setIsInProgress] = useState(
  213. infra.status == "creating" ||
  214. infra.status == "updating" ||
  215. infra.status == "deleting"
  216. );
  217. const [fullInfra, setFullInfra] = useState<Infrastructure>(null);
  218. const [infraState, setInfraState] = useState<TFState>(null);
  219. const [isLoading, setIsLoading] = useState(false);
  220. useEffect(() => {
  221. if ((isExpanded || isInProgress) && !fullInfra) {
  222. refreshInfra();
  223. }
  224. }, [infra, project_id, isExpanded, isInProgress]);
  225. useEffect(() => {
  226. if ((isExpanded || isInProgress) && !infraState) {
  227. refreshInfraState();
  228. }
  229. }, [infra, project_id, isExpanded, isInProgress]);
  230. const refreshInfraState = () => {
  231. api
  232. .getInfraState(
  233. "<token>",
  234. {},
  235. {
  236. project_id: project_id,
  237. infra_id: infra.id,
  238. }
  239. )
  240. .then(({ data }) => {
  241. setInfraState(data);
  242. setIsLoading(false);
  243. })
  244. .catch((err) => {
  245. console.error(err);
  246. });
  247. };
  248. const refreshInfra = (completed?: boolean, errored?: boolean) => {
  249. setIsLoading(true);
  250. api
  251. .getInfraByID(
  252. "<token>",
  253. {},
  254. {
  255. project_id: project_id,
  256. infra_id: infra.id,
  257. }
  258. )
  259. .then(({ data }) => {
  260. let infra = data as Infrastructure;
  261. if (completed && infra.latest_operation) {
  262. if (errored) {
  263. infra.latest_operation.status = "errored";
  264. } else {
  265. infra.latest_operation.status = "completed";
  266. }
  267. }
  268. setFullInfra(infra);
  269. updateInfraStatus(infra);
  270. // re-query for the infra state
  271. refreshInfraState();
  272. setIsLoading(false);
  273. })
  274. .catch((err) => {
  275. console.error(err);
  276. });
  277. };
  278. const renderExpandedContentsCreated = () => {
  279. return (
  280. <OperationDetails
  281. infra={fullInfra}
  282. can_delete={can_delete}
  283. refreshInfra={refreshInfra}
  284. />
  285. );
  286. };
  287. const renderExpandedContents = () => {
  288. if (!isExpanded) {
  289. return null;
  290. } else if (fullInfra) {
  291. return renderExpandedContentsCreated();
  292. }
  293. return (
  294. <ErrorWrapper>
  295. <Placeholder>
  296. <Loading />{" "}
  297. </Placeholder>
  298. </ErrorWrapper>
  299. );
  300. };
  301. const renderTimestampSection = () => {
  302. let timestampLabel = "Started at";
  303. switch (infra.status) {
  304. case "created":
  305. timestampLabel = "Created at";
  306. break;
  307. case "deleted":
  308. timestampLabel = "Deleted at";
  309. break;
  310. case "errored":
  311. timestampLabel = "Errored at";
  312. break;
  313. }
  314. return (
  315. <Timestamp>
  316. {timestampLabel} {readableDate(infra.updated_at)}
  317. </Timestamp>
  318. );
  319. };
  320. return (
  321. <StyledInfraObject key={infra.id} set_max_width={set_max_width}>
  322. <InfraHeader
  323. is_clickable={is_collapsible}
  324. onClick={() => {
  325. if (is_collapsible) {
  326. setIsExpanded((val) => {
  327. setIsLoading(true);
  328. return !val;
  329. });
  330. }
  331. }}
  332. >
  333. <Flex>
  334. {integrationList[infra.kind] && (
  335. <Icon src={integrationList[infra.kind].icon} />
  336. )}
  337. {KindMap[infra.kind]?.provider_name}
  338. </Flex>
  339. <Flex>
  340. {renderTimestampSection()}
  341. <ExpandIconContainer hidden={!is_collapsible}>
  342. <i className="material-icons expand-icon">
  343. {isExpanded ? "expand_less" : "expand_more"}
  344. </i>
  345. </ExpandIconContainer>
  346. </Flex>
  347. </InfraHeader>
  348. {renderExpandedContents()}
  349. </StyledInfraObject>
  350. );
  351. };
  352. type OperationDetailsProps = {
  353. infra: Infrastructure;
  354. can_delete?: boolean;
  355. refreshInfra: (completed?: boolean, errored?: boolean) => void;
  356. useOperation?: Operation;
  357. padding?: string;
  358. };
  359. export const OperationDetails: React.FunctionComponent<OperationDetailsProps> = ({
  360. infra,
  361. can_delete,
  362. refreshInfra,
  363. useOperation,
  364. padding,
  365. }) => {
  366. const [isLoading, setIsLoading] = useState(!useOperation);
  367. const [hasError, setHasError] = useState(false);
  368. const [operation, setOperation] = useState<Operation>(useOperation);
  369. const [infraState, setInfraState] = useState<TFState>(null);
  370. const [infraStateInitialized, setInfraStateInitialized] = useState(false);
  371. const { currentProject, setCurrentError } = useContext(Context);
  372. const [erroredResources, setErroredResources] = useState<TFResourceState[]>(
  373. []
  374. );
  375. const [createdResources, setCreatedResources] = useState<TFResourceState[]>(
  376. []
  377. );
  378. const [deletedResources, setDeletedResources] = useState<TFResourceState[]>(
  379. []
  380. );
  381. const [plannedResources, setPlannedResources] = useState<TFResourceState[]>(
  382. []
  383. );
  384. const { newWebsocket, openWebsocket, closeWebsocket } = useWebsockets();
  385. const parseOperationWebsocketEvent = (evt: MessageEvent) => {
  386. let { status, resource_id, error } = JSON.parse(evt.data);
  387. if (status == "OPERATION_COMPLETED") {
  388. // if the operation is completed, call the completed handler
  389. refreshInfra(true, erroredResources.length > 0);
  390. } else if (status && resource_id) {
  391. // if the status and resource_id are defined, add this to the infra state
  392. setInfraState((curr) => {
  393. let currCopy: TFState = {
  394. last_updated: curr.last_updated,
  395. operation_id: curr.operation_id,
  396. status: curr.status,
  397. resources: { ...curr.resources },
  398. };
  399. if (currCopy.resources[resource_id]) {
  400. currCopy.resources[resource_id].status = status;
  401. currCopy.resources[resource_id].error = error;
  402. } else {
  403. currCopy.resources[resource_id] = {
  404. id: resource_id,
  405. status: status,
  406. error: error,
  407. };
  408. }
  409. return currCopy;
  410. });
  411. }
  412. };
  413. const setupOperationWebsocket = (websocketID: string) => {
  414. let apiPath = `/api/projects/${currentProject.id}/infras/${infra.id}/operations/${infra.latest_operation.id}/state`;
  415. const wsConfig = {
  416. onopen: () => {
  417. console.log(`connected to websocket:`, websocketID);
  418. },
  419. onmessage: parseOperationWebsocketEvent,
  420. onclose: () => {
  421. console.log(`closing websocket:`, websocketID);
  422. },
  423. onerror: (err: ErrorEvent) => {
  424. console.log(err);
  425. closeWebsocket(websocketID);
  426. },
  427. };
  428. newWebsocket(websocketID, apiPath, wsConfig);
  429. openWebsocket(websocketID);
  430. };
  431. useEffect(() => {
  432. // if the latest_operation is in progress, open a websocket
  433. if (infraStateInitialized && infra.latest_operation.status === "starting") {
  434. const websocketID = infra.latest_operation.id;
  435. setupOperationWebsocket(websocketID);
  436. return () => {
  437. closeWebsocket(websocketID);
  438. };
  439. }
  440. }, [infraStateInitialized]);
  441. useEffect(() => {
  442. api
  443. .getInfraState(
  444. "<token>",
  445. {},
  446. {
  447. project_id: currentProject.id,
  448. infra_id: infra.id,
  449. }
  450. )
  451. .then(({ data }) => {
  452. setInfraState(data);
  453. setIsLoading(false);
  454. setInfraStateInitialized(true);
  455. })
  456. .catch((err) => {
  457. console.error(err);
  458. if (!infraStateInitialized) {
  459. setInfraState({
  460. last_updated: "",
  461. operation_id: infra.latest_operation.id,
  462. status: "creating",
  463. resources: {},
  464. });
  465. setInfraStateInitialized(true);
  466. }
  467. });
  468. }, [currentProject, infra]);
  469. useEffect(() => {
  470. api
  471. .getOperation(
  472. "<token>",
  473. {},
  474. {
  475. project_id: currentProject.id,
  476. infra_id: infra.id,
  477. operation_id: useOperation?.id || infra.latest_operation.id,
  478. }
  479. )
  480. .then(({ data }) => {
  481. setOperation(data);
  482. setIsLoading(false);
  483. })
  484. .catch((err) => {
  485. console.error(err);
  486. setHasError(true);
  487. setCurrentError(err.response?.data?.error);
  488. setIsLoading(false);
  489. });
  490. }, [currentProject, infra]);
  491. useEffect(() => {
  492. if (infraState && infraState.resources) {
  493. setErroredResources(
  494. Object.keys(infraState.resources)
  495. .map((key) => {
  496. if (
  497. infraState.resources[key].error &&
  498. infraState.resources[key].error != null
  499. ) {
  500. return infraState.resources[key];
  501. }
  502. return null;
  503. })
  504. .filter((val) => val)
  505. );
  506. setCreatedResources(
  507. Object.keys(infraState.resources)
  508. .map((key) => {
  509. if (infraState.resources[key].status == "created") {
  510. return infraState.resources[key];
  511. }
  512. return null;
  513. })
  514. .filter((val) => val)
  515. );
  516. setDeletedResources(
  517. Object.keys(infraState.resources)
  518. .map((key) => {
  519. if (infraState.resources[key].status == "deleted") {
  520. return infraState.resources[key];
  521. }
  522. return null;
  523. })
  524. .filter((val) => val)
  525. );
  526. setPlannedResources(
  527. Object.keys(infraState.resources)
  528. .map((key) => {
  529. if (
  530. infraState.resources[key].status == "planned_create" ||
  531. infraState.resources[key].status == "planned_delete"
  532. ) {
  533. return infraState.resources[key];
  534. }
  535. return null;
  536. })
  537. .filter((val) => val)
  538. );
  539. }
  540. }, [infraState]);
  541. if (isLoading || !infraState || !operation) {
  542. return (
  543. <Placeholder>
  544. <Loading />
  545. </Placeholder>
  546. );
  547. }
  548. if (hasError) {
  549. return <Placeholder>Error</Placeholder>;
  550. }
  551. const getOperationDescription = (
  552. type: OperationType,
  553. status: OperationStatus,
  554. time: string
  555. ): string => {
  556. switch (type) {
  557. case "retry_create":
  558. case "create":
  559. if (status == "starting") {
  560. return (
  561. "Status: infrastructure creation in progress, started at " +
  562. readableDate(time)
  563. );
  564. } else if (status == "completed") {
  565. return (
  566. "Status: infrastructure creation completed at " + readableDate(time)
  567. );
  568. } else if (status == "errored") {
  569. return "Status: this infrastructure encountered an error while creating.";
  570. }
  571. case "update":
  572. if (status == "starting") {
  573. return (
  574. "Status: infrastructure update in progress, started at " +
  575. readableDate(time)
  576. );
  577. } else if (status == "completed") {
  578. return (
  579. "Status: infrastructure update completed at " + readableDate(time)
  580. );
  581. } else if (status == "errored") {
  582. return "Status: this infrastructure encountered an error while updating.";
  583. }
  584. case "retry_delete":
  585. case "delete":
  586. if (status == "starting") {
  587. return (
  588. "Status: infrastructure deletion in progress, started at " +
  589. readableDate(time)
  590. );
  591. } else if (status == "completed") {
  592. return (
  593. "Status: infrastructure deletion completed at " + readableDate(time)
  594. );
  595. } else if (status == "errored") {
  596. return "Status: this infrastructure encountered an error while deleting.";
  597. }
  598. }
  599. };
  600. const deleteInfra = () => {
  601. api
  602. .deleteInfra(
  603. "<token>",
  604. {},
  605. {
  606. project_id: currentProject.id,
  607. infra_id: infra.id,
  608. }
  609. )
  610. .then(({ data }) => {
  611. refreshInfra();
  612. })
  613. .catch((err) => {
  614. console.error(err);
  615. });
  616. };
  617. const getOperationAction = (status: OperationStatus) => {
  618. if (can_delete && status == "errored") {
  619. return (
  620. <Button color="#b91133" onClick={deleteInfra}>
  621. Delete Infra
  622. </Button>
  623. );
  624. }
  625. };
  626. const renderLoadingBar = (
  627. completedResourceCount: number,
  628. plannedResourceCount: number
  629. ) => {
  630. let width = (100.0 * completedResourceCount) / plannedResourceCount;
  631. let operationKind = "Created";
  632. let count = `${completedResourceCount} / ${plannedResourceCount}`;
  633. if (
  634. infra.latest_operation.status == "completed" &&
  635. (infra.latest_operation.type == "delete" ||
  636. infra.latest_operation.type == "retry_delete")
  637. ) {
  638. width = 100.0;
  639. count = "";
  640. } else if (
  641. infra.latest_operation.status != "completed" &&
  642. plannedResourceCount == 0
  643. ) {
  644. // in the case when the planned resource count is 0, the state is still being computed, so
  645. // render 0 width and "Planning..." message
  646. width = 0;
  647. operationKind = "Planning...";
  648. count = "";
  649. }
  650. if (operationKind != "Planning...") {
  651. switch (infra.latest_operation.type) {
  652. case "retry_create":
  653. case "create":
  654. operationKind = "Created";
  655. break;
  656. case "update":
  657. operationKind = "Updated";
  658. break;
  659. case "retry_delete":
  660. case "delete":
  661. operationKind = "Deleted";
  662. }
  663. }
  664. return (
  665. <StatusContainer>
  666. <LoadingBar>
  667. <LoadingFill status="loading" width={width + "%"} />
  668. </LoadingBar>
  669. <ResourceNumber>{`${count} ${operationKind}`}</ResourceNumber>
  670. </StatusContainer>
  671. );
  672. };
  673. const renderErrorSection = () => {
  674. if (erroredResources.length > 0 && infra?.latest_operation?.errored) {
  675. return (
  676. <>
  677. <Description>
  678. Encountered the following errors while provisioning:
  679. </Description>
  680. <ErrorWrapper>
  681. {erroredResources.map((resource, index) => {
  682. return (
  683. <ExpandedError key={index}>{resource.error}</ExpandedError>
  684. );
  685. })}
  686. </ErrorWrapper>
  687. </>
  688. );
  689. }
  690. };
  691. return (
  692. <StyledCard padding={padding}>
  693. {renderLoadingBar(
  694. createdResources.length + deletedResources.length,
  695. createdResources.length +
  696. erroredResources.length +
  697. plannedResources.length
  698. )}
  699. <Description>
  700. {getOperationDescription(
  701. operation.type,
  702. operation.status,
  703. operation.last_updated
  704. )}
  705. </Description>
  706. {renderErrorSection()}
  707. {getOperationAction(operation.status)}
  708. </StyledCard>
  709. );
  710. };
  711. const StyledCard = styled.div<{ padding?: string }>`
  712. padding: ${(props) => props.padding || "12px 20px"};
  713. max-height: 300px;
  714. overflow-y: auto;
  715. `;
  716. const StyledV1Card = styled(StyledCard)`
  717. padding: 0 20px 12px 20px;
  718. `;
  719. const Flex = styled.div`
  720. display: flex;
  721. align-items: center;
  722. `;
  723. const Timestamp = styled.div`
  724. font-size: 13px;
  725. font-weight: 400;
  726. color: #ffffff55;
  727. `;
  728. const Icon = styled.img`
  729. height: 20px;
  730. margin-right: 10px;
  731. `;
  732. const ErrorWrapper = styled.div`
  733. margin-top: 20px;
  734. overflow-y: auto;
  735. user-select: text;
  736. padding: 0 15px;
  737. `;
  738. const ExpandedError = styled.div`
  739. background: #ffffff22;
  740. border-radius: 5px;
  741. padding: 15px;
  742. font-size: 13px;
  743. font-family: monospace;
  744. border: 1px solid #aaaabb;
  745. margin-bottom: 17px;
  746. padding-bottom: 17px;
  747. `;
  748. const StatusContainer = styled.div`
  749. display: flex;
  750. align-items: center;
  751. justify-content: space-between;
  752. `;
  753. const ResourceNumber = styled.div`
  754. font-size: 12px;
  755. margin-left: 7px;
  756. min-width: 100px;
  757. text-align: right;
  758. color: #aaaabb;
  759. `;
  760. const movingGradient = keyframes`
  761. 0% {
  762. background-position: left bottom;
  763. }
  764. 100% {
  765. background-position: right bottom;
  766. }
  767. `;
  768. const StyledProvisionerStatus = styled.div`
  769. margin-top: 25px;
  770. `;
  771. const StyledInfraObject = styled.div<{ set_max_width?: boolean }>`
  772. background: #ffffff1a;
  773. border: 1px solid #aaaabb;
  774. border-radius: 5px;
  775. margin-bottom: 10px;
  776. position: relative;
  777. width: ${(props) => (props.set_max_width ? "580px" : "100%")};
  778. `;
  779. const InfraHeader = styled.div<{ is_clickable: boolean }>`
  780. font-size: 13px;
  781. font-weight: 500;
  782. justify-content: space-between;
  783. padding: 15px;
  784. display: flex;
  785. align-items: center;
  786. cursor: ${(props) => (props.is_clickable ? "pointer" : "default")};
  787. height: 50px;
  788. :hover {
  789. background: ${(props) => (props.is_clickable ? "#ffffff12" : "none")};
  790. }
  791. .expand-icon {
  792. display: none;
  793. color: #ffffff55;
  794. }
  795. :hover .expand-icon {
  796. display: inline-block;
  797. }
  798. `;
  799. const LoadingBar = styled.div`
  800. background: #ffffff22;
  801. width: 100%;
  802. height: 8px;
  803. overflow: hidden;
  804. border-radius: 100px;
  805. `;
  806. const LoadingFill = styled.div<{ width: string; status: string }>`
  807. width: ${(props) => props.width};
  808. background: ${(props) =>
  809. props.status === "successful"
  810. ? "rgb(56, 168, 138)"
  811. : props.status === "error"
  812. ? "#fcba03"
  813. : "linear-gradient(to right, #8ce1ff, #616FEE)"};
  814. height: 100%;
  815. background-size: 250% 100%;
  816. animation: ${movingGradient} 2s infinite;
  817. animation-timing-function: ease-in-out;
  818. animation-direction: alternate;
  819. `;
  820. const ExpandIconContainer = styled.div<{ hidden: boolean }>`
  821. width: 30px;
  822. margin-left: 10px;
  823. padding-top: 2px;
  824. display: ${(props) => (props.hidden ? "none" : "inline")};
  825. `;
  826. const DeleteAction = styled.span`
  827. height: 35px;
  828. font-size: 13px;
  829. font-weight: 500;
  830. font-family: "Work Sans", sans-serif;
  831. display: flex;
  832. align-items: center;
  833. justify-content: space-between;
  834. padding: 6px 14px;
  835. text-align: left;
  836. border: 1px solid #ffffff55;
  837. border-radius: 8px;
  838. background: #ffffff11;
  839. color: #ffffffdd;
  840. cursor: pointer;
  841. margin-top: 20px;
  842. max-width: 120px;
  843. `;
  844. const Button = styled.button`
  845. height: 35px;
  846. font-size: 13px;
  847. margin: 10px 0;
  848. font-weight: 500;
  849. font-family: "Work Sans", sans-serif;
  850. color: white;
  851. padding: 6px 20px 7px 20px;
  852. text-align: left;
  853. border: 0;
  854. border-radius: 5px;
  855. background: ${(props) => (!props.disabled ? props.color : "#aaaabb")};
  856. box-shadow: ${(props) =>
  857. !props.disabled ? "0 2px 5px 0 #00000030" : "none"};
  858. cursor: ${(props) => (!props.disabled ? "pointer" : "default")};
  859. user-select: none;
  860. :focus {
  861. outline: 0;
  862. }
  863. :hover {
  864. filter: ${(props) => (!props.disabled ? "brightness(120%)" : "")};
  865. }
  866. `;