Removes residual references to org from project list components. Assign IDs to project and jt related tabs after array has been finalized.

This commit is contained in:
mabashian 2019-10-04 11:04:56 -04:00
parent f502fbfad6
commit c9e889ca82
5 changed files with 25 additions and 22 deletions

View File

@ -18,7 +18,7 @@ import OrganizationListItem from './OrganizationListItem';
const QS_CONFIG = getQSConfig('organization', {
page: 1,
page_size: 5,
page_size: 20,
order_by: 'name',
});

View File

@ -127,31 +127,32 @@ class Project extends Component {
(me.is_system_auditor || isAuditorOfThisOrg || isAdminOfThisOrg);
const tabsArray = [
{ name: i18n._(t`Details`), link: `${match.url}/details`, id: 0 },
{ name: i18n._(t`Access`), link: `${match.url}/access`, id: 1 },
{ name: i18n._(t`Details`), link: `${match.url}/details` },
{ name: i18n._(t`Access`), link: `${match.url}/access` },
];
if (canSeeNotificationsTab) {
tabsArray.push({
name: i18n._(t`Notifications`),
link: `${match.url}/notifications`,
id: 2,
});
}
tabsArray.push(
{
name: i18n._(t`Job Templates`),
link: '/job_templates',
id: canSeeNotificationsTab ? 3 : 2,
link: `${match.url}/job_templates`,
},
{
name: i18n._(t`Schedules`),
link: '/schedules',
id: canSeeNotificationsTab ? 4 : 3,
link: `${match.url}/schedules`,
}
);
tabsArray.forEach((tab, n) => {
tab.id = n;
});
const CardHeader = styled(PFCardHeader)`
--pf-c-card--first-child--PaddingTop: 0;
--pf-c-card--child--PaddingLeft: 0;

View File

@ -18,7 +18,7 @@ import ProjectListItem from './ProjectListItem';
const QS_CONFIG = getQSConfig('project', {
page: 1,
page_size: 5,
page_size: 20,
order_by: 'name',
});
@ -38,7 +38,7 @@ class ProjectsList extends Component {
this.handleSelectAll = this.handleSelectAll.bind(this);
this.handleSelect = this.handleSelect.bind(this);
this.handleOrgDelete = this.handleOrgDelete.bind(this);
this.handleProjectDelete = this.handleProjectDelete.bind(this);
this.handleDeleteErrorClose = this.handleDeleteErrorClose.bind(this);
this.loadProjects = this.loadProjects.bind(this);
}
@ -75,12 +75,14 @@ class ProjectsList extends Component {
this.setState({ deletionError: null });
}
async handleOrgDelete() {
async handleProjectDelete() {
const { selected } = this.state;
this.setState({ hasContentLoading: true });
try {
await Promise.all(selected.map(org => ProjectsAPI.destroy(org.id)));
await Promise.all(
selected.map(project => ProjectsAPI.destroy(project.id))
);
} catch (err) {
this.setState({ deletionError: err });
} finally {
@ -150,7 +152,7 @@ class ProjectsList extends Component {
hasContentLoading={hasContentLoading}
items={projects}
itemCount={itemCount}
pluralizedItemName="Projects"
pluralizedItemName={i18n._(t`Projects`)}
qsConfig={QS_CONFIG}
toolbarColumns={[
{
@ -182,9 +184,9 @@ class ProjectsList extends Component {
additionalControls={[
<ToolbarDeleteButton
key="delete"
onDelete={this.handleOrgDelete}
onDelete={this.handleProjectDelete}
itemsToDelete={selected}
pluralizedItemName="Projects"
pluralizedItemName={i18n._(t`Projects`)}
/>,
canAdd ? (
<ToolbarAddButton key="add" linkTo={`${match.url}/add`} />

View File

@ -89,15 +89,14 @@ class Template extends Component {
const canSeeNotificationsTab = me.is_system_auditor || isNotifAdmin;
const tabsArray = [
{ name: i18n._(t`Details`), link: `${match.url}/details`, id: 0 },
{ name: i18n._(t`Access`), link: '/home', id: 1 },
{ name: i18n._(t`Details`), link: `${match.url}/details` },
{ name: i18n._(t`Access`), link: '/home' },
];
if (canSeeNotificationsTab) {
tabsArray.push({
name: i18n._(t`Notifications`),
link: `${match.url}/notifications`,
id: 2,
});
}
@ -105,20 +104,21 @@ class Template extends Component {
{
name: i18n._(t`Schedules`),
link: '/home',
id: canSeeNotificationsTab ? 3 : 2,
},
{
name: i18n._(t`Completed Jobs`),
link: '/home',
id: canSeeNotificationsTab ? 4 : 3,
},
{
name: i18n._(t`Survey`),
link: '/home',
id: canSeeNotificationsTab ? 5 : 4,
}
);
tabsArray.forEach((tab, n) => {
tab.id = n;
});
let cardHeader = hasContentLoading ? null : (
<CardHeader style={{ padding: 0 }}>
<RoutedTabs history={history} tabsArray={tabsArray} />

View File

@ -27,7 +27,7 @@ import TemplateListItem from './TemplateListItem';
// workflow_job_template so the params sent to the API match what the api expects.
const QS_CONFIG = getQSConfig('template', {
page: 1,
page_size: 5,
page_size: 20,
order_by: 'name',
type: 'job_template,workflow_job_template',
});