Skip to content

Commit f182261

Browse files
Added label instead of Alert
1 parent d069965 commit f182261

File tree

9 files changed

+65
-39
lines changed

9 files changed

+65
-39
lines changed

frontend/packages/dev-console/src/components/add/AddPage.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { match as RMatch } from 'react-router';
66
import { withStartGuide } from '../../../../../public/components/start-guide';
77
import NamespacedPage, { NamespacedPageVariants } from '../NamespacedPage';
88
import CreateProjectListPage from '../projects/CreateProjectListPage';
9-
import { ResourceQuotaAlert } from '../resource-quota/ResourceQuotaAlert';
109
import AddPageLayout from './AddPageLayout';
1110

1211
export interface AddPageProps {
@@ -21,10 +20,7 @@ export const PageContents: React.FC<AddPageProps> = ({ match }) => {
2120
const namespace = match.params.ns;
2221

2322
return namespace ? (
24-
<>
25-
<ResourceQuotaAlert namespace={namespace} />
26-
<AddPageLayout title={t('devconsole~Add')} />
27-
</>
23+
<AddPageLayout title={t('devconsole~Add')} />
2824
) : (
2925
<CreateProjectListPage title={t('devconsole~Add')}>
3026
{(openProjectModal) => (

frontend/packages/dev-console/src/components/add/AddPageLayout.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,8 @@
5252
&__additional-hint-block {
5353
padding-bottom: var(--pf-global--spacer--md);
5454
}
55+
56+
&__resource-quota-message-block {
57+
margin-right: var(--pf-global--spacer--xl);
58+
}
5559
}

frontend/packages/dev-console/src/components/add/AddPageLayout.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import TopologyQuickSearch from '@console/topology/src/components/quick-search/T
1010
import TopologyQuickSearchButton from '@console/topology/src/components/quick-search/TopologyQuickSearchButton';
1111
import { filterNamespaceScopedUrl } from '../../utils/add-page-utils';
1212
import { useAddActionExtensions } from '../../utils/useAddActionExtensions';
13+
import { ResourceQuotaAlert } from '../resource-quota/ResourceQuotaAlert';
1314
import AddCardSection from './AddCardSection';
1415
import { GETTING_STARTED_USER_SETTINGS_KEY } from './constants';
1516
import { GettingStartedSection } from './GettingStartedSection';
@@ -65,6 +66,9 @@ const AddPageLayout: React.FC<AddPageLayoutProps> = ({ title, hintBlock: additio
6566
<TopologyQuickSearchButton onClick={() => setIsQuickSearchOpen(true)} />
6667
</div>
6768
<div className="odc-add-page-layout__hint-block__actions">
69+
<div className="odc-add-page-layout__resource-quota-message-block">
70+
<ResourceQuotaAlert namespace={activeNamespace} />
71+
</div>
6872
<RestoreGettingStartedButton userSettingsKey={GETTING_STARTED_USER_SETTINGS_KEY} />
6973
<div
7074
className={cx('odc-add-page-layout__hint-block__details-switch', {

frontend/packages/dev-console/src/components/resource-quota/ResourceQuotaAlert.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import * as React from 'react';
2-
import { Alert } from '@patternfly/react-core';
2+
import { Label } from '@patternfly/react-core';
33
import { useTranslation } from 'react-i18next';
44
import { Link } from 'react-router-dom';
5-
import { useK8sWatchResource } from '@console/dynamic-plugin-sdk/src/api/core-api';
5+
import {
6+
useK8sWatchResource,
7+
YellowExclamationTriangleIcon,
8+
} from '@console/dynamic-plugin-sdk/src/api/core-api';
69
import { AppliedClusterResourceQuotaModel, ResourceQuotaModel } from '@console/internal/models';
710
import { AppliedClusterResourceQuotaKind, ResourceQuotaKind } from '@console/internal/module/k8s';
811
import { checkQuotaLimit } from '@console/topology/src/components/utils/checkResourceQuota';
@@ -69,13 +72,13 @@ export const ResourceQuotaAlert: React.FC<ResourceQuotaAlertProps> = ({ namespac
6972
return (
7073
<>
7174
{warningMessageFlag && rqLoaded && acrqLoaded ? (
72-
<Alert variant="warning" title={t('devconsole~Resource quota reached')} isInline>
73-
<Link to={getRedirectLink()}>
75+
<Label color="orange" icon={<YellowExclamationTriangleIcon />}>
76+
<Link to={getRedirectLink()} data-test="resource-quota-warning">
7477
{t('devconsole~{{count}} resource reached quota', {
7578
count: totalResourcesAtQuota.reduce((a, b) => a + b, 0),
7679
})}
7780
</Link>
78-
</Alert>
81+
</Label>
7982
) : null}
8083
</>
8184
);

frontend/packages/topology/integration-tests/support/step-definitions/topology/resource-quota-warning.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,7 @@ When('user enters the {string} file data to YAML Editor', (yamlFile: string) =>
9191
});
9292

9393
When('user clicks on link to view resource quota details', () => {
94-
cy.get('h4.pf-c-alert__title').should('contain.text', 'Resource quota reached');
95-
cy.get('a')
96-
.contains('reached quota')
97-
.click();
94+
cy.byTestID('resource-quota-warning').click();
9895
});
9996

10097
Then('user is redirected to resource quota details page', () => {

frontend/packages/topology/src/components/export-app/ExportApplication.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,14 @@ import { handleExportApplication } from './ExportApplicationModal';
1010
type ExportApplicationProps = {
1111
namespace: string;
1212
isDisabled: boolean;
13+
setIsExportAppEnabled?: (showExportAppBtn: boolean) => void;
1314
};
1415

15-
const ExportApplication: React.FC<ExportApplicationProps> = ({ namespace, isDisabled }) => {
16+
const ExportApplication: React.FC<ExportApplicationProps> = ({
17+
namespace,
18+
isDisabled,
19+
setIsExportAppEnabled,
20+
}) => {
1621
const { t } = useTranslation();
1722
const isMobile = useIsMobile();
1823
const toast = useToast();
@@ -25,6 +30,9 @@ const ExportApplication: React.FC<ExportApplicationProps> = ({ namespace, isDisa
2530
});
2631

2732
const showExportAppBtn = canExportApp && isExportAppAllowed && !isMobile;
33+
if (setIsExportAppEnabled) {
34+
setIsExportAppEnabled(showExportAppBtn);
35+
}
2836
const name = EXPORT_CR_NAME;
2937

3038
return showExportAppBtn ? (

frontend/packages/topology/src/components/page/TopologyDataRenderer.tsx

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as React from 'react';
22
import { observer } from '@patternfly/react-topology';
33
import { useTranslation } from 'react-i18next';
4-
import ResourceQuotaAlert from '@console/dev-console/src/components/resource-quota/ResourceQuotaAlert';
54
import { StatusBox } from '@console/internal/components/utils';
65
import { ModelContext, ExtensibleModel } from '../../data-transforms/ModelContext';
76
import { TopologyViewType } from '../../topology-types';
@@ -17,27 +16,24 @@ const TopologyDataRenderer: React.FC<TopologyDataRendererProps> = observer(
1716
const { namespace, model, loaded, loadError } = React.useContext<ExtensibleModel>(ModelContext);
1817

1918
return (
20-
<>
21-
<ResourceQuotaAlert namespace={namespace} />
22-
<StatusBox
23-
skeleton={
24-
viewType === TopologyViewType.list && (
25-
<div className="co-m-pane__body skeleton-overview">
26-
<div className="skeleton-overview--head" />
27-
<div className="skeleton-overview--tile" />
28-
<div className="skeleton-overview--tile" />
29-
<div className="skeleton-overview--tile" />
30-
</div>
31-
)
32-
}
33-
data={model}
34-
label={t('topology~Topology')}
35-
loaded={loaded}
36-
loadError={loadError}
37-
>
38-
<DroppableTopologyComponent viewType={viewType} model={model} namespace={namespace} />
39-
</StatusBox>
40-
</>
19+
<StatusBox
20+
skeleton={
21+
viewType === TopologyViewType.list && (
22+
<div className="co-m-pane__body skeleton-overview">
23+
<div className="skeleton-overview--head" />
24+
<div className="skeleton-overview--tile" />
25+
<div className="skeleton-overview--tile" />
26+
<div className="skeleton-overview--tile" />
27+
</div>
28+
)
29+
}
30+
data={model}
31+
label={t('topology~Topology')}
32+
loaded={loaded}
33+
loadError={loadError}
34+
>
35+
<DroppableTopologyComponent viewType={viewType} model={model} namespace={namespace} />
36+
</StatusBox>
4137
);
4238
},
4339
);

frontend/packages/topology/src/filters/TopologyFilterBar.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212
&__kiali-link {
1313
margin-left: auto;
1414
}
15+
16+
&__resource-quota-warning-block {
17+
margin-right: var(--pf-global--spacer--lg);
18+
}
1519
}

frontend/packages/topology/src/filters/TopologyFilterBar.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { requirementFromString } from '@console/internal/module/k8s/selector-req
2121
import { getActiveNamespace } from '@console/internal/reducers/ui';
2222
import { RootState } from '@console/internal/redux';
2323
import { useQueryParams } from '@console/shared';
24+
import { ResourceQuotaAlert } from '../../../dev-console/src/components/resource-quota/ResourceQuotaAlert';
2425
import ExportApplication from '../components/export-app/ExportApplication';
2526
import TopologyQuickSearchButton from '../components/quick-search/TopologyQuickSearchButton';
2627
import { TopologyViewType } from '../topology-types';
@@ -41,7 +42,6 @@ import FilterDropdown from './FilterDropdown';
4142
import { FilterContext } from './FilterProvider';
4243
import KindFilterDropdown from './KindFilterDropdown';
4344
import NameLabelFilterDropdown from './NameLabelFilterDropdown';
44-
4545
import './TopologyFilterBar.scss';
4646

4747
type StateProps = {
@@ -71,6 +71,7 @@ const TopologyFilterBar: React.FC<TopologyFilterBarProps> = ({
7171
const { t } = useTranslation();
7272
const { filters, setTopologyFilters: onFiltersChange } = React.useContext(FilterContext);
7373
const [labelFilterInput, setLabelFilterInput] = React.useState('');
74+
const [isExportAppEnabled, setIsExportAppEnabled] = React.useState(false);
7475
const [consoleLinks] = useK8sWatchResource<K8sResourceKind[]>({
7576
isList: true,
7677
kind: referenceForModel(ConsoleLinkModel),
@@ -198,12 +199,25 @@ const TopologyFilterBar: React.FC<TopologyFilterBarProps> = ({
198199
variant={ToolbarGroupVariant['button-group']}
199200
alignment={{ default: 'alignRight' }}
200201
>
202+
<ToolbarItem
203+
className={
204+
isExportAppEnabled || kialiLink
205+
? 'odc-topology-filter-bar__resource-quota-warning-block'
206+
: ''
207+
}
208+
>
209+
<ResourceQuotaAlert namespace={namespace} />
210+
</ToolbarItem>
201211
{kialiLink && (
202212
<ToolbarItem className="odc-topology-filter-bar__kiali-link1">
203213
<ExternalLink href={kialiLink} text={t('topology~Kiali')} />
204214
</ToolbarItem>
205215
)}
206-
<ExportApplication namespace={namespace} isDisabled={isDisabled} />
216+
<ExportApplication
217+
namespace={namespace}
218+
isDisabled={isDisabled}
219+
setIsExportAppEnabled={setIsExportAppEnabled}
220+
/>
207221
</ToolbarGroup>
208222
</ToolbarContent>
209223
</Toolbar>

0 commit comments

Comments
 (0)