-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Expand file tree
/
Copy pathGenerateDeployKeyModalView.tsx
More file actions
113 lines (107 loc) · 3.15 KB
/
GenerateDeployKeyModalView.tsx
File metadata and controls
113 lines (107 loc) · 3.15 KB
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
import React from "react";
import {
Button,
Flex,
Modal,
ModalBody,
ModalFooter,
ModalHeader,
} from "@appsmith/ads";
import {
GENERATE_DEPLOY_KEY_MODAL_TITLE,
GENERATE_DEPLOY_KEY_MODAL_WAIT_TEXT,
createMessage,
} from "ee/constants/messages";
import { StyledModalContent } from "git/components/common/GitUIComponents";
import styled from "styled-components";
import AddDeployKey from "git/components/common/AddDeployKey";
import type { ConnectFormDataState } from "git/components/common/types";
import type { GitApiError } from "git/store/types";
import Statusbar from "../Statusbar";
interface GenerateDeployKeyModalViewProps {
error: GitApiError | null;
formData: ConnectFormDataState;
isModalOpen: boolean;
isSSHKeyLoading: boolean;
onChange: (args: Partial<ConnectFormDataState>) => void;
onFetchSSHKey: () => void;
onGenerateSSHKey: (keyType: string) => void;
onModalOpenChange: (open: boolean) => void;
sshPublicKey: string | null;
onUpdateGeneratedSSHKey: () => void;
isUpdateGeneratedSSHKeyLoading: boolean;
}
const OFFSET = 200;
const OUTER_PADDING = 32;
const FOOTER = 56;
const HEADER = 44;
const StyledModalBody = styled(ModalBody)`
flex: 1;
overflow-y: initial;
display: flex;
flex-direction: column;
max-height: calc(
100vh - ${OFFSET}px - ${OUTER_PADDING}px - ${FOOTER}px - ${HEADER}px
);
`;
function GenerateDeployKeyModalView({
error,
formData,
isModalOpen,
isSSHKeyLoading,
isUpdateGeneratedSSHKeyLoading,
onChange,
onFetchSSHKey,
onGenerateSSHKey,
onModalOpenChange,
onUpdateGeneratedSSHKey,
sshPublicKey,
}: GenerateDeployKeyModalViewProps) {
const isSubmitLoading = false; // This modal doesn't have submit functionality
return (
<Modal onOpenChange={onModalOpenChange} open={isModalOpen}>
<StyledModalContent>
<ModalHeader>
{createMessage(GENERATE_DEPLOY_KEY_MODAL_TITLE)}
</ModalHeader>
<StyledModalBody>
<AddDeployKey
error={error}
isSSHKeyLoading={isSSHKeyLoading}
isSubmitLoading={isSubmitLoading}
onChange={onChange}
onFetchSSHKey={onFetchSSHKey}
onGenerateSSHKey={onGenerateSSHKey}
sshPublicKey={sshPublicKey}
value={formData}
/>
</StyledModalBody>
<ModalFooter>
<Flex
alignItems="center"
flex={1}
flexDirection="row-reverse"
justifyContent="space-between"
>
<Button
data-testid="t--git-generate-deploy-key-finish-btn"
isDisabled={!formData.isAddedDeployKey}
isLoading={isUpdateGeneratedSSHKeyLoading}
onClick={onUpdateGeneratedSSHKey}
size="md"
>
Finish
</Button>
{isUpdateGeneratedSSHKeyLoading && (
<Statusbar
completed={!isUpdateGeneratedSSHKeyLoading}
message={createMessage(GENERATE_DEPLOY_KEY_MODAL_WAIT_TEXT)}
/>
)}
</Flex>
</ModalFooter>
</StyledModalContent>
</Modal>
);
}
export default GenerateDeployKeyModalView;