Skip to content

Commit ddc8d56

Browse files
authored
Merge pull request #1155 from yaacov/add-wmware-ui-link
🐾 Add link to vmware ui
2 parents dfbffbd + 3e2b6f3 commit ddc8d56

File tree

7 files changed

+47
-18
lines changed

7 files changed

+47
-18
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@
200200
"Issuer": "Issuer",
201201
"Kubernetes name of the new migration Plan resource": "Kubernetes name of the new migration Plan resource",
202202
"Label": "Label",
203-
"Link for the Red Hat Virtualization Manager (RHVM) landing page. For example, https://rhv-host-example.com/ovirt-engine.": "Link for the Red Hat Virtualization Manager (RHVM) landing page. For example, https://rhv-host-example.com/ovirt-engine.",
203+
"Link for the provider Virtualization Manager landing page. For example, https://rhv-host-example.com/ovirt-engine.": "Link for the provider Virtualization Manager landing page. For example, https://rhv-host-example.com/ovirt-engine.",
204204
"List of objects depended by this object. If ALL objects in the list have been deleted,\n this object will be garbage collected. If this object is managed by a controller,\n then an entry in this list will point to this controller, with the controller field set to true.\n There cannot be more than one managing controller.": "List of objects depended by this object. If ALL objects in the list have been deleted,\n this object will be garbage collected. If this object is managed by a controller,\n then an entry in this list will point to this controller, with the controller field set to true.\n There cannot be more than one managing controller.",
205205
"Loading": "Loading",
206206
"Loading...": "Loading...",
@@ -506,6 +506,7 @@
506506
"VM(s) with NICs that are not linked with a NIC profile were detected.": "VM(s) with NICs that are not linked with a NIC profile were detected.",
507507
"VMs": "VMs",
508508
"VMware only: vSphere product name.": "VMware only: vSphere product name.",
509+
"VMware UI": "VMware UI",
509510
"VMware Virtual Disk Development Kit (VDDK) image, for example: quay.io/kubev2v/vddk:latest .": "VMware Virtual Disk Development Kit (VDDK) image, for example: quay.io/kubev2v/vddk:latest .",
510511
"Volume Types": "Volume Types",
511512
"Volumes": "Volumes",

packages/forklift-console-plugin/src/modules/Providers/modals/EditProviderUI/EditProviderUIModal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ export type EditProviderUIModalProps = Modify<
2121

2222
export const EditProviderUIModal: React.FC<EditProviderUIModalProps> = (props) => {
2323
switch (props.resource?.spec?.type) {
24+
case 'vsphere':
2425
case 'ovirt':
2526
return <OvirtEditUIModal {...props} />;
2627
case 'openshift':
2728
case 'openstack':
28-
case 'vsphere':
2929
default:
3030
return <></>;
3131
}

packages/forklift-console-plugin/src/modules/Providers/modals/EditProviderUI/OvirtEditUIModal.tsx

+3-12
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,8 @@ export const OvirtEditUIModal: React.FC<EditProviderUIModalProps> = (props) => {
1515

1616
const ModalBody = (
1717
<ForkliftTrans>
18-
<p>Link for the Red Hat Virtualization Manager (RHVM) landing page.</p>
19-
<br />
20-
<p>Use this link to access the RHVM user interface for RHV VMs management.</p>
21-
<br />
22-
<p>
23-
The format of the provided link for the Red Hat Virtualization Manager (RHVM) landing page
24-
should include a scheme, a domain name, path, and optionally a port. Usually the path will
25-
end with /ovirt-engine, for example:{' '}
26-
<strong>https://rhv-host-example.com/ovirt-engine</strong>.
27-
</p>
28-
<br />
18+
<p>Link for the Provider Virtualization Manager landing page.</p>
19+
<p>Use this link to access the user interface for the providers virtualization management.</p>
2920
<p>If no link value is specify then a default auto calculated or an empty value is set.</p>
3021
</ForkliftTrans>
3122
);
@@ -40,7 +31,7 @@ export const OvirtEditUIModal: React.FC<EditProviderUIModalProps> = (props) => {
4031
variant={ModalVariant.large}
4132
body={ModalBody}
4233
helperText={t(
43-
'Link for the Red Hat Virtualization Manager (RHVM) landing page. For example, https://rhv-host-example.com/ovirt-engine.',
34+
'Link for the provider Virtualization Manager landing page. For example, https://rhv-host-example.com/ovirt-engine.',
4435
)}
4536
onConfirmHook={patchProviderUI}
4637
validationHook={validateOvirtUILink}

packages/forklift-console-plugin/src/modules/Providers/views/details/components/DetailsSection/VSphereDetailsSection.tsx

+13-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { DetailsItem } from '../../../../utils';
88
import {
99
CreatedAtDetailsItem,
1010
CredentialsDetailsItem,
11+
ExternalManagementLinkDetailsItem,
1112
NameDetailsItem,
1213
NamespaceDetailsItem,
1314
OwnerDetailsItem,
@@ -16,11 +17,13 @@ import {
1617
VDDKDetailsItem,
1718
} from './components';
1819
import { DetailsSectionProps } from './DetailsSection';
20+
import { getVSphereProviderWebUILink } from './utils';
1921

2022
export const VSphereDetailsSection: React.FC<DetailsSectionProps> = ({ data }) => {
2123
const { t } = useForkliftTranslation();
2224

2325
const { provider, permissions } = data;
26+
const webUILink = getVSphereProviderWebUILink(provider);
2427

2528
return (
2629
<DescriptionList
@@ -39,7 +42,12 @@ export const VSphereDetailsSection: React.FC<DetailsSectionProps> = ({ data }) =
3942

4043
<NameDetailsItem resource={provider} />
4144

42-
<NamespaceDetailsItem resource={provider} />
45+
<ExternalManagementLinkDetailsItem
46+
resource={provider}
47+
canPatch={permissions.canPatch}
48+
webUILinkText={t(`VMware UI`)}
49+
webUILink={webUILink}
50+
/>
4351

4452
<URLDetailsItem
4553
resource={provider}
@@ -57,13 +65,15 @@ export const VSphereDetailsSection: React.FC<DetailsSectionProps> = ({ data }) =
5765
}
5866
/>
5967

60-
<CredentialsDetailsItem resource={provider} />
68+
<NamespaceDetailsItem resource={provider} />
6169

6270
<CreatedAtDetailsItem resource={provider} />
6371

64-
<VDDKDetailsItem resource={provider} canPatch={permissions.canPatch} />
72+
<CredentialsDetailsItem resource={provider} />
6573

6674
<OwnerDetailsItem resource={provider} />
75+
76+
<VDDKDetailsItem resource={provider} canPatch={permissions.canPatch} />
6777
</DescriptionList>
6878
);
6979
};

packages/forklift-console-plugin/src/modules/Providers/views/details/components/DetailsSection/utils/getOvirtProviderWebUILink.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const getOvirtProviderWebUILink = (provider: V1beta1Provider): string =>
1616
}
1717

1818
// Calculate link using API URL
19-
const uiLinkRegexp = new RegExp('(?<=ovirt-engine)\\/api(\\/)*$', 'g');
19+
const uiLinkRegexp = new RegExp('(?<=ovirt-engine)/api(/)?$', 'g');
2020
const regexpResult = uiLinkRegexp.exec(provider?.spec?.url);
2121

2222
return provider?.spec?.url && regexpResult
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { V1beta1Provider } from '@kubev2v/types';
2+
3+
import { getProviderUIAnnotation } from './getProviderUIAnnotation';
4+
5+
/**
6+
* A function for auto calculating the vSphere UI link.
7+
* It extracts the provider's vSphere UI link from the vSphere URL by searching for the URL's
8+
*/
9+
export const getVSphereProviderWebUILink = (provider: V1beta1Provider): string => {
10+
// Check for custom link
11+
const customLink = getProviderUIAnnotation(provider);
12+
if (customLink) {
13+
return customLink;
14+
}
15+
16+
// Calculate link using API URL
17+
const url = provider?.spec?.url || '';
18+
const suffix = '/sdk';
19+
const newSuffix = '/ui';
20+
21+
if (url.endsWith(suffix)) {
22+
return url.slice(0, -suffix.length) + newSuffix;
23+
} else {
24+
return url;
25+
}
26+
};
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @index(['./*', /style/g], f => `export * from '${f.path}';`)
22
export * from './getOvirtProviderWebUILink';
33
export * from './getProviderUIAnnotation';
4+
export * from './getVSphereProviderWebUILink';
45
// @endindex

0 commit comments

Comments
 (0)