ProvisionerForm.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import React, { useEffect, useState, useContext } from "react";
  2. import styled from "styled-components";
  3. import api from "shared/api";
  4. import aws from "assets/aws.png";
  5. import { Context } from "shared/Context";
  6. import SelectRow from "components/form-components/SelectRow";
  7. import Heading from "components/form-components/Heading";
  8. import Helper from "./form-components/Helper";
  9. import InputRow from "./form-components/InputRow";
  10. import SaveButton from "./SaveButton";
  11. const regionOptions = [
  12. { value: "us-east-1", label: "US East (N. Virginia) us-east-1" },
  13. { value: "us-east-2", label: "US East (Ohio) us-east-2" },
  14. { value: "us-west-1", label: "US West (N. California) us-west-1" },
  15. { value: "us-west-2", label: "US West (Oregon) us-west-2" },
  16. { value: "af-south-1", label: "Africa (Cape Town) af-south-1" },
  17. { value: "ap-east-1", label: "Asia Pacific (Hong Kong) ap-east-1" },
  18. { value: "ap-south-1", label: "Asia Pacific (Mumbai) ap-south-1" },
  19. { value: "ap-northeast-2", label: "Asia Pacific (Seoul) ap-northeast-2" },
  20. { value: "ap-southeast-1", label: "Asia Pacific (Singapore) ap-southeast-1" },
  21. { value: "ap-southeast-2", label: "Asia Pacific (Sydney) ap-southeast-2" },
  22. { value: "ap-northeast-1", label: "Asia Pacific (Tokyo) ap-northeast-1" },
  23. { value: "ca-central-1", label: "Canada (Central) ca-central-1" },
  24. { value: "eu-central-1", label: "Europe (Frankfurt) eu-central-1" },
  25. { value: "eu-west-1", label: "Europe (Ireland) eu-west-1" },
  26. { value: "eu-west-2", label: "Europe (London) eu-west-2" },
  27. { value: "eu-south-1", label: "Europe (Milan) eu-south-1" },
  28. { value: "eu-west-3", label: "Europe (Paris) eu-west-3" },
  29. { value: "eu-north-1", label: "Europe (Stockholm) eu-north-1" },
  30. { value: "me-south-1", label: "Middle East (Bahrain) me-south-1" },
  31. { value: "sa-east-1", label: "South America (São Paulo) sa-east-1" },
  32. ];
  33. type Props = {
  34. goBack: () => void;
  35. credentialId: any;
  36. };
  37. const ProvisionerForm: React.FC<Props> = ({
  38. goBack,
  39. credentialId,
  40. }) => {
  41. const { currentProject } = useContext(Context);
  42. const [createStatus, setCreateStatus] = useState("");
  43. const [clusterName, setClusterName] = useState("");
  44. const [awsRegion, setAwsRegion] = useState("us-east-1");
  45. return (
  46. <>
  47. <Heading isAtTop>
  48. <BackButton width="155px" onClick={goBack}>
  49. <i className="material-icons">first_page</i>
  50. Set credentials
  51. </BackButton>
  52. <Spacer />
  53. <Img src={aws} />
  54. Configure settings
  55. </Heading>
  56. <Helper>
  57. Configure settings for your new cluster.
  58. </Helper>
  59. <StyledForm>
  60. <InputRow
  61. width="350px"
  62. isRequired
  63. type="string"
  64. value={clusterName}
  65. setValue={(x: string) => setClusterName(x)}
  66. label="🏷️ Cluster name"
  67. placeholder="ex: total-perspective-vortex"
  68. />
  69. <SelectRow
  70. options={regionOptions}
  71. width="350px"
  72. value={awsRegion}
  73. scrollBuffer={true}
  74. dropdownMaxHeight="240px"
  75. setActiveValue={setAwsRegion}
  76. label="📍 AWS Region"
  77. />
  78. </StyledForm>
  79. </>
  80. );
  81. };
  82. export default ProvisionerForm;
  83. const Spacer = styled.div`
  84. height: 1px;
  85. width: 17px;
  86. `;
  87. const Img = styled.img`
  88. height: 18px;
  89. margin-right: 15px;
  90. `;
  91. const BackButton = styled.div`
  92. display: flex;
  93. align-items: center;
  94. justify-content: space-between;
  95. cursor: pointer;
  96. font-size: 13px;
  97. height: 35px;
  98. padding: 5px 13px;
  99. padding-right: 15px;
  100. border: 1px solid #ffffff55;
  101. border-radius: 100px;
  102. width: ${(props: { width: string }) => props.width};
  103. color: white;
  104. background: #ffffff11;
  105. :hover {
  106. background: #ffffff22;
  107. }
  108. > i {
  109. color: white;
  110. font-size: 16px;
  111. margin-right: 6px;
  112. margin-left: -2px;
  113. }
  114. `;
  115. const StyledForm = styled.div`
  116. position: relative;
  117. padding: 15px 30px 25px;
  118. border-radius: 5px;
  119. background: #26292e;
  120. border: 1px solid #494b4f;
  121. font-size: 13px;
  122. margin-bottom: 30px;
  123. `;