-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Destination.js
169 lines (156 loc) · 6.17 KB
/
Destination.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import React, { useEffect } from "react";
import {
updateDestinationAccessId,
updateDestinationSecretKey,
updateAccountId,
} from "../slice";
import { getUserBuckets } from "../services/getBuckets";
import { useDispatch, useSelector } from "react-redux";
import BucketSelect from "./BucketSelect";
import aws_edited from "../public/aws_edited.png";
import cloudflare_edited from "../public/cloudflare_edited.png";
import MigrationButton from "./MigrationButton";
import ErrorComponent from "./ErrorComponent";
const Destination = (props) => {
const dispatch = useDispatch();
const { origin, destination } = useSelector((state) => state.GUI);
let bucketSelect;
const requireAccountId = props.name === "Cloudflare" ? true : false;
if (!requireAccountId) {
bucketSelect = destination.accessId && destination.secretKey && (
<BucketSelect remote={"destination"}></BucketSelect>
);
} else {
bucketSelect = destination.accessId &&
destination.secretKey &&
destination.accountId && (
<BucketSelect remote={"destination"}></BucketSelect>
);
}
useEffect(() => {
if (!destination.accessId || !destination.secretKey) return;
if (destination.name === "Cloudflare" && !destination.accountId) return;
dispatch(
getUserBuckets({ ...destination, originOrDestination: "destination" })
);
}, [
destination.accessId,
destination.secretKey,
destination.name,
destination.accountId,
]);
return (
<div>
<div className="relative z-0 w-full h-full mb-6 group">
<div class="grid grid-cols-3 gap-2">
<div class="mx-auto text-sm flex items-center font-mono">
Destination
{props.name && (
<>
: {props.name} {props.service}
</>
)}
</div>
<div>
<img
class={`flex items-center mx-auto object-scale-down h-8 w-8 ${
props.name === "Cloudflare" ? "" : "grayscale"
}`}
// src={props.name === 'AWS' ? aws_edited : cloudflare_edited}
src={cloudflare_edited}
/>
</div>
<div>
<img
class={`flex items-center mx-auto object-scale-down h-8 w-8 ${
props.name === "AWS" ? "" : "grayscale"
}`}
// src={props.name === 'AWS' ? aws_edited : cloudflare_edited}
src={aws_edited}
/>
</div>
</div>
</div>
<div className="relative z-0 w-full h-full mb-6 group">
<input
type="key"
className="block py-2.5 px-0 w-full text-sm text-gray-900 bg-transparent border-0 border-b-2 border-gray-800 appearance-none focus:outline-none focus:ring-0 focus:border-blue-600 peer"
placeholder=" "
required
name="destAccessId"
id="destinationAccessId"
onChange={(e) => {
const newState = props.accessIdHandler(e, origin, destination);
dispatch(updateDestinationAccessId(newState));
}}
></input>
<label
htmlFor="destAccessId"
className="peer-focus:font-medium absolute text-base duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:left-0 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6"
>
Access ID{destination.accessId ? <>{" \u2705"}</> : <></>}
</label>
</div>
<div className="block relative z-0 w-full h-full mb-6 group">
<input
className="block py-2.5 px-0 w-full text-sm text-gray-900 bg-transparent border-0 border-b-2 border-gray-800 appearance-none focus:outline-none focus:ring-0 focus:border-blue-600 peer"
placeholder=" "
required
type="key"
name="destSecretKey"
id="destSecretKey"
onChange={(e) => {
const newState = props.secretKeyHandler(e, origin, destination);
dispatch(updateDestinationSecretKey(newState));
}}
></input>
<label
htmlFor="destSecretKey"
className="peer-focus:font-medium absolute text-base duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:left-0 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6"
>
Secret Key{destination.secretKey ? <>{" \u2705"}</> : <></>}
</label>
</div>
{props.name === "Cloudflare" && (
<div className="relative z-0 w-full h-full mb-6 group">
<input
className="block py-2.5 px-0 w-full text-sm text-gray-900 bg-transparent border-0 border-b-2 border-gray-800 appearance-none focus:outline-none focus:ring-0 focus:border-blue-600 peer"
placeholder=" "
required
type="id"
id="destAccountId"
name="destAccountId"
onChange={(e) => {
const newState = props.accountIdHandler(
e,
origin,
destination,
props.remoteType
);
dispatch(updateAccountId(newState));
}}
></input>
<label
htmlFor="destAccountId"
className="peer-focus:font-medium absolute text-base duration-300 transform -translate-y-6 scale-75 top-3 -z-10 origin-[0] peer-focus:left-0 peer-focus:text-blue-600 peer-placeholder-shown:scale-100 peer-placeholder-shown:translate-y-0 peer-focus:scale-75 peer-focus:-translate-y-6"
>
Account ID {destination.accountId.length > 1 && <>{"\u2705"}</>}
</label>
</div>
)}
{destination.errorMessage ? (
<ErrorComponent></ErrorComponent>
) : (
<div className="relative z-0 w-full h-full mb-6 group">
{bucketSelect}
</div>
)}
<div className="relative z-0 w-full h-full mb-6 group">
{origin.selectedBucket && destination.selectedBucket && (
<MigrationButton></MigrationButton>
)}
</div>
</div>
);
};
export default Destination;