-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddHostModal.tsx
More file actions
67 lines (65 loc) · 2.03 KB
/
AddHostModal.tsx
File metadata and controls
67 lines (65 loc) · 2.03 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
import type { HostBinding, HostConfig, HostMetadata, SshKeyObject, UserObject } from "../types";
import { HostForm } from "./HostForm";
export type AddHostModalProps = {
newHostDraft: HostConfig;
onChangeNewHost: (host: HostConfig) => void;
storeKeys: SshKeyObject[];
storeUsers: UserObject[];
sshHosts: HostConfig[];
hostMetadataByHost: Record<string, HostMetadata | undefined>;
hostBindingDraft: HostBinding;
onHostBindingDraftChange: (binding: HostBinding) => void;
onClose: () => void;
onCreateHost: () => void;
canCreateHost: boolean;
error: string;
};
export function AddHostModal({
newHostDraft,
onChangeNewHost,
storeKeys,
storeUsers,
sshHosts,
hostMetadataByHost,
hostBindingDraft,
onHostBindingDraftChange,
onClose,
onCreateHost,
canCreateHost,
error,
}: AddHostModalProps) {
return (
<div className="app-settings-overlay" onClick={onClose}>
<section className="app-settings-modal panel add-host-modal" onClick={(event) => event.stopPropagation()}>
<header className="panel-header">
<h2>Add host</h2>
<button className="btn" onClick={onClose}>
Cancel
</button>
</header>
<div className="app-settings-content">
<HostForm
host={newHostDraft}
onChange={onChangeNewHost}
storeKeys={storeKeys}
hostBinding={hostBindingDraft}
onHostBindingChange={onHostBindingDraftChange}
storeUsers={storeUsers}
sshHosts={sshHosts}
hostAliasForJumpExclude={newHostDraft.host.trim()}
hostMetadataByHost={hostMetadataByHost}
/>
<div className="action-row">
<button className="btn" onClick={onClose}>
Cancel
</button>
<button className="btn btn-primary" onClick={onCreateHost} disabled={!canCreateHost}>
Add host
</button>
</div>
{error && <p className="error-text">{error}</p>}
</div>
</section>
</div>
);
}