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

Show warning unknown check selection #840

Merged
merged 5 commits into from
Sep 23, 2022
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
4 changes: 4 additions & 0 deletions .photofinish.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ files = ["./test/fixtures/scenarios/clusters-overview/13e8c25c-3180-5a9a-95c8-51

files = ["./test/fixtures/scenarios/clusters-overview/13e8c25c-3180-5a9a-95c8-51ec38e50cfc_ha_cluster_discovery_unnamed.json"]

[cluster-unknown-provider]

files = ["./test/fixtures/scenarios/hana-cluster-details/b767b3e9-e802-587e-a442-541d093b86b9_ha_cluster_discovery_unknown_provider.json"]

[host-details-azure]

files = ["./test/fixtures/scenarios/healthy-27-node-SAP-cluster/9cd46919-5f19-59aa-993e-cf3736c71053_cloud_discovery.json"]
Expand Down
25 changes: 25 additions & 0 deletions assets/js/components/Banners/WarningBanner.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';

import { EOS_WARNING_OUTLINED } from 'eos-icons-react';

const WarningBanner = ({ children }) => {
return (
<div className="bg-yellow-50 rounded mt-2 mb-2 p-3 border-2 border-yellow-500">
<div className="flex flex-wrap items-center justify-between">
<div className="flex w-0 flex-1 items-center">
<EOS_WARNING_OUTLINED className="h-6 w-6 fill-yellow-500" />
<p className="ml-3 truncate font-medium">
<span
data-testid="warning-banner"
className="md:inline text-yellow-500"
>
{children}
</span>
</p>
</div>
</div>
</div>
);
};

export default WarningBanner;
21 changes: 21 additions & 0 deletions assets/js/components/Banners/WarningBanner.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';

import WarningBanner from './WarningBanner';

describe('WarningBanner', () => {
it('should display a warning banner with its text and icon', () => {
render(
<WarningBanner>
Warning!
<br />
You should have a look on this!
</WarningBanner>
);

expect(screen.getByTestId('warning-banner')).toHaveTextContent(
'Warning!You should have a look on this!'
);
});
});
53 changes: 23 additions & 30 deletions assets/js/components/ClusterDetails/ChecksResults.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import LoadingBox from '../LoadingBox';

import Button from '@components/Button';
import BackButton from '@components/BackButton';
import WarningBanner from '@components/Banners/WarningBanner';
import { UNKNOWN_PROVIDER } from '@components/ClusterDetails/ClusterSettings';

import { getCluster } from '@state/selectors';
import TrentoLogo from '../../../static/trento-icon.png';
Expand Down Expand Up @@ -63,14 +65,11 @@ export const ChecksResults = () => {
const cluster = useSelector(getCluster(clusterID));
const [hasAlreadyChecksResults, setHasAlreadyChecksResults] = useState(false);

const [catalogData, catalogErrorCode, catalogError, loading] = useSelector(
(state) => [
state.catalog.data,
state.catalog.errorCode,
state.catalog.error,
state.catalog.loading,
]
);
const [catalogData, catalogError, loading] = useSelector((state) => [
state.catalog.data,
state.catalog.error,
state.catalog.loading,
]);

const findCheckDataByID = (checkID) => {
return catalogData.find((check) => check.id === checkID);
Expand Down Expand Up @@ -107,28 +106,14 @@ export const ChecksResults = () => {
};

if (catalogError) {
if (catalogErrorCode == 'not_found') {
pageContent = (
<NotificationBox
icon={<EOS_ERROR className="m-auto" color="red" size="xl" />}
text={
<ReactMarkdown
className="markdown"
remarkPlugins={[remarkGfm]}
>{`Provider \`${cluster?.provider}\` does not support checks execution`}</ReactMarkdown>
}
/>
);
} else {
pageContent = (
<NotificationBox
icon={<EOS_ERROR className="m-auto" color="red" size="xl" />}
text={catalogError}
buttonText="Try again"
buttonOnClick={dispatchUpdateCatalog}
/>
);
}
pageContent = (
<NotificationBox
icon={<EOS_ERROR className="m-auto" color="red" size="xl" />}
text={catalogError}
buttonText="Try again"
buttonOnClick={dispatchUpdateCatalog}
/>
);
} else if (!hasAlreadyChecksResults) {
pageContent = (
<HintForChecksSelection
Expand Down Expand Up @@ -253,6 +238,14 @@ export const ChecksResults = () => {
}
/>
</div>
{cluster.provider == 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>
)}
{pageContent}
</div>
);
Expand Down
27 changes: 5 additions & 22 deletions assets/js/components/ClusterDetails/ChecksSelection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,11 @@ export const ChecksSelection = ({ clusterId, cluster }) => {
const isSelected = (check_id) =>
selectedChecks ? selectedChecks.includes(check_id) : false;

const [[catalogData], catalogErrorCode, catalogError, loading] = useSelector(
(state) => [
state.catalog.data,
state.catalog.errorCode,
state.catalog.error,
state.catalog.loading,
]
);
const [[catalogData], catalogError, loading] = useSelector((state) => [
state.catalog.data,
state.catalog.error,
state.catalog.loading,
]);

const { saving, savingError, savingSuccess } = useSelector(
(state) => state.clusterChecksSelection
Expand Down Expand Up @@ -103,20 +100,6 @@ export const ChecksSelection = ({ clusterId, cluster }) => {
}
}, [loading]);

if (catalogErrorCode == 'not_found') {
return (
<NotificationBox
icon={<EOS_ERROR className="m-auto" color="red" size="xl" />}
text={
<ReactMarkdown
className="markdown"
remarkPlugins={[remarkGfm]}
>{`Provider \`${cluster?.provider}\` does not support checks execution`}</ReactMarkdown>
}
/>
);
}

if (catalogError) {
return (
<NotificationBox
Expand Down
11 changes: 11 additions & 0 deletions assets/js/components/ClusterDetails/ClusterSettings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import {
truncatedClusterNameClasses,
} from './ClusterDetails';
import { getClusterName } from '@components/ClusterLink';
import WarningBanner from '@components/Banners/WarningBanner';

export const UNKNOWN_PROVIDER = 'unknown';

export const ClusterSettings = () => {
const { clusterID } = useParams();
Expand Down Expand Up @@ -62,6 +65,14 @@ export const ClusterSettings = () => {
</Tab>
))}
</Tab.List>
{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>
)}
<Tab.Panels className="mt-2">
{Object.values(tabsSettings).map((tabContent, idx) => (
<Tab.Panel
Expand Down
21 changes: 21 additions & 0 deletions test/e2e/cypress/integration/hana_cluster_details.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,25 @@ context('HANA database details', () => {
cy.get('.tn-check-result-row').should('have.length', 68);
});
});

describe('Cluster with unknown provider', () => {
before(() => {
cy.loadScenario('cluster-unknown-provider');
cy.visit(`/clusters/${availableHanaCluster.id}`);
});

it(`should show a warning message in the check selection view`, () => {
cy.contains('button', 'Settings').click();
cy.get('[data-testid="warning-banner"]').contains(
'The following catalog is valid for on-premise bare metal platforms.'
);
});

it(`should show a warning message in the checks results view`, () => {
cy.visit(`/clusters/${availableHanaCluster.id}/checks/results`);
cy.get('[data-testid="warning-banner"]').contains(
'The following results are valid for on-premise bare metal platforms.'
);
});
});
});
Loading