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', { const QS_CONFIG = getQSConfig('organization', {
page: 1, page: 1,
page_size: 5, page_size: 20,
order_by: 'name', order_by: 'name',
}); });

View File

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

View File

@@ -18,7 +18,7 @@ import ProjectListItem from './ProjectListItem';
const QS_CONFIG = getQSConfig('project', { const QS_CONFIG = getQSConfig('project', {
page: 1, page: 1,
page_size: 5, page_size: 20,
order_by: 'name', order_by: 'name',
}); });
@@ -38,7 +38,7 @@ class ProjectsList extends Component {
this.handleSelectAll = this.handleSelectAll.bind(this); this.handleSelectAll = this.handleSelectAll.bind(this);
this.handleSelect = this.handleSelect.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.handleDeleteErrorClose = this.handleDeleteErrorClose.bind(this);
this.loadProjects = this.loadProjects.bind(this); this.loadProjects = this.loadProjects.bind(this);
} }
@@ -75,12 +75,14 @@ class ProjectsList extends Component {
this.setState({ deletionError: null }); this.setState({ deletionError: null });
} }
async handleOrgDelete() { async handleProjectDelete() {
const { selected } = this.state; const { selected } = this.state;
this.setState({ hasContentLoading: true }); this.setState({ hasContentLoading: true });
try { try {
await Promise.all(selected.map(org => ProjectsAPI.destroy(org.id))); await Promise.all(
selected.map(project => ProjectsAPI.destroy(project.id))
);
} catch (err) { } catch (err) {
this.setState({ deletionError: err }); this.setState({ deletionError: err });
} finally { } finally {
@@ -150,7 +152,7 @@ class ProjectsList extends Component {
hasContentLoading={hasContentLoading} hasContentLoading={hasContentLoading}
items={projects} items={projects}
itemCount={itemCount} itemCount={itemCount}
pluralizedItemName="Projects" pluralizedItemName={i18n._(t`Projects`)}
qsConfig={QS_CONFIG} qsConfig={QS_CONFIG}
toolbarColumns={[ toolbarColumns={[
{ {
@@ -182,9 +184,9 @@ class ProjectsList extends Component {
additionalControls={[ additionalControls={[
<ToolbarDeleteButton <ToolbarDeleteButton
key="delete" key="delete"
onDelete={this.handleOrgDelete} onDelete={this.handleProjectDelete}
itemsToDelete={selected} itemsToDelete={selected}
pluralizedItemName="Projects" pluralizedItemName={i18n._(t`Projects`)}
/>, />,
canAdd ? ( canAdd ? (
<ToolbarAddButton key="add" linkTo={`${match.url}/add`} /> <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 canSeeNotificationsTab = me.is_system_auditor || isNotifAdmin;
const tabsArray = [ const tabsArray = [
{ name: i18n._(t`Details`), link: `${match.url}/details`, id: 0 }, { name: i18n._(t`Details`), link: `${match.url}/details` },
{ name: i18n._(t`Access`), link: '/home', id: 1 }, { name: i18n._(t`Access`), link: '/home' },
]; ];
if (canSeeNotificationsTab) { if (canSeeNotificationsTab) {
tabsArray.push({ tabsArray.push({
name: i18n._(t`Notifications`), name: i18n._(t`Notifications`),
link: `${match.url}/notifications`, link: `${match.url}/notifications`,
id: 2,
}); });
} }
@@ -105,20 +104,21 @@ class Template extends Component {
{ {
name: i18n._(t`Schedules`), name: i18n._(t`Schedules`),
link: '/home', link: '/home',
id: canSeeNotificationsTab ? 3 : 2,
}, },
{ {
name: i18n._(t`Completed Jobs`), name: i18n._(t`Completed Jobs`),
link: '/home', link: '/home',
id: canSeeNotificationsTab ? 4 : 3,
}, },
{ {
name: i18n._(t`Survey`), name: i18n._(t`Survey`),
link: '/home', link: '/home',
id: canSeeNotificationsTab ? 5 : 4,
} }
); );
tabsArray.forEach((tab, n) => {
tab.id = n;
});
let cardHeader = hasContentLoading ? null : ( let cardHeader = hasContentLoading ? null : (
<CardHeader style={{ padding: 0 }}> <CardHeader style={{ padding: 0 }}>
<RoutedTabs history={history} tabsArray={tabsArray} /> <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. // workflow_job_template so the params sent to the API match what the api expects.
const QS_CONFIG = getQSConfig('template', { const QS_CONFIG = getQSConfig('template', {
page: 1, page: 1,
page_size: 5, page_size: 20,
order_by: 'name', order_by: 'name',
type: 'job_template,workflow_job_template', type: 'job_template,workflow_job_template',
}); });