Skip to content

Commit b4b4c82

Browse files
authored
Merge pull request #1129 from sgratch/seperate-to-vcenter-esxi-cresentials-list
🐞 Replace vSphere credentials list page with vCenter and Esxi pages
2 parents 0505233 + 3ba9d07 commit b4b4c82

File tree

6 files changed

+105
-6
lines changed

6 files changed

+105
-6
lines changed

packages/forklift-console-plugin/locales/en/plugin__forklift-console-plugin.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"404: Not Found": "404: Not Found",
1616
"7 days": "7 days",
1717
"A CA certificate to be trusted when connecting to Openshift API endpoint. Ensure the CA certificate format is in a PEM encoded X.509 format. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.": "A CA certificate to be trusted when connecting to Openshift API endpoint. Ensure the CA certificate format is in a PEM encoded X.509 format. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.",
18+
"A CA certificate to be trusted when connecting to the ESXi API endpoint. Ensure the CA certificate format is in a PEM encoded X.509 format. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.": "A CA certificate to be trusted when connecting to the ESXi API endpoint. Ensure the CA certificate format is in a PEM encoded X.509 format. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.",
1819
"A CA certificate to be trusted when connecting to the OpenStack Identity (Keystone) endpoint. Ensure the CA certificate format is valid. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.": "A CA certificate to be trusted when connecting to the OpenStack Identity (Keystone) endpoint. Ensure the CA certificate format is valid. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.",
1920
"A CA certificate to be trusted when connecting to the Red Hat Virtualization Manager (RHVM) API endpoint. Ensure the CA certificate format is in a PEM encoded X.509 format. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.": "A CA certificate to be trusted when connecting to the Red Hat Virtualization Manager (RHVM) API endpoint. Ensure the CA certificate format is in a PEM encoded X.509 format. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.",
2021
"A CA certificate to be trusted when connecting to the vCenter API endpoint. Ensure the CA certificate format is in a PEM encoded X.509 format. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.": "A CA certificate to be trusted when connecting to the vCenter API endpoint. Ensure the CA certificate format is in a PEM encoded X.509 format. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.",

packages/forklift-console-plugin/src/modules/Providers/views/details/components/CredentialsSection/EsxiCredentialsSection.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
BaseCredentialsSectionProps,
88
} from './components/BaseCredentialsSection';
99
import { EsxiCredentialsEdit } from './components/edit/EsxiCredentialsEdit';
10-
import { VSphereCredentialsList } from './components/list/VSphereCredentialsList';
10+
import { EsxiCredentialsList } from './components/list';
1111

1212
export type EsxiCredentialsSectionProps = Omit<
1313
BaseCredentialsSectionProps,
@@ -19,7 +19,7 @@ export const EsxiCredentialsSection: React.FC<EsxiCredentialsSectionProps> = (pr
1919
<BaseCredentialsSection
2020
{...props}
2121
validator={esxiSecretValidator}
22-
ListComponent={VSphereCredentialsList}
22+
ListComponent={EsxiCredentialsList}
2323
EditComponent={EsxiCredentialsEdit}
2424
/>
2525
</ModalHOC>

packages/forklift-console-plugin/src/modules/Providers/views/details/components/CredentialsSection/VCenterCredentialsSection.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
BaseCredentialsSectionProps,
88
} from './components/BaseCredentialsSection';
99
import { VCenterCredentialsEdit } from './components/edit/VCenterCredentialsEdit';
10-
import { VSphereCredentialsList } from './components/list/VSphereCredentialsList';
10+
import { VCenterCredentialsList } from './components/list/VCenterCredentialsList';
1111

1212
export type VCenterCredentialsSectionProps = Omit<
1313
BaseCredentialsSectionProps,
@@ -19,7 +19,7 @@ export const VCenterCredentialsSection: React.FC<VCenterCredentialsSectionProps>
1919
<BaseCredentialsSection
2020
{...props}
2121
validator={vcenterSecretValidator}
22-
ListComponent={VSphereCredentialsList}
22+
ListComponent={VCenterCredentialsList}
2323
EditComponent={VCenterCredentialsEdit}
2424
/>
2525
</ModalHOC>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import React from 'react';
2+
import { Base64 } from 'js-base64';
3+
import { ForkliftTrans, useForkliftTranslation } from 'src/utils/i18n';
4+
5+
import { Text, TextVariants } from '@patternfly/react-core';
6+
7+
import { FieldWithClipboardCopy } from '../../FieldWithClipboardCopy';
8+
import { MaskedField } from '../../MaskedField';
9+
import { ListComponentProps } from '../BaseCredentialsSection';
10+
11+
import { Fields } from './Fields';
12+
13+
export const EsxiCredentialsList: React.FC<ListComponentProps> = ({ secret, reveal }) => {
14+
const { t } = useForkliftTranslation();
15+
16+
const items = [];
17+
18+
const insecureSkipVerifyHelperTextPopover = (
19+
<ForkliftTrans>
20+
<p>
21+
Select <strong>Skip certificate validation</strong> to skip certificate verification, which
22+
proceeds with an insecure migration and then the certificate is not required. Insecure
23+
migration means that the transferred data is sent over an insecure connection and
24+
potentially sensitive data could be exposed.
25+
</p>
26+
</ForkliftTrans>
27+
);
28+
29+
const cacertHelperTextPopover = (
30+
<ForkliftTrans>
31+
<p>
32+
Use the CA certificate of the Manager unless it was replaced by a third-party certificate,
33+
in which case enter the Manager Apache CA certificate.
34+
</p>
35+
<p>When left empty the system CA certificate is used.</p>
36+
<p>
37+
The certificate is not verified when <strong>Skip certificate validation</strong> is set.
38+
</p>
39+
</ForkliftTrans>
40+
);
41+
42+
const fields: Fields = {
43+
user: {
44+
label: t('Username'),
45+
description: (
46+
<div className="forklift-page-provider-field-default-validation">
47+
<ForkliftTrans>
48+
A username and domain for connecting to the ESXi API endpoint. For example:{' '}
49+
<strong>user</strong>.
50+
</ForkliftTrans>
51+
</div>
52+
),
53+
},
54+
password: {
55+
label: t('Password'),
56+
description: 'A user password for connecting to the ESXi API endpoint.',
57+
},
58+
insecureSkipVerify: {
59+
label: t('Skip certificate validation'),
60+
description: t("If true, the provider's TLS certificate won't be validated."),
61+
cacertHelperTextPopover: insecureSkipVerifyHelperTextPopover,
62+
displayType: 'switch',
63+
},
64+
cacert: {
65+
label: t('CA certificate'),
66+
description: t(
67+
'A CA certificate to be trusted when connecting to the ESXi API endpoint. Ensure the CA certificate format is in a PEM encoded X.509 format. To use a CA certificate, drag the file to the text box or browse for it. To use the system CA certificate, leave the field empty.',
68+
),
69+
helperTextPopover: cacertHelperTextPopover,
70+
displayType: 'textArea',
71+
},
72+
};
73+
74+
for (const key in fields) {
75+
const field = fields[key];
76+
const base64Value = secret.data?.[key];
77+
const value = base64Value ? Base64.decode(secret.data[key]) : undefined;
78+
79+
items.push(
80+
<>
81+
<div className="forklift-page-secret-title-div">
82+
<Text component={TextVariants.h6} className="forklift-page-secret-title">
83+
{field.label}
84+
</Text>
85+
<Text component={TextVariants.small} className="forklift-page-secret-subtitle">
86+
{field.description}
87+
</Text>
88+
</div>
89+
<div className="forklift-page-secret-content-div">
90+
{reveal ? <FieldWithClipboardCopy field={field} value={value} /> : <MaskedField />}
91+
</div>
92+
</>,
93+
);
94+
}
95+
96+
return <>{items}</>;
97+
};
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { ListComponentProps } from '../BaseCredentialsSection';
1010

1111
import { Fields } from './Fields';
1212

13-
export const VSphereCredentialsList: React.FC<ListComponentProps> = ({ secret, reveal }) => {
13+
export const VCenterCredentialsList: React.FC<ListComponentProps> = ({ secret, reveal }) => {
1414
const { t } = useForkliftTranslation();
1515

1616
const items = [];
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// @index('./*.tsx', f => `export * from '${f.path}';`)
2+
export * from './EsxiCredentialsList';
23
export * from './Fields';
34
export * from './OpenshiftCredentialsList';
45
export * from './OpenstackCredentialsList';
56
export * from './OvirtCredentialsList';
6-
export * from './VSphereCredentialsList';
7+
export * from './VCenterCredentialsList';
78
// @endindex

0 commit comments

Comments
 (0)