diff --git a/awx/ui_next/src/components/PaginatedDataList/PaginatedDataList.jsx b/awx/ui_next/src/components/PaginatedDataList/PaginatedDataList.jsx
index 466b006ea2..48bc97bf73 100644
--- a/awx/ui_next/src/components/PaginatedDataList/PaginatedDataList.jsx
+++ b/awx/ui_next/src/components/PaginatedDataList/PaginatedDataList.jsx
@@ -40,13 +40,13 @@ class PaginatedDataList extends React.Component {
componentDidUpdate(prevProps) {
const { itemCount: prevItemCount } = prevProps;
- const { itemCount } = this.props
+ const { itemCount } = this.props;
if (prevItemCount !== itemCount) {
this.getCurrPage(itemCount);
}
}
- getSortOrder () {
+ getSortOrder() {
const { qsConfig, location } = this.props;
const queryParams = parseNamespacedQueryString(qsConfig, location.search);
if (queryParams.order_by && queryParams.order_by.startsWith('-')) {
@@ -55,20 +55,22 @@ class PaginatedDataList extends React.Component {
return [queryParams.order_by, 'ascending'];
}
- getCurrPage (itemCount) {
+ getCurrPage(itemCount) {
if (itemCount < 0) {
return;
}
const { qsConfig, location } = this.props;
- const queryParams = parseNamespacedQueryString(qsConfig, location.search);
- const maxPages = Math.ceil(itemCount / queryParams.page_size);
- const currPage = queryParams.page;
- if (currPage > maxPages) {
- this.pushHistoryState({ page: (currPage + (maxPages - currPage)) || 1 })
+ const { page_size, page: currPage } = parseNamespacedQueryString(
+ qsConfig,
+ location.search
+ );
+ const lastPage = Math.ceil(itemCount / page_size);
+ if (currPage > lastPage) {
+ this.pushHistoryState({ page: lastPage || 1 });
}
}
- handleSetPage (event, pageNumber) {
+ handleSetPage(event, pageNumber) {
this.pushHistoryState({ page: pageNumber });
}
diff --git a/awx/ui_next/src/components/PaginatedDataList/PaginatedDataList.test.jsx b/awx/ui_next/src/components/PaginatedDataList/PaginatedDataList.test.jsx
index 9ef2231484..1c9a22c374 100644
--- a/awx/ui_next/src/components/PaginatedDataList/PaginatedDataList.test.jsx
+++ b/awx/ui_next/src/components/PaginatedDataList/PaginatedDataList.test.jsx
@@ -132,7 +132,7 @@ describe('', () => {
integerFields: [],
};
const testParams = [5, 25, 0, -1]; // number of items
- const expected = [5, 5, 1, 1] // expected current page
+ const expected = [5, 5, 1, 1]; // expected current page
const history = createMemoryHistory({
initialEntries: ['/organizations/1/teams'],
});
@@ -146,13 +146,16 @@ describe('', () => {
order_by: 'name',
}}
qsConfig={customQSConfig}
- />, { context: { router: { history } } }
+ />,
+ { context: { router: { history } } }
);
testParams.forEach((param, i) => {
wrapper.setProps({ itemCount: param });
- expect(history.location.search).toEqual(`?${customQSConfig.namespace}.page=${expected[i]}`)
+ expect(history.location.search).toEqual(
+ `?${customQSConfig.namespace}.page=${expected[i]}`
+ );
wrapper.update();
- })
+ });
wrapper.unmount();
});
});
diff --git a/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx b/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx
index 3819601803..037241a156 100644
--- a/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx
+++ b/awx/ui_next/src/screens/Organization/OrganizationList/OrganizationList.jsx
@@ -75,12 +75,12 @@ class OrganizationsList extends Component {
this.setState({ deletionError: null });
}
- async handleOrgDelete () {
+ async handleOrgDelete() {
const { selected, itemCount } = this.state;
this.setState({ hasContentLoading: true });
try {
- await Promise.all(selected.map((org) => OrganizationsAPI.destroy(org.id)));
+ await Promise.all(selected.map(org => OrganizationsAPI.destroy(org.id)));
this.setState({ itemCount: itemCount - selected.length });
} catch (err) {
this.setState({ deletionError: err });
diff --git a/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx b/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx
index db8636fd96..93c3352790 100644
--- a/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx
+++ b/awx/ui_next/src/screens/Template/TemplateList/TemplateList.jsx
@@ -77,20 +77,22 @@ class TemplatesList extends Component {
}
}
- async handleTemplateDelete () {
+ async handleTemplateDelete() {
const { selected, itemCount } = this.state;
this.setState({ hasContentLoading: true });
try {
- await Promise.all(selected.map(({ type, id }) => {
- let deletePromise;
- if (type === 'job_template') {
- deletePromise = JobTemplatesAPI.destroy(id);
- } else if (type === 'workflow_job_template') {
- deletePromise = WorkflowJobTemplatesAPI.destroy(id);
- }
- return deletePromise;
- }));
+ await Promise.all(
+ selected.map(({ type, id }) => {
+ let deletePromise;
+ if (type === 'job_template') {
+ deletePromise = JobTemplatesAPI.destroy(id);
+ } else if (type === 'workflow_job_template') {
+ deletePromise = WorkflowJobTemplatesAPI.destroy(id);
+ }
+ return deletePromise;
+ })
+ );
this.setState({ itemCount: itemCount - selected.length });
} catch (err) {
this.setState({ deletionError: err });