mirror of
https://github.com/ansible/awx.git
synced 2026-03-13 15:09:32 -02:30
fix org list page on delete
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect, useCallback } from 'react';
|
||||
import { useLocation, useRouteMatch } from 'react-router-dom';
|
||||
import { useLocation, useHistory, useRouteMatch } from 'react-router-dom';
|
||||
import { withI18n } from '@lingui/react';
|
||||
import { t } from '@lingui/macro';
|
||||
import { Card, PageSection } from '@patternfly/react-core';
|
||||
@@ -13,7 +13,12 @@ import PaginatedDataList, {
|
||||
ToolbarAddButton,
|
||||
ToolbarDeleteButton,
|
||||
} from '@components/PaginatedDataList';
|
||||
import { getQSConfig, parseQueryString } from '@util/qs';
|
||||
import {
|
||||
getQSConfig,
|
||||
parseQueryString,
|
||||
removeParams,
|
||||
encodeNonDefaultQueryString,
|
||||
} from '@util/qs';
|
||||
|
||||
import OrganizationListItem from './OrganizationListItem';
|
||||
|
||||
@@ -25,6 +30,7 @@ const QS_CONFIG = getQSConfig('organization', {
|
||||
|
||||
function OrganizationsList({ i18n }) {
|
||||
const location = useLocation();
|
||||
const history = useHistory();
|
||||
const match = useRouteMatch();
|
||||
|
||||
const [selected, setSelected] = useState([]);
|
||||
@@ -81,6 +87,16 @@ function OrganizationsList({ i18n }) {
|
||||
|
||||
const handleOrgDelete = async () => {
|
||||
await deleteOrganizations();
|
||||
const params = parseQueryString(QS_CONFIG, location.search);
|
||||
if (params.page > 1 && selected.length === organizations.length) {
|
||||
const newParams = removeParams(QS_CONFIG, params, { page: params.page });
|
||||
history.push(
|
||||
`${location.pathname}?${encodeNonDefaultQueryString(
|
||||
QS_CONFIG,
|
||||
newParams
|
||||
)}`
|
||||
);
|
||||
}
|
||||
await fetchOrganizations();
|
||||
};
|
||||
|
||||
|
||||
@@ -90,7 +90,6 @@ export { addDefaultsToObject as _addDefaultsToObject };
|
||||
/**
|
||||
* Convert query param object to url query string
|
||||
* Used to encode params for interacting with the api
|
||||
* @param {object} qs config object for namespacing params, filtering defaults
|
||||
* @param {object} query param object
|
||||
* @return {string} url query string
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user