mirror of
https://github.com/ansible/awx.git
synced 2026-03-03 09:48:51 -03:30
Show HostMetrics only for specific subscription
SUBSCRIPTION_USAGE_MODEL: 'unique_managed_hosts' Fixes https://issues.redhat.com/browse/AA-1613
This commit is contained in:
committed by
John Westcott IV
parent
c20e8eb712
commit
c117ca66d5
@@ -18,6 +18,10 @@ class Settings extends Base {
|
|||||||
return this.http.get(`${this.baseUrl}all/`);
|
return this.http.get(`${this.baseUrl}all/`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readSystem() {
|
||||||
|
return this.http.get(`${this.baseUrl}system/`);
|
||||||
|
}
|
||||||
|
|
||||||
updateCategory(category, data) {
|
updateCategory(category, data) {
|
||||||
return this.http.patch(`${this.baseUrl}${category}/`, data);
|
return this.http.patch(`${this.baseUrl}${category}/`, data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import useRequest, { useDismissableError } from 'hooks/useRequest';
|
|||||||
import AlertModal from 'components/AlertModal';
|
import AlertModal from 'components/AlertModal';
|
||||||
import ErrorDetail from 'components/ErrorDetail';
|
import ErrorDetail from 'components/ErrorDetail';
|
||||||
import { useSession } from './Session';
|
import { useSession } from './Session';
|
||||||
|
import { SettingsAPI } from '../api';
|
||||||
|
|
||||||
// eslint-disable-next-line import/prefer-default-export
|
// eslint-disable-next-line import/prefer-default-export
|
||||||
export const ConfigContext = React.createContext({});
|
export const ConfigContext = React.createContext({});
|
||||||
@@ -40,6 +41,11 @@ export const ConfigProvider = ({ children }) => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
] = await Promise.all([ConfigAPI.read(), MeAPI.read()]);
|
] = await Promise.all([ConfigAPI.read(), MeAPI.read()]);
|
||||||
|
let systemConfig = {};
|
||||||
|
if (me?.is_superuser || me?.is_system_auditor) {
|
||||||
|
const { data: systemConfigResults } = await SettingsAPI.readSystem();
|
||||||
|
systemConfig = systemConfigResults;
|
||||||
|
}
|
||||||
|
|
||||||
const [
|
const [
|
||||||
{
|
{
|
||||||
@@ -62,10 +68,21 @@ export const ConfigProvider = ({ children }) => {
|
|||||||
role_level: 'execution_environment_admin_role',
|
role_level: 'execution_environment_admin_role',
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
return {
|
||||||
return { ...data, me, adminOrgCount, notifAdminCount, execEnvAdminCount };
|
...data,
|
||||||
|
me,
|
||||||
|
adminOrgCount,
|
||||||
|
notifAdminCount,
|
||||||
|
execEnvAdminCount,
|
||||||
|
systemConfig,
|
||||||
|
};
|
||||||
}, []),
|
}, []),
|
||||||
{ adminOrgCount: 0, notifAdminCount: 0, execEnvAdminCount: 0 }
|
{
|
||||||
|
adminOrgCount: 0,
|
||||||
|
notifAdminCount: 0,
|
||||||
|
execEnvAdminCount: 0,
|
||||||
|
systemConfig: {},
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const { error, dismissError } = useDismissableError(configError);
|
const { error, dismissError } = useDismissableError(configError);
|
||||||
@@ -112,6 +129,7 @@ export const useUserProfile = () => {
|
|||||||
isOrgAdmin: config.adminOrgCount,
|
isOrgAdmin: config.adminOrgCount,
|
||||||
isNotificationAdmin: config.notifAdminCount,
|
isNotificationAdmin: config.notifAdminCount,
|
||||||
isExecEnvAdmin: config.execEnvAdminCount,
|
isExecEnvAdmin: config.execEnvAdminCount,
|
||||||
|
systemConfig: config.systemConfig,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,12 @@ function getRouteConfig(userProfile = {}) {
|
|||||||
const deleteRouteGroup = (name) => {
|
const deleteRouteGroup = (name) => {
|
||||||
routeConfig = routeConfig.filter(({ groupId }) => !groupId.includes(name));
|
routeConfig = routeConfig.filter(({ groupId }) => !groupId.includes(name));
|
||||||
};
|
};
|
||||||
|
if (
|
||||||
|
userProfile?.systemConfig?.SUBSCRIPTION_USAGE_MODEL !==
|
||||||
|
'unique_managed_hosts'
|
||||||
|
) {
|
||||||
|
deleteRoute('host_metrics');
|
||||||
|
}
|
||||||
if (userProfile?.isSuperUser || userProfile?.isSystemAuditor)
|
if (userProfile?.isSuperUser || userProfile?.isSystemAuditor)
|
||||||
return routeConfig;
|
return routeConfig;
|
||||||
deleteRoute('host_metrics');
|
deleteRoute('host_metrics');
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const userProfile = {
|
|||||||
isOrgAdmin: false,
|
isOrgAdmin: false,
|
||||||
isNotificationAdmin: false,
|
isNotificationAdmin: false,
|
||||||
isExecEnvAdmin: false,
|
isExecEnvAdmin: false,
|
||||||
|
systemConfig: { SUBSCRIPTION_USAGE_MODEL: 'unique_managed_hosts' },
|
||||||
};
|
};
|
||||||
|
|
||||||
const filterPaths = (sidebar) => {
|
const filterPaths = (sidebar) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user