mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -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:
parent
c20e8eb712
commit
c117ca66d5
@ -18,6 +18,10 @@ class Settings extends Base {
|
||||
return this.http.get(`${this.baseUrl}all/`);
|
||||
}
|
||||
|
||||
readSystem() {
|
||||
return this.http.get(`${this.baseUrl}system/`);
|
||||
}
|
||||
|
||||
updateCategory(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 ErrorDetail from 'components/ErrorDetail';
|
||||
import { useSession } from './Session';
|
||||
import { SettingsAPI } from '../api';
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const ConfigContext = React.createContext({});
|
||||
@ -40,6 +41,11 @@ export const ConfigProvider = ({ children }) => {
|
||||
},
|
||||
},
|
||||
] = 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 [
|
||||
{
|
||||
@ -62,10 +68,21 @@ export const ConfigProvider = ({ children }) => {
|
||||
role_level: 'execution_environment_admin_role',
|
||||
}),
|
||||
]);
|
||||
|
||||
return { ...data, me, adminOrgCount, notifAdminCount, execEnvAdminCount };
|
||||
return {
|
||||
...data,
|
||||
me,
|
||||
adminOrgCount,
|
||||
notifAdminCount,
|
||||
execEnvAdminCount,
|
||||
systemConfig,
|
||||
};
|
||||
}, []),
|
||||
{ adminOrgCount: 0, notifAdminCount: 0, execEnvAdminCount: 0 }
|
||||
{
|
||||
adminOrgCount: 0,
|
||||
notifAdminCount: 0,
|
||||
execEnvAdminCount: 0,
|
||||
systemConfig: {},
|
||||
}
|
||||
);
|
||||
|
||||
const { error, dismissError } = useDismissableError(configError);
|
||||
@ -112,6 +129,7 @@ export const useUserProfile = () => {
|
||||
isOrgAdmin: config.adminOrgCount,
|
||||
isNotificationAdmin: config.notifAdminCount,
|
||||
isExecEnvAdmin: config.execEnvAdminCount,
|
||||
systemConfig: config.systemConfig,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@ -184,7 +184,12 @@ function getRouteConfig(userProfile = {}) {
|
||||
const deleteRouteGroup = (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)
|
||||
return routeConfig;
|
||||
deleteRoute('host_metrics');
|
||||
|
||||
@ -7,6 +7,7 @@ const userProfile = {
|
||||
isOrgAdmin: false,
|
||||
isNotificationAdmin: false,
|
||||
isExecEnvAdmin: false,
|
||||
systemConfig: { SUBSCRIPTION_USAGE_MODEL: 'unique_managed_hosts' },
|
||||
};
|
||||
|
||||
const filterPaths = (sidebar) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user