mirror of
https://github.com/ansible/awx.git
synced 2026-05-23 16:47:45 -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 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 { withI18n } from '@lingui/react';
|
||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Card, PageSection } from '@patternfly/react-core';
|
import { Card, PageSection } from '@patternfly/react-core';
|
||||||
@@ -13,7 +13,12 @@ import PaginatedDataList, {
|
|||||||
ToolbarAddButton,
|
ToolbarAddButton,
|
||||||
ToolbarDeleteButton,
|
ToolbarDeleteButton,
|
||||||
} from '@components/PaginatedDataList';
|
} from '@components/PaginatedDataList';
|
||||||
import { getQSConfig, parseQueryString } from '@util/qs';
|
import {
|
||||||
|
getQSConfig,
|
||||||
|
parseQueryString,
|
||||||
|
removeParams,
|
||||||
|
encodeNonDefaultQueryString,
|
||||||
|
} from '@util/qs';
|
||||||
|
|
||||||
import OrganizationListItem from './OrganizationListItem';
|
import OrganizationListItem from './OrganizationListItem';
|
||||||
|
|
||||||
@@ -25,6 +30,7 @@ const QS_CONFIG = getQSConfig('organization', {
|
|||||||
|
|
||||||
function OrganizationsList({ i18n }) {
|
function OrganizationsList({ i18n }) {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
const history = useHistory();
|
||||||
const match = useRouteMatch();
|
const match = useRouteMatch();
|
||||||
|
|
||||||
const [selected, setSelected] = useState([]);
|
const [selected, setSelected] = useState([]);
|
||||||
@@ -81,6 +87,16 @@ function OrganizationsList({ i18n }) {
|
|||||||
|
|
||||||
const handleOrgDelete = async () => {
|
const handleOrgDelete = async () => {
|
||||||
await deleteOrganizations();
|
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();
|
await fetchOrganizations();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,6 @@ export { addDefaultsToObject as _addDefaultsToObject };
|
|||||||
/**
|
/**
|
||||||
* Convert query param object to url query string
|
* Convert query param object to url query string
|
||||||
* Used to encode params for interacting with the api
|
* Used to encode params for interacting with the api
|
||||||
* @param {object} qs config object for namespacing params, filtering defaults
|
|
||||||
* @param {object} query param object
|
* @param {object} query param object
|
||||||
* @return {string} url query string
|
* @return {string} url query string
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user