-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CONSOLE-922: Support AppliedClusterResourceQuota for normal users
Added support for list and details pages, as well as other pages like Search. We now also display ACRQs in the ResourceQuotas table for projects. Fixes https://issues.redhat.com/browse/CONSOLE-922
- Loading branch information
1 parent
54f679a
commit 84ec99b
Showing
15 changed files
with
1,032 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...e-shared/src/components/dashboard/resource-quota-card/AppliedClusterResourceQuotaItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import * as React from 'react'; | ||
import { | ||
getQuotaResourceTypes, | ||
QuotaScopesInline, | ||
QuotaGaugeCharts, | ||
} from '@console/internal/components/resource-quota'; | ||
import { ResourceLink } from '@console/internal/components/utils/resource-link'; | ||
import { AppliedClusterResourceQuotaModel } from '@console/internal/models'; | ||
import { referenceForModel, AppliedClusterResourceQuotaKind } from '@console/internal/module/k8s'; | ||
|
||
import './resource-quota-card.scss'; | ||
|
||
const AppliedClusterResourceQuotaItem: React.FC<AppliedClusterResourceQuotaItemProps> = ({ | ||
resourceQuota, | ||
namespace, | ||
}) => { | ||
const resourceTypes = getQuotaResourceTypes(resourceQuota); | ||
const scopes = resourceQuota?.spec?.quota?.scopes; | ||
return ( | ||
<> | ||
<div> | ||
<ResourceLink | ||
kind={referenceForModel(AppliedClusterResourceQuotaModel)} | ||
name={resourceQuota.metadata.name} | ||
className="co-resource-item--truncate co-resource-quota-card__item-title" | ||
namespace={namespace} | ||
inline | ||
/> | ||
{scopes && <QuotaScopesInline scopes={scopes} />} | ||
</div> | ||
<QuotaGaugeCharts | ||
quota={resourceQuota} | ||
resourceTypes={resourceTypes} | ||
namespace={namespace} | ||
chartClassName="co-resource-quota-card__chart" | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default AppliedClusterResourceQuotaItem; | ||
|
||
type AppliedClusterResourceQuotaItemProps = { | ||
resourceQuota: AppliedClusterResourceQuotaKind; | ||
namespace: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
frontend/packages/integration-tests-cypress/tests/crud/quotas.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import { safeLoad, safeDump } from 'js-yaml'; | ||
import * as _ from 'lodash'; | ||
import { checkErrors, testName } from '../../support'; | ||
import { projectDropdown } from '../../views/common'; | ||
import { detailsPage } from '../../views/details-page'; | ||
import { errorMessage } from '../../views/form'; | ||
import { listPage } from '../../views/list-page'; | ||
import { modal } from '../../views/modal'; | ||
import { nav } from '../../views/nav'; | ||
import * as yamlEditor from '../../views/yaml-editor'; | ||
|
||
const quotaName = 'example-resource-quota'; | ||
const clusterQuotaName = 'example-cluster-resource-quota'; | ||
const allProjectsDropdownLabel = 'All Projects'; | ||
|
||
const createExampleQuotas = () => { | ||
cy.log('create quota instance'); | ||
nav.sidenav.clickNavLink(['Administration', 'ResourceQuotas']); | ||
projectDropdown.selectProject(testName); | ||
projectDropdown.shouldContain(testName); | ||
listPage.clickCreateYAMLbutton(); | ||
// sidebar needs to be fully loaded, else it sometimes overlays the Create button | ||
cy.byTestID('resource-sidebar').should('exist'); | ||
yamlEditor.isLoaded(); | ||
let newContent; | ||
yamlEditor.getEditorContent().then((content) => { | ||
newContent = _.defaultsDeep({}, { metadata: { name: quotaName } }, safeLoad(content)); | ||
yamlEditor.setEditorContent(safeDump(newContent)).then(() => { | ||
yamlEditor.clickSaveCreateButton(); | ||
cy.get(errorMessage).should('not.exist'); | ||
}); | ||
}); | ||
detailsPage.breadcrumb(0).click(); | ||
|
||
cy.log('create cluster quota instance'); | ||
listPage.clickCreateYAMLbutton(); | ||
cy.byTestID('resource-sidebar').should('exist'); | ||
yamlEditor.isLoaded(); | ||
yamlEditor.getEditorContent().then((content) => { | ||
newContent = _.defaultsDeep( | ||
{}, | ||
{ | ||
kind: 'ClusterResourceQuota', | ||
apiVersion: 'quota.openshift.io/v1', | ||
metadata: { name: clusterQuotaName }, | ||
spec: { | ||
quota: { | ||
hard: { | ||
pods: '10', | ||
secrets: '10', | ||
}, | ||
}, | ||
selector: { | ||
labels: { | ||
matchLabels: { | ||
'kubernetes.io/metadata.name': testName, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
safeLoad(content), | ||
); | ||
yamlEditor.setEditorContent(safeDump(newContent)).then(() => { | ||
yamlEditor.clickSaveCreateButton(); | ||
cy.get(errorMessage).should('not.exist'); | ||
}); | ||
}); | ||
}; | ||
|
||
const deleteClusterExamples = () => { | ||
cy.log('delete ClusterResourceQuota instance'); | ||
projectDropdown.selectProject(allProjectsDropdownLabel); | ||
nav.sidenav.clickNavLink(['Administration', 'ResourceQuotas']); | ||
listPage.rows.shouldBeLoaded(); | ||
listPage.filter.byName(clusterQuotaName); | ||
listPage.rows.clickRowByName(clusterQuotaName); | ||
detailsPage.isLoaded(); | ||
detailsPage.clickPageActionFromDropdown('Delete ClusterResourceQuota'); | ||
modal.shouldBeOpened(); | ||
modal.submit(); | ||
modal.shouldBeClosed(); | ||
detailsPage.isLoaded(); | ||
}; | ||
|
||
describe('Quotas', () => { | ||
before(() => { | ||
cy.login(); | ||
cy.createProject(testName); | ||
createExampleQuotas(); | ||
}); | ||
|
||
afterEach(() => { | ||
checkErrors(); | ||
}); | ||
|
||
after(() => { | ||
deleteClusterExamples(); | ||
cy.deleteProject(testName); | ||
cy.logout(); | ||
}); | ||
|
||
it(`'All Projects' shows ResourceQuotas`, () => { | ||
nav.sidenav.clickNavLink(['Administration', 'ResourceQuotas']); | ||
projectDropdown.selectProject(allProjectsDropdownLabel); | ||
listPage.rows.shouldBeLoaded(); | ||
listPage.filter.byName(quotaName); | ||
listPage.rows.shouldExist(quotaName); | ||
}); | ||
|
||
it(`'All Projects' shows ClusterResourceQuotas`, () => { | ||
nav.sidenav.clickNavLink(['Administration', 'ResourceQuotas']); | ||
projectDropdown.selectProject(allProjectsDropdownLabel); | ||
listPage.rows.shouldBeLoaded(); | ||
listPage.filter.byName(clusterQuotaName); | ||
listPage.rows.shouldExist(clusterQuotaName); | ||
listPage.rows.clickRowByName(clusterQuotaName); | ||
detailsPage.isLoaded(); | ||
detailsPage.breadcrumb(0).contains('ClusterResourceQuota'); | ||
}); | ||
|
||
it(`Test namespace shows ResourceQuotas`, () => { | ||
nav.sidenav.clickNavLink(['Administration', 'ResourceQuotas']); | ||
projectDropdown.selectProject(testName); | ||
listPage.rows.shouldBeLoaded(); | ||
listPage.filter.byName(quotaName); | ||
listPage.rows.shouldExist(quotaName); | ||
}); | ||
|
||
it(`Test namespace shows AppliedClusterResourceQuotas`, () => { | ||
nav.sidenav.clickNavLink(['Administration', 'ResourceQuotas']); | ||
projectDropdown.selectProject(testName); | ||
listPage.rows.shouldBeLoaded(); | ||
listPage.filter.byName(clusterQuotaName); | ||
listPage.rows.shouldExist(clusterQuotaName); | ||
listPage.rows.clickRowByName(clusterQuotaName); | ||
detailsPage.isLoaded(); | ||
detailsPage.breadcrumb(0).contains('AppliedClusterResourceQuota'); | ||
}); | ||
}); |
Oops, something went wrong.