Skip to content

Commit 6108c61

Browse files
committed
Added cloud integration support for cluster info modal
1 parent 9ca8f2b commit 6108c61

File tree

14 files changed

+243
-91
lines changed

14 files changed

+243
-91
lines changed

locales/data.json

+57-6
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,12 @@
997997
"value": "Close"
998998
}
999999
],
1000+
"cloudIntegration": [
1001+
{
1002+
"type": 0,
1003+
"value": "Cloud integration"
1004+
}
1005+
],
10001006
"cluster": [
10011007
{
10021008
"type": 0,
@@ -9711,6 +9717,57 @@
97119717
"value": "Infrastructure"
97129718
}
97139719
],
9720+
"integration": [
9721+
{
9722+
"options": {
9723+
"aws": {
9724+
"value": [
9725+
{
9726+
"type": 0,
9727+
"value": "Amazon Web Services source:"
9728+
}
9729+
]
9730+
},
9731+
"azure": {
9732+
"value": [
9733+
{
9734+
"type": 0,
9735+
"value": "Microsoft Azure source:"
9736+
}
9737+
]
9738+
},
9739+
"gcp": {
9740+
"value": [
9741+
{
9742+
"type": 0,
9743+
"value": "Google Cloud Platform source:"
9744+
}
9745+
]
9746+
},
9747+
"oci": {
9748+
"value": [
9749+
{
9750+
"type": 0,
9751+
"value": "Oracle Cloud Infrastructure source:"
9752+
}
9753+
]
9754+
},
9755+
"ocp": {
9756+
"value": [
9757+
{
9758+
"type": 0,
9759+
"value": "OpenShift source:"
9760+
}
9761+
]
9762+
},
9763+
"other": {
9764+
"value": []
9765+
}
9766+
},
9767+
"type": 5,
9768+
"value": "value"
9769+
}
9770+
],
97149771
"lastProcessed": [
97159772
{
97169773
"type": 0,
@@ -10585,12 +10642,6 @@
1058510642
"value": "Memory usage and requests"
1058610643
}
1058710644
],
10588-
"ocpSource": [
10589-
{
10590-
"type": 0,
10591-
"value": "OpenShift source:"
10592-
}
10593-
],
1059410645
"ocpVolumeUsageAndRequests": [
1059510646
{
1059610647
"type": 0,

locales/translations.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"chooseKeyPlaceholder": "Choose key",
6161
"chooseValuePlaceholder": "Choose value",
6262
"close": "Close",
63+
"cloudIntegration": "Cloud integration",
6364
"cluster": "Cluster",
6465
"clusterId": "Cluster id",
6566
"clusterInfo": "Cluster information",
@@ -341,6 +342,7 @@
341342
"inactiveSourcesTitle": "A problem was detected with {value}",
342343
"inactiveSourcesTitleMultiplier": "A problem was detected with the following integrations",
343344
"infrastructure": "Infrastructure",
345+
"integration": "{value, select, aws {Amazon Web Services source:} azure {Microsoft Azure source:} oci {Oracle Cloud Infrastructure source:} gcp {Google Cloud Platform source:} ocp {OpenShift source:} other {}}",
344346
"lastProcessed": "Last processed",
345347
"learnMore": "Learn more",
346348
"limits": "Limits",
@@ -428,7 +430,6 @@
428430
"ocpDetailsSupplementaryCostDesc": "All costs not directly attributed to the infrastructure. These costs are determined by applying a price list within a cost model to OpenShift cluster metrics.",
429431
"ocpDetailsTitle": "OpenShift Details",
430432
"ocpMemoryUsageAndRequests": "Memory usage and requests",
431-
"ocpSource": "OpenShift source:",
432433
"ocpVolumeUsageAndRequests": "Volume usage and requests",
433434
"openShift": "OpenShift",
434435
"openShiftCloudInfrastructure": "OpenShift cloud infrastructure",

src/api/providers.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ export const enum ProviderType {
7373
rhel = 'ocp', // Todo: Update to use rhel when APIs are available
7474
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
7575
ros = 'ocp', // Todo: Update to use rhel when APIs are available
76+
uuid = 'uuid',
7677
}
7778

78-
export function fetchProviders(query: string) {
79-
const queryString = query ? `?${query}` : '';
79+
export function fetchProviders(query: string, reportType: ProviderType = undefined) {
80+
const separator = reportType === ProviderType.uuid ? '' : '?';
81+
const queryString = query ? `${separator}${query}` : '';
8082
return axios.get<Providers>(`sources/${queryString}`);
8183
}

src/locales/messages.ts

+17-5
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,11 @@ export default defineMessages({
350350
description: 'Close',
351351
id: 'close',
352352
},
353+
cloudIntegration: {
354+
defaultMessage: 'Cloud integration',
355+
description: 'Cloud integration',
356+
id: 'cloudIntegration',
357+
},
353358
cluster: {
354359
defaultMessage: 'Cluster',
355360
description: 'Cluster',
@@ -2702,11 +2707,6 @@ export default defineMessages({
27022707
description: 'Memory usage and requests',
27032708
id: 'ocpMemoryUsageAndRequests',
27042709
},
2705-
ocpSource: {
2706-
defaultMessage: 'OpenShift source:',
2707-
description: 'OpenShift source',
2708-
id: 'ocpSource',
2709-
},
27102710
ocpVolumeUsageAndRequests: {
27112711
defaultMessage: 'Volume usage and requests',
27122712
description: 'Volume usage and requests',
@@ -3344,6 +3344,18 @@ export default defineMessages({
33443344
description: 'Jan 1-31',
33453345
id: 'sinceDate',
33463346
},
3347+
source: {
3348+
defaultMessage:
3349+
'{value, select, ' +
3350+
'aws {Amazon Web Services source:} ' +
3351+
'azure {Microsoft Azure source:} ' +
3352+
'oci {Oracle Cloud Infrastructure source:} ' +
3353+
'gcp {Google Cloud Platform source:} ' +
3354+
'ocp {OpenShift source:} ' +
3355+
'other {}}',
3356+
description: 'Select from the following {value} integrations:',
3357+
id: 'integration',
3358+
},
33473359
sourceType: {
33483360
defaultMessage: 'Integration',
33493361
description: 'Integration',

src/routes/details/components/pvcChart/modal/pvcModal.scss

-10
This file was deleted.

src/routes/details/components/pvcChart/modal/pvcModal.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import './pvcModal.scss';
2-
31
import { Modal } from '@patternfly/react-core';
42
import React from 'react';
53
import type { WrappedComponentProps } from 'react-intl';
@@ -34,7 +32,7 @@ class PvcModalBase extends React.Component<PvcModalProps, any> {
3432
const { isOpen, title } = this.props;
3533

3634
return (
37-
<Modal className="modalOverride" isOpen={isOpen} onClose={this.handleClose} title={title} width={'50%'}>
35+
<Modal isOpen={isOpen} onClose={this.handleClose} title={title} width={'50%'}>
3836
<PvcContent />
3937
</Modal>
4038
);

src/routes/details/components/summary/modal/summaryModal.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import './summaryModal.scss';
2-
31
import { Modal } from '@patternfly/react-core';
42
import type { Query } from 'api/queries/query';
53
import type { ReportPathsType } from 'api/reports/report';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
import { Text, TextList, TextListItem, TextVariants } from '@patternfly/react-core';
2+
import type { Provider } from 'api/providers';
3+
import { ProviderType } from 'api/providers';
4+
import type { AxiosError } from 'axios';
5+
import messages from 'locales/messages';
6+
import React, { useEffect } from 'react';
7+
import { useIntl } from 'react-intl';
8+
import { useDispatch, useSelector } from 'react-redux';
9+
import type { AnyAction } from 'redux';
10+
import type { ThunkDispatch } from 'redux-thunk';
11+
import { routes } from 'routes';
12+
import { NotAvailable } from 'routes/components/page/notAvailable';
13+
import { LoadingState } from 'routes/components/state/loadingState';
14+
import type { RootState } from 'store';
15+
import { FetchStatus } from 'store/common';
16+
import { providersActions, providersSelectors } from 'store/providers';
17+
import { formatPath, getReleasePath } from 'utils/paths';
18+
19+
import { styles } from './modal.styles';
20+
21+
interface CloudIntegrationOwnProps {
22+
uuid?: string;
23+
}
24+
25+
export interface CloudIntegrationStateProps {
26+
provider: Provider;
27+
providerError: AxiosError;
28+
providerFetchStatus: FetchStatus;
29+
providerQueryString: string;
30+
uuid?: string;
31+
}
32+
33+
export interface CloudIntegrationMapProps {
34+
// TBD...
35+
}
36+
37+
type CloudIntegrationProps = CloudIntegrationOwnProps;
38+
39+
const CloudIntegration: React.FC<CloudIntegrationProps> = ({ uuid }: CloudIntegrationProps) => {
40+
const intl = useIntl();
41+
42+
const { provider, providerError, providerFetchStatus } = useMapToProps({ uuid });
43+
44+
const title = intl.formatMessage(messages.optimizations);
45+
46+
if (providerError) {
47+
return <NotAvailable title={title} />;
48+
}
49+
50+
const release = getReleasePath();
51+
52+
if (providerFetchStatus === FetchStatus.inProgress) {
53+
return (
54+
<div style={styles.loading}>
55+
<LoadingState />
56+
</div>
57+
);
58+
}
59+
return (
60+
<>
61+
<Text component={TextVariants.h3}>{intl.formatMessage(messages.cloudIntegration)}</Text>
62+
<TextList isPlain>
63+
<TextListItem>
64+
<span style={styles.spacing}>
65+
{intl.formatMessage(messages.source, { value: provider?.source_type?.toLowerCase() })}
66+
</span>
67+
<a href={`${release}/settings/integrations/detail/${provider?.id}`}>{provider?.name}</a>
68+
</TextListItem>
69+
{provider?.cost_models?.length === 0 && (
70+
<TextListItem>
71+
<a href={formatPath(routes.settings.path)}>{intl.formatMessage(messages.assignCostModel)}</a>
72+
</TextListItem>
73+
)}
74+
</TextList>
75+
</>
76+
);
77+
};
78+
79+
// eslint-disable-next-line no-empty-pattern
80+
const useMapToProps = ({ uuid }): CloudIntegrationStateProps => {
81+
const dispatch: ThunkDispatch<RootState, any, AnyAction> = useDispatch();
82+
83+
const providerQueryString = uuid;
84+
const provider = useSelector(
85+
(state: RootState) => providersSelectors.selectProviders(state, ProviderType.uuid, providerQueryString) as Provider
86+
);
87+
const providerError = useSelector((state: RootState) =>
88+
providersSelectors.selectProvidersError(state, ProviderType.uuid, providerQueryString)
89+
);
90+
const providerFetchStatus = useSelector((state: RootState) =>
91+
providersSelectors.selectProvidersFetchStatus(state, ProviderType.uuid, providerQueryString)
92+
);
93+
94+
useEffect(() => {
95+
if (!providerError && providerFetchStatus !== FetchStatus.inProgress) {
96+
dispatch(providersActions.fetchProviders(ProviderType.uuid, providerQueryString));
97+
}
98+
}, []);
99+
100+
return {
101+
provider,
102+
providerError,
103+
providerFetchStatus,
104+
providerQueryString,
105+
};
106+
};
107+
108+
export { CloudIntegration };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@import url("~@patternfly/patternfly/base/patternfly-variables.css");
2+
3+
.textContentOverride {
4+
&.pf-v5-c-content ul {
5+
padding-left: var(--pf-v5-global--spacer--lg);
6+
}
7+
}

0 commit comments

Comments
 (0)