mirror of
https://github.com/ansible/awx.git
synced 2026-05-12 03:47:36 -02:30
remove unnecessary org rest calls for notifcation tabs on proj wfjt
This commit is contained in:
@@ -25,8 +25,6 @@ class Project extends Component {
|
|||||||
contentError: null,
|
contentError: null,
|
||||||
isInitialized: false,
|
isInitialized: false,
|
||||||
isNotifAdmin: false,
|
isNotifAdmin: false,
|
||||||
isAuditorOfThisOrg: false,
|
|
||||||
isAdminOfThisOrg: false,
|
|
||||||
};
|
};
|
||||||
this.loadProject = this.loadProject.bind(this);
|
this.loadProject = this.loadProject.bind(this);
|
||||||
this.loadProjectAndRoles = this.loadProjectAndRoles.bind(this);
|
this.loadProjectAndRoles = this.loadProjectAndRoles.bind(this);
|
||||||
@@ -65,22 +63,10 @@ class Project extends Component {
|
|||||||
role_level: 'notification_admin_role',
|
role_level: 'notification_admin_role',
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
const [auditorRes, adminRes] = await Promise.all([
|
|
||||||
OrganizationsAPI.read({
|
|
||||||
id: data.organization,
|
|
||||||
role_level: 'auditor_role',
|
|
||||||
}),
|
|
||||||
OrganizationsAPI.read({
|
|
||||||
id: data.organization,
|
|
||||||
role_level: 'admin_role',
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
setBreadcrumb(data);
|
setBreadcrumb(data);
|
||||||
this.setState({
|
this.setState({
|
||||||
project: data,
|
project: data,
|
||||||
isNotifAdmin: notifAdminRes.data.results.length > 0,
|
isNotifAdmin: notifAdminRes.data.results.length > 0,
|
||||||
isAuditorOfThisOrg: auditorRes.data.results.length > 0,
|
|
||||||
isAdminOfThisOrg: adminRes.data.results.length > 0,
|
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.setState({ contentError: err });
|
this.setState({ contentError: err });
|
||||||
@@ -124,18 +110,9 @@ class Project extends Component {
|
|||||||
hasContentLoading,
|
hasContentLoading,
|
||||||
isInitialized,
|
isInitialized,
|
||||||
isNotifAdmin,
|
isNotifAdmin,
|
||||||
isAuditorOfThisOrg,
|
|
||||||
isAdminOfThisOrg,
|
|
||||||
} = this.state;
|
} = this.state;
|
||||||
const canSeeNotificationsTab =
|
const canSeeNotificationsTab = me.is_system_auditor || isNotifAdmin;
|
||||||
me.is_superuser ||
|
const canToggleNotifications = isNotifAdmin;
|
||||||
me.is_system_auditor ||
|
|
||||||
isNotifAdmin ||
|
|
||||||
isAuditorOfThisOrg;
|
|
||||||
const canToggleNotifications =
|
|
||||||
me.is_superuser ||
|
|
||||||
(isNotifAdmin &&
|
|
||||||
(me.is_system_auditor || isAuditorOfThisOrg || isAdminOfThisOrg));
|
|
||||||
|
|
||||||
const tabsArray = [
|
const tabsArray = [
|
||||||
{ name: i18n._(t`Details`), link: `${match.url}/details` },
|
{ name: i18n._(t`Details`), link: `${match.url}/details` },
|
||||||
|
|||||||
@@ -33,8 +33,6 @@ class WorkflowJobTemplate extends Component {
|
|||||||
template: null,
|
template: null,
|
||||||
webhook_key: null,
|
webhook_key: null,
|
||||||
isNotifAdmin: false,
|
isNotifAdmin: false,
|
||||||
isAuditorOfThisOrg: false,
|
|
||||||
isAdminOfThisOrg: false,
|
|
||||||
};
|
};
|
||||||
this.loadTemplate = this.loadTemplate.bind(this);
|
this.loadTemplate = this.loadTemplate.bind(this);
|
||||||
this.loadSchedules = this.loadSchedules.bind(this);
|
this.loadSchedules = this.loadSchedules.bind(this);
|
||||||
@@ -77,27 +75,14 @@ class WorkflowJobTemplate extends Component {
|
|||||||
);
|
);
|
||||||
data.summary_fields.webhook_credential.kind = name;
|
data.summary_fields.webhook_credential.kind = name;
|
||||||
}
|
}
|
||||||
const [notifAdminRes, auditorRes, adminRes] = await Promise.all([
|
const notifAdminRes = await OrganizationsAPI.read({
|
||||||
OrganizationsAPI.read({
|
page_size: 1,
|
||||||
page_size: 1,
|
role_level: 'notification_admin_role',
|
||||||
role_level: 'notification_admin_role',
|
});
|
||||||
}),
|
|
||||||
OrganizationsAPI.read({
|
|
||||||
id: data.organization,
|
|
||||||
role_level: 'auditor_role',
|
|
||||||
}),
|
|
||||||
OrganizationsAPI.read({
|
|
||||||
id: data.organization,
|
|
||||||
role_level: 'admin_role',
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
this.setState({ template: data });
|
|
||||||
setBreadcrumb(data);
|
setBreadcrumb(data);
|
||||||
this.setState({
|
this.setState({
|
||||||
template: data,
|
template: data,
|
||||||
isNotifAdmin: notifAdminRes.data.results.length > 0,
|
isNotifAdmin: notifAdminRes.data.results.length > 0,
|
||||||
isAuditorOfThisOrg: auditorRes.data.results.length > 0,
|
|
||||||
isAdminOfThisOrg: adminRes.data.results.length > 0,
|
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.setState({ contentError: err });
|
this.setState({ contentError: err });
|
||||||
@@ -124,15 +109,10 @@ class WorkflowJobTemplate extends Component {
|
|||||||
template,
|
template,
|
||||||
webhook_key,
|
webhook_key,
|
||||||
isNotifAdmin,
|
isNotifAdmin,
|
||||||
isAuditorOfThisOrg,
|
|
||||||
isAdminOfThisOrg,
|
|
||||||
} = this.state;
|
} = this.state;
|
||||||
|
|
||||||
const canSeeNotificationsTab =
|
const canSeeNotificationsTab = me.is_system_auditor || isNotifAdmin;
|
||||||
me.is_system_auditor || isNotifAdmin || isAuditorOfThisOrg;
|
const canToggleNotifications = isNotifAdmin;
|
||||||
const canToggleNotifications =
|
|
||||||
isNotifAdmin &&
|
|
||||||
(me.is_system_auditor || isAuditorOfThisOrg || isAdminOfThisOrg);
|
|
||||||
|
|
||||||
const tabsArray = [
|
const tabsArray = [
|
||||||
{ name: i18n._(t`Details`), link: `${match.url}/details` },
|
{ name: i18n._(t`Details`), link: `${match.url}/details` },
|
||||||
|
|||||||
Reference in New Issue
Block a user