= (props) =
[kinds],
);
+ const appliedClusterQuotaReference = referenceForModel(AppliedClusterResourceQuotaModel);
+
return (
);
@@ -186,6 +207,6 @@ export const DefaultDetailsPage: React.FC;
};
-export type TableRowForKindProps = K8sResourceKind & { namespace?: string };
+export type TableRowForACRQProps = K8sResourceKind & { namespace?: string };
DefaultDetailsPage.displayName = 'DefaultDetailsPage';
diff --git a/frontend/public/components/resource-quota.jsx b/frontend/public/components/resource-quota.jsx
index 09bd1cfddabd..93c74197ff6e 100644
--- a/frontend/public/components/resource-quota.jsx
+++ b/frontend/public/components/resource-quota.jsx
@@ -12,7 +12,6 @@ import {
import { useTranslation } from 'react-i18next';
import { FLAGS, YellowExclamationTriangleIcon } from '@console/shared';
-import { LAST_NAMESPACE_NAME_LOCAL_STORAGE_KEY } from '@console/shared/src/constants';
import { DetailsPage, MultiListPage, Table, TableData } from './factory';
import {
Kebab,
@@ -51,12 +50,14 @@ const resourceQuotaReference = referenceForModel(ResourceQuotaModel);
const clusterQuotaReference = referenceForModel(ClusterResourceQuotaModel);
const appliedClusterQuotaReference = referenceForModel(AppliedClusterResourceQuotaModel);
-const quotaKind = (quota, canListClusterQuota) => {
+const quotaKind = (quota) => {
if (quota.metadata.namespace) {
return resourceQuotaReference;
}
- return canListClusterQuota ? clusterQuotaReference : appliedClusterQuotaReference;
+ return quota.kind === 'ClusterResourceQuota'
+ ? clusterQuotaReference
+ : appliedClusterQuotaReference;
};
const quotaActions = (quota) =>
@@ -70,12 +71,11 @@ export const getQuotaResourceTypes = (quota) => {
return _.keys(specHard).sort();
};
-const getResourceUsage = (quota, resourceType, isACRQ = false) => {
+const getResourceUsage = (quota, resourceType, namespace, isACRQ = false) => {
const isCluster = isClusterQuota(quota);
const statusPath = isCluster ? ['status', 'total', 'hard'] : ['status', 'hard'];
const specPath = isCluster ? ['spec', 'quota', 'hard'] : ['spec', 'hard'];
const usedPath = isCluster ? ['status', 'total', 'used'] : ['status', 'used'];
- let totalUsedPath;
let totalUsed;
let used;
@@ -84,11 +84,11 @@ const getResourceUsage = (quota, resourceType, isACRQ = false) => {
// "used" is the data for the current namespace and "totalUsed" is the cluster-scoped data
if (isACRQ) {
used = _.get(quota, ['status', 'namespaces']);
- const currentNamespace = sessionStorage.getItem(LAST_NAMESPACE_NAME_LOCAL_STORAGE_KEY);
- used = used.filter((ns) => ns.namespace === currentNamespace);
- used = _.get(used[0], ['status', 'used', resourceType]);
- totalUsedPath = ['status', 'total', 'used'];
- totalUsed = _.get(quota, [...totalUsedPath, resourceType]);
+ if (namespace !== undefined) {
+ used = used.filter((ns) => ns.namespace === namespace);
+ used = _.get(used[0], ['status', 'used', resourceType]);
+ }
+ totalUsed = _.get(quota, ['status', 'total', 'used', resourceType]);
} else {
used = _.get(quota, [...usedPath, resourceType]);
}
@@ -123,8 +123,18 @@ export const UsageIcon = ({ percent }) => {
return usageIcon;
};
-export const ResourceUsageRow = ({ quota, resourceType, isACRQ = false }) => {
- const { used, totalUsed, max, percent } = getResourceUsage(quota, resourceType, isACRQ);
+export const ResourceUsageRow = ({
+ quota,
+ resourceType,
+ namespace = undefined,
+ isACRQ = false,
+}) => {
+ const { used, totalUsed, max, percent } = getResourceUsage(
+ quota,
+ resourceType,
+ namespace,
+ isACRQ,
+ );
if (isACRQ) {
return (
@@ -299,13 +309,14 @@ export const hasComputeResources = (resourceTypes) => {
return _.intersection(resourceTypes, chartResourceTypes).length > 0;
};
-const Details_ = ({ obj: rq, flags }) => {
+const Details = ({ obj: rq, match }) => {
const { t } = useTranslation();
const resourceTypes = getQuotaResourceTypes(rq);
const showChartRow = hasComputeResources(resourceTypes);
const scopes = _.get(rq, ['spec', 'scopes']);
- const kind = quotaKind(rq, flags[FLAGS.CAN_LIST_CLUSTER_QUOTA]);
+ const kind = quotaKind(rq);
const isACRQ = kind === appliedClusterQuotaReference;
+ const namespace = match?.params?.ns;
let text;
switch (kind) {
case appliedClusterQuotaReference:
@@ -381,7 +392,13 @@ const Details_ = ({ obj: rq, flags }) => {
{resourceTypes.map((type) => (
-
+
))}
@@ -390,20 +407,16 @@ const Details_ = ({ obj: rq, flags }) => {
);
};
-const Details = connectToFlags(FLAGS.CAN_LIST_CLUSTER_QUOTA)(Details_);
-
-const ResourceQuotaTableRow_ = ({ obj: rq, flags, namespace }) => {
+const ResourceQuotaTableRow = ({ obj: rq, namespace }) => {
const { t } = useTranslation();
return (
<>
@@ -419,18 +432,12 @@ const ResourceQuotaTableRow_ = ({ obj: rq, flags, namespace }) => {
)}
-
+
>
);
};
-const ResourceQuotaTableRow = connectToFlags(FLAGS.CAN_LIST_CLUSTER_QUOTA)(ResourceQuotaTableRow_);
-
export const ResourceQuotasList = (props) => {
const { t } = useTranslation();
const ResourceQuotaTableHeader = () => {
@@ -475,78 +482,74 @@ export const quotaType = (quota) => {
// Split each resource quota into one row per subject
export const flatten = (resources) => _.flatMap(resources, (resource) => _.compact(resource.data));
-export const ResourceQuotasPage = connectToFlags(
- FLAGS.OPENSHIFT,
- FLAGS.CAN_LIST_CLUSTER_QUOTA,
-)(({ namespace, flags, mock, showTitle }) => {
- const { t } = useTranslation();
- const resources = [{ kind: 'ResourceQuota', namespaced: true }];
- let rowFilters = null;
+export const ResourceQuotasPage = connectToFlags(FLAGS.OPENSHIFT)(
+ ({ namespace, flags, mock, showTitle }) => {
+ const { t } = useTranslation();
+ const resources = [{ kind: 'ResourceQuota', namespaced: true }];
+ let rowFilters = null;
- if (flagPending(flags[FLAGS.OPENSHIFT]) || flagPending(flags[FLAGS.CAN_LIST_CLUSTER_QUOTA])) {
- return ;
- }
- if (flags[FLAGS.OPENSHIFT]) {
- if (flags[FLAGS.CAN_LIST_CLUSTER_QUOTA]) {
+ if (flagPending(flags[FLAGS.OPENSHIFT])) {
+ return ;
+ }
+ if (flags[FLAGS.OPENSHIFT]) {
resources.push({
kind: referenceForModel(ClusterResourceQuotaModel),
namespaced: false,
optional: true,
});
- } else {
resources.push({
kind: referenceForModel(AppliedClusterResourceQuotaModel),
namespaced: true,
namespace,
optional: true,
});
- }
- rowFilters = [
- {
- filterGroupName: t('public~Role'),
- type: 'role-kind',
- reducer: quotaType,
- items: [
- {
- id: 'cluster',
- title: t('public~Cluster-wide {{resource}}', {
- resource: t(ResourceQuotaModel.labelPluralKey),
- }),
- },
- {
- id: 'namespace',
- title: t('public~Namespace {{resource}}', {
- resource: t(ResourceQuotaModel.labelPluralKey),
- }),
- },
- ],
- },
- ];
- }
- const createNS = namespace || 'default';
- const accessReview = {
- model: ResourceQuotaModel,
- namespace: createNS,
- };
- return (
-
- );
-});
+ rowFilters = [
+ {
+ filterGroupName: t('public~Role'),
+ type: 'role-kind',
+ reducer: quotaType,
+ items: [
+ {
+ id: 'cluster',
+ title: t('public~Cluster-wide {{resource}}', {
+ resource: t(ResourceQuotaModel.labelPluralKey),
+ }),
+ },
+ {
+ id: 'namespace',
+ title: t('public~Namespace {{resource}}', {
+ resource: t(ResourceQuotaModel.labelPluralKey),
+ }),
+ },
+ ],
+ },
+ ];
+ }
+ const createNS = namespace || 'default';
+ const accessReview = {
+ model: ResourceQuotaModel,
+ namespace: createNS,
+ };
+ return (
+
+ );
+ },
+);
export const ResourceQuotasDetailsPage = (props) => {
return (