|
1 | | -import { Steps, Collapse, Button } from "antd"; |
| 1 | +import { Steps, Collapse, Button, Form, Input } from "antd"; |
2 | 2 | import { useState } from "react"; |
| 3 | +import airtable from "../../components/airtable"; |
| 4 | +import Schema from "async-validator"; |
| 5 | +Schema.warning = function () {}; // to avoid async validator warning |
| 6 | + |
3 | 7 | const { Step } = Steps; |
4 | 8 | const { Panel } = Collapse; |
5 | 9 |
|
6 | | -const stepData = { |
7 | | - "SEGG Access": |
8 | | - "SEGG uses an AWS Lambda to temporarily assume an IAM Role on your AWS Account to fetch the Step Function Information and their corresponding Cloudwatch Logs", |
| 10 | +const IAMData = { |
9 | 11 | "IAM Role - Assume Role Policy": |
10 | | - "The IAM Role requires an Assume Role Policy that allows access to SEGG Account", |
| 12 | + "The IAM Role requires an Assume Role Policy that allows access to SEGG AWS Account to assume the role", |
11 | 13 | "IAM Role - Managed Policies": |
12 | | - "The IAM Role needs to have permission to get Step Functions and Cloudwatch Logs", |
| 14 | + "The IAM Role that is assumed needs to have permission to get Step Functions and Cloudwatch Logs", |
| 15 | +}; |
| 16 | +const stepData = { |
| 17 | + "SEGG Access": ( |
| 18 | + <> |
| 19 | + <p> |
| 20 | + SEGG uses an AWS Lambda to temporarily assume an IAM Role from your AWS |
| 21 | + Account to fetch the Step Function Information and their corresponding |
| 22 | + Cloudwatch Logs. The IAM Role to be created in your account has 2 parts |
| 23 | + as mentioned below: |
| 24 | + </p> |
| 25 | + <Steps progressDot current={4} direction="vertical"> |
| 26 | + {Object.keys(IAMData).map((e) => { |
| 27 | + return <Step title={e} key={e} description={IAMData[e]} />; |
| 28 | + })} |
| 29 | + </Steps> |
| 30 | + </> |
| 31 | + ), |
| 32 | + |
13 | 33 | "1 Click Deploy": ( |
14 | | - <Button |
15 | | - target="_blank" |
16 | | - rel="noreferrer" |
17 | | - href="https://console.aws.amazon.com/cloudformation/home?region=ap-south-1#/stacks/new?stackName=SEGG-IAMRole&templateURL=https://oss-1click-deployments.s3.ap-south-1.amazonaws.com/iam-one-click-template.yaml" |
18 | | - > |
19 | | - Create IAM Role |
20 | | - </Button> |
| 34 | + <> |
| 35 | + <p> |
| 36 | + {" "} |
| 37 | + Click the button below to create the cloudformation for the required |
| 38 | + accesss |
| 39 | + </p> |
| 40 | + <Button |
| 41 | + type="primary" |
| 42 | + target="_blank" |
| 43 | + rel="noreferrer" |
| 44 | + href="https://console.aws.amazon.com/cloudformation/home?region=ap-south-1#/stacks/new?stackName=SEGG-IAMRole&templateURL=https://oss-1click-deployments.s3.ap-south-1.amazonaws.com/iam-one-click-template.yaml" |
| 45 | + > |
| 46 | + Create IAM Role |
| 47 | + </Button> |
| 48 | + </> |
21 | 49 | ), |
22 | 50 | }; |
23 | 51 |
|
24 | 52 | const IntroMid = () => { |
25 | | - const [width, setWidth] = useState("100px"); |
| 53 | + const [width, setWidth] = useState("120px"); |
| 54 | + const [panel, setPanel] = useState("registerPart1"); |
| 55 | + const [activeKey, setActiveKey] = useState(""); |
26 | 56 |
|
27 | 57 | const changeWidth = () => { |
28 | | - if (width === "100px") { |
| 58 | + if (width === "120px") { |
29 | 59 | setWidth("75%"); |
| 60 | + setActiveKey("1"); |
30 | 61 | } else { |
31 | 62 | setTimeout(() => { |
32 | | - setWidth("100px"); |
| 63 | + setWidth("120px"); |
| 64 | + setActiveKey(); |
33 | 65 | }, 200); |
34 | 66 | } |
35 | 67 | }; |
| 68 | + const formStyle = {}; |
36 | 69 |
|
37 | | - return ( |
38 | | - <Collapse style={{ width: width }} onChange={changeWidth}> |
39 | | - <Panel showArrow={false} header="Register AWS Account" key="1"> |
| 70 | + const formUpdate = (values) => { |
| 71 | + console.log(values); |
| 72 | + airtable(values); |
| 73 | + setPanel("registerPart2"); |
| 74 | + setActiveKey("2"); |
| 75 | + }; |
| 76 | + |
| 77 | + const panelJSX = { |
| 78 | + registerPart1: ( |
| 79 | + <Panel |
| 80 | + showArrow={false} |
| 81 | + header="Step 1 : Register and Link AWS Account" |
| 82 | + key="1" |
| 83 | + > |
| 84 | + <Form |
| 85 | + key="formItem" |
| 86 | + layout="vertical" |
| 87 | + onFinish={(values) => { |
| 88 | + formUpdate(values); |
| 89 | + }} |
| 90 | + > |
| 91 | + <Form.Item |
| 92 | + label="Name" |
| 93 | + name="Name" |
| 94 | + style={formStyle} |
| 95 | + rules={[ |
| 96 | + { |
| 97 | + required: true, |
| 98 | + message: "Please enter your Name", |
| 99 | + }, |
| 100 | + ]} |
| 101 | + > |
| 102 | + <Input /> |
| 103 | + </Form.Item> |
| 104 | + <Form.Item |
| 105 | + label="Email" |
| 106 | + style={formStyle} |
| 107 | + name="Email" |
| 108 | + rules={[ |
| 109 | + { |
| 110 | + type: "email", |
| 111 | + message: "Please enter a valid Email", |
| 112 | + }, |
| 113 | + { |
| 114 | + required: true, |
| 115 | + message: "Please enter your Email", |
| 116 | + }, |
| 117 | + ]} |
| 118 | + > |
| 119 | + <Input /> |
| 120 | + </Form.Item> |
| 121 | + <Form.Item |
| 122 | + label="Organisation" |
| 123 | + style={formStyle} |
| 124 | + name="Organisation" |
| 125 | + rules={[ |
| 126 | + { |
| 127 | + required: true, |
| 128 | + message: "Please enter your Organisation", |
| 129 | + }, |
| 130 | + ]} |
| 131 | + > |
| 132 | + <Input /> |
| 133 | + </Form.Item> |
| 134 | + <Form.Item |
| 135 | + label="Designation" |
| 136 | + style={formStyle} |
| 137 | + name="Designation" |
| 138 | + rules={[ |
| 139 | + { |
| 140 | + required: true, |
| 141 | + message: "Please enter your Designation", |
| 142 | + }, |
| 143 | + ]} |
| 144 | + > |
| 145 | + <Input /> |
| 146 | + </Form.Item> |
| 147 | + |
| 148 | + <Form.Item style={formStyle}> |
| 149 | + <Button type="primary" htmlType="submit"> |
| 150 | + Register |
| 151 | + </Button> |
| 152 | + </Form.Item> |
| 153 | + </Form> |
| 154 | + </Panel> |
| 155 | + ), |
| 156 | + registerPart2: ( |
| 157 | + <Panel |
| 158 | + showArrow={false} |
| 159 | + header="Step 1 : Register and Link AWS Account" |
| 160 | + key="2" |
| 161 | + > |
40 | 162 | <Steps progressDot current={4} direction="vertical"> |
41 | 163 | {Object.keys(stepData).map((e) => { |
42 | 164 | return <Step title={e} key={e} description={stepData[e]} />; |
43 | 165 | })} |
44 | 166 | </Steps> |
45 | 167 | </Panel> |
| 168 | + ), |
| 169 | + }; |
| 170 | + |
| 171 | + return ( |
| 172 | + <Collapse |
| 173 | + activeKey={activeKey} |
| 174 | + style={{ width: width }} |
| 175 | + onChange={changeWidth} |
| 176 | + > |
| 177 | + {panelJSX[panel]} |
46 | 178 | </Collapse> |
47 | 179 | ); |
48 | 180 | }; |
|
0 commit comments