Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning banner improvement #1371

Merged
merged 3 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 17 additions & 23 deletions assets/js/components/ClusterDetails/ClusterSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,12 @@ import PageHeader from '@components/PageHeader';
import BackButton from '@components/BackButton';
import ChecksSelection from '@components/ClusterDetails/ChecksSelection';
import TriggerChecksExecutionRequest from '@components/TriggerChecksExecutionRequest';
import WarningBanner from '@components/Banners/WarningBanner';
import { getClusterName } from '@components/ClusterLink';
import { ClusterInfoBox } from '@components/ClusterDetails';

import { getCluster, getClusterHostIDs } from '@state/selectors/cluster';

export const UNKNOWN_PROVIDER = 'unknown';

export const providerWarningBanners = {
[UNKNOWN_PROVIDER]: (
<WarningBanner>
The following catalog is valid for on-premise bare metal platforms.
<br />
If you are running your HANA cluster on a different platform, please use
results with caution
</WarningBanner>
),
vmware: (
<WarningBanner>
Configuration checks for HANA scale-up performance optimized clusters on
VMware are still in experimental phase. Please use results with caution.
</WarningBanner>
),
};
import WarningBanner from '@components/Banners/WarningBanner';
import { UNKNOWN_PROVIDER, VMWARE_PROVIDER } from '@lib/model';

export function ClusterSettings() {
const { clusterID } = useParams();
Expand All @@ -42,8 +24,6 @@ export function ClusterSettings() {
return <div>Loading...</div>;
}

const warning = providerWarningBanners[cluster.provider];

return (
<div className="w-full px-2 sm:px-0">
<BackButton url={`/clusters/${clusterID}`}>
Expand All @@ -53,7 +33,21 @@ export function ClusterSettings() {
Cluster Settings for{' '}
<span className="font-bold">{getClusterName(cluster)}</span>
</PageHeader>
{warning}
{cluster.provider === UNKNOWN_PROVIDER && (
<WarningBanner>
The following catalog is valid for on-premise bare metal platforms.
<br />
If you are running your HANA cluster on a different platform, please
use results with caution
</WarningBanner>
)}
{cluster.provider === VMWARE_PROVIDER && (
<WarningBanner>
Configuration checks for HANA scale-up performance optimized clusters
on VMware are still in experimental phase. Please use results with
caution.
</WarningBanner>
)}
<ClusterInfoBox haScenario={cluster.type} provider={cluster.provider} />
<ChecksSelection clusterId={clusterID} cluster={cluster} />
</div>
Expand Down
3 changes: 2 additions & 1 deletion assets/js/components/ClusterDetails/ClusterSettings.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
import { catalogCheckFactory, clusterFactory } from '@lib/test-utils/factories';

import { Route, Routes, MemoryRouter } from 'react-router-dom';
import { ClusterSettings, UNKNOWN_PROVIDER } from './ClusterSettings';
import { UNKNOWN_PROVIDER } from '@lib/model';
import { ClusterSettings } from './ClusterSettings';

describe('ClusterDetails ClusterSettings component', () => {
it('should render the cluster info box and the catalog container', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';

import BackButton from '@components/BackButton';
import { providerWarningBanners } from '@components/ClusterDetails/ClusterSettings';
import HealthIcon from '@components/Health/HealthIcon';
import WarningBanner from '@components/Banners/WarningBanner';
import { UNKNOWN_PROVIDER, VMWARE_PROVIDER } from '@lib/model';
import CheckResultInfoBox from './CheckResultInfoBox';

function CheckDetailHeader({
Expand All @@ -14,8 +15,6 @@ function CheckDetailHeader({
cloudProvider,
result,
}) {
const warning = providerWarningBanners[cloudProvider];

return (
<>
<BackButton url={`/clusters/${clusterID}/executions/last`}>
Expand All @@ -29,7 +28,21 @@ function CheckDetailHeader({
<span className="font-medium">{checkDescription}</span>
</h1>
</div>
{warning}
{cloudProvider === UNKNOWN_PROVIDER && (
<WarningBanner>
The following results are valid for on-premise bare metal platforms.
<br />
If you are running your HANA cluster on a different platform, please
use results with caution
</WarningBanner>
)}
{cloudProvider === VMWARE_PROVIDER && (
<WarningBanner>
Configuration checks for HANA scale-up performance optimized clusters
on VMware are still in experimental phase. Please use results with
caution.
</WarningBanner>
)}
<CheckResultInfoBox
checkID={checkID}
targetType={targetType}
Expand Down
21 changes: 17 additions & 4 deletions assets/js/components/ExecutionResults/ExecutionHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import React from 'react';
import classNames from 'classnames';

import BackButton from '@components/BackButton';
import { providerWarningBanners } from '@components/ClusterDetails/ClusterSettings';
import { ClusterInfoBox } from '@components/ClusterDetails';

import ChecksResultFilters from '@components/ExecutionResults/ChecksResultFilters';
import { UNKNOWN_PROVIDER, VMWARE_PROVIDER } from '@lib/model';
import WarningBanner from '@components/Banners/WarningBanner';

function ExecutionHeader({
clusterID,
Expand All @@ -14,8 +15,6 @@ function ExecutionHeader({
clusterScenario,
onFilterChange = () => {},
}) {
const warning = providerWarningBanners[cloudProvider];

return (
<>
<BackButton url={`/clusters/${clusterID}`}>
Expand All @@ -34,7 +33,21 @@ function ExecutionHeader({
</h1>
<ChecksResultFilters onChange={onFilterChange} />
</div>
{warning}
{cloudProvider === UNKNOWN_PROVIDER && (
<WarningBanner>
The following results are valid for on-premise bare metal platforms.
<br />
If you are running your HANA cluster on a different platform, please
use results with caution
</WarningBanner>
)}
{cloudProvider === VMWARE_PROVIDER && (
<WarningBanner>
Configuration checks for HANA scale-up performance optimized clusters
on VMware are still in experimental phase. Please use results with
caution.
</WarningBanner>
)}
<ClusterInfoBox haScenario={clusterScenario} provider={cloudProvider} />
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Cluster Checks results ExecutionHeader Component', () => {
expect(screen.getByText('HANA scale-up')).toBeTruthy();
expect(
screen.getByText(
/The following catalog is valid for on-premise bare metal platforms./
/The following results are valid for on-premise bare metal platforms./
)
).toBeTruthy();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
agentsCheckResultsWithHostname,
} from '@lib/test-utils/factories';
import '@testing-library/jest-dom/extend-expect';
import { UNKNOWN_PROVIDER } from '@components/ClusterDetails/ClusterSettings';
import { UNKNOWN_PROVIDER } from '@lib/model';
import ExecutionResults from './ExecutionResults';

const prepareStateData = (checkExecutionStatus) => {
Expand Down Expand Up @@ -444,7 +444,7 @@ describe('ExecutionResults', () => {
expect(screen.getByText('Provider not recognized')).toBeTruthy();
expect(
screen.getByText(
/The following catalog is valid for on-premise bare metal platforms.*If you are running your HANA cluster on a different platform, please use results with caution/
/The following results are valid for on-premise bare metal platforms.*If you are running your HANA cluster on a different platform, please use results with caution/
)
).toBeTruthy();
});
Expand Down
3 changes: 3 additions & 0 deletions assets/js/lib/model/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ export const TARGET_CLUSTER = 'cluster';

export const isValidTargetType = (targetType) =>
[TARGET_HOST, TARGET_CLUSTER].includes(targetType);

export const UNKNOWN_PROVIDER = 'unknown';
export const VMWARE_PROVIDER = 'vmware';