Skip to content

Commit

Permalink
Merge 1b1ddb4 into 6bf069b
Browse files Browse the repository at this point in the history
  • Loading branch information
fhlavac authored Jun 8, 2023
2 parents 6bf069b + 1b1ddb4 commit fe3c1a5
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 26 deletions.
5 changes: 2 additions & 3 deletions src/smart-components/group/edit-group-modal.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState } from 'react';
import { useDispatch } from 'react-redux';
import { useIntl } from 'react-intl';
import { useParams } from 'react-router-dom';
import { useParams, useNavigate } from 'react-router-dom';
import PropTypes from 'prop-types';
import { Skeleton } from '@patternfly/react-core';
import { addNotification } from '@redhat-cloud-services/frontend-components-notifications/';
Expand All @@ -10,7 +10,6 @@ import validatorTypes from '@data-driven-forms/react-form-renderer/validator-typ
import componentMapper from '@data-driven-forms/pf4-component-mapper/component-mapper';
import ModalFormTemplate from '../common/ModalFormTemplate';
import FormRenderer from '../common/form-renderer';
import useAppNavigate from '../../hooks/useAppNavigate';
import { fetchGroup, updateGroup } from '../../redux/actions/group-actions';
import { debouncedAsyncValidator } from './validators';
import messages from '../../Messages';
Expand All @@ -20,7 +19,7 @@ const EditGroupModal = ({ postMethod, pagination, filters, cancelRoute, submitRo
const intl = useIntl();
const [selectedGroup, setSelectedGroup] = useState(undefined);

const navigate = useAppNavigate();
const navigate = useNavigate();
const { groupId } = useParams();

const setGroupData = (groupData) => {
Expand Down
12 changes: 6 additions & 6 deletions src/smart-components/group/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ const Group = ({ onDelete }) => {
element={
<RemoveGroup
postMethod={() => dispatch(fetchGroups({ ...pagination, offset: 0, filters, usesMetaInURL: true }))}
cancelRoute={pathnames['group-detail-roles'].link.replace(':groupId', groupId)}
submitRoute={getBackRoute(pathnames.groups.link, { ...pagination, offset: 0 }, filters)}
cancelRoute={mergeToBasename(pathnames['group-detail-roles'].link.replace(':groupId', groupId))}
submitRoute={getBackRoute(mergeToBasename(pathnames.groups.link), { ...pagination, offset: 0 }, filters)}
isModalOpen
groupsUuid={[group]}
/>
Expand All @@ -261,7 +261,7 @@ const Group = ({ onDelete }) => {
element={
<EditGroup
group={group}
cancelRoute={pathnames['group-detail-roles'].link.replace(':groupId', groupId)}
cancelRoute={mergeToBasename(pathnames['group-detail-roles'].link.replace(':groupId', groupId))}
postMethod={() => dispatch(fetchGroup(fetchId))}
/>
}
Expand All @@ -273,8 +273,8 @@ const Group = ({ onDelete }) => {
element={
<RemoveGroup
postMethod={() => dispatch(fetchGroups({ ...pagination, offset: 0, filters, usesMetaInURL: true }))}
cancelRoute={pathnames['group-detail-members'].link.replace(':groupId', groupId)}
submitRoute={getBackRoute(pathnames.groups.link, { ...pagination, offset: 0 }, filters)}
cancelRoute={mergeToBasename(pathnames['group-detail-members'].link.replace(':groupId', groupId))}
submitRoute={getBackRoute(mergeToBasename(pathnames.groups.link), { ...pagination, offset: 0 }, filters)}
isModalOpen
groupsUuid={[group]}
/>
Expand All @@ -285,7 +285,7 @@ const Group = ({ onDelete }) => {
element={
<EditGroup
group={group}
cancelRoute={pathnames['group-detail-members'].link.replace(':groupId', groupId)}
cancelRoute={mergeToBasename(pathnames['group-detail-members'].link.replace(':groupId', groupId))}
postMethod={() => dispatch(fetchGroup(fetchId))}
/>
}
Expand Down
2 changes: 1 addition & 1 deletion src/smart-components/group/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const Groups = () => {
props: {
isDisabled: !(selectedRows.length === 1),
},
onClick: () => navigate(mergeToBasename(pathnames['edit-group'].link)).replace(':groupId', selectedRows[0].uuid),
onClick: () => navigate(mergeToBasename(pathnames['edit-group'].link.replace(':groupId', selectedRows[0].uuid))),
},
{
label: intl.formatMessage(messages.delete),
Expand Down
4 changes: 2 additions & 2 deletions src/smart-components/group/remove-group-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { FormattedMessage, useIntl } from 'react-intl';
import { shallowEqual, useDispatch, useSelector } from 'react-redux';
import { Button, Checkbox, Modal, ModalVariant, Text, TextContent } from '@patternfly/react-core';
import { ExclamationTriangleIcon } from '@patternfly/react-icons';
import { useNavigate } from 'react-router-dom';
import { fetchGroup, removeGroups } from '../../redux/actions/group-actions';
import { FormItemLoader } from '../../presentational-components/shared/loader-placeholders';
import pathnames from '../../utilities/pathnames';
import useAppNavigate from '../../hooks/useAppNavigate';
import messages from '../../Messages';
import './remove-group-modal.scss';

Expand All @@ -27,7 +27,7 @@ const RemoveGroupModal = ({ groupsUuid, isModalOpen, postMethod, pagination, fil
}
}, []);

const navigate = useAppNavigate();
const navigate = useNavigate();

const [checked, setChecked] = useState(false);

Expand Down
7 changes: 3 additions & 4 deletions src/smart-components/role/edit-role-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import componentTypes from '@data-driven-forms/react-form-renderer/component-typ
import validatorTypes from '@data-driven-forms/react-form-renderer/validator-types';
import { addNotification } from '@redhat-cloud-services/frontend-components-notifications/';
import { useIntl } from 'react-intl';
import { useParams, useNavigate } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import ModalFormTemplate from '../common/ModalFormTemplate';
import FormRenderer from '../common/form-renderer';
import useAppNavigate from '../../hooks/useAppNavigate';
import useIsMounted from '../../hooks/useIsMounted';
import { useParams } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import { roleSelector } from './role-selectors';
import { fetchRole, fetchRoles } from '../../helpers/role/role-helper';
import asyncDebounce from '../../utilities/async-debounce';
Expand All @@ -19,7 +18,7 @@ import messages from '../../Messages';
const EditRoleModal = ({ cancelRoute, submitRoute = cancelRoute, afterSubmit }) => {
const intl = useIntl();
const isMounted = useIsMounted();
const navigate = useAppNavigate();
const navigate = useNavigate();
const dispatch = useDispatch();

const { roleId } = useParams();
Expand Down
5 changes: 2 additions & 3 deletions src/smart-components/role/remove-role-modal.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { useDispatch, useSelector } from 'react-redux';
import { useParams } from 'react-router-dom';
import { useParams, useNavigate } from 'react-router-dom';
import { ExclamationTriangleIcon } from '@patternfly/react-icons';
import { Button, Checkbox, Modal, Text, TextContent, TextVariants, Split, SplitItem } from '@patternfly/react-core';
import { addNotification } from '@redhat-cloud-services/frontend-components-notifications/redux';
import useAppNavigate from '../../hooks/useAppNavigate';
import { removeRole } from '../../redux/actions/role-actions';
import { fetchRole } from '../../helpers/role/role-helper';
import { roleNameSelector } from './role-selectors';
Expand All @@ -26,7 +25,7 @@ const RemoveRoleModal = ({ cancelRoute, submitRoute = cancelRoute, afterSubmit }
const [isDisabled, setIsDisabled] = useState(true);
const [internalRoleName, setInternalRoleName] = useState(roleName);
const dispatch = useDispatch();
const navigate = useAppNavigate();
const navigate = useNavigate();

useEffect(() => {
if (roles && roleName) {
Expand Down
10 changes: 5 additions & 5 deletions src/smart-components/role/role.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import useAppNavigate from '../../hooks/useAppNavigate';
import { fetchRole, fetchRolesWithPolicies } from '../../redux/actions/role-actions';
import { TopToolbar } from '../../presentational-components/shared/top-toolbar';
import { ListLoader } from '../../presentational-components/shared/loader-placeholders';
import Permissions from './role-permissions';
import { fetchGroup, fetchRolesForGroup, fetchSystemGroup } from '../../redux/actions/group-actions';
import { ToolbarTitlePlaceholder } from '../../presentational-components/shared/loader-placeholders';
import Permissions from './role-permissions';
import RemoveRoleModal from './remove-role-modal';
import EditRoleModal from './edit-role-modal';
import EmptyWithAction from '../../presentational-components/shared/empty-state';
Expand Down Expand Up @@ -135,7 +135,7 @@ const Role = ({ onDelete }) => {
/>,
<DropdownItem
component={
<AppLink onClick={onDelete} to={pathnames['role-detail-remove'].path.replace(':roleId', roleId)}>
<AppLink onClick={onDelete} to={pathnames['role-detail-remove'].link.replace(':roleId', roleId)}>
{intl.formatMessage(messages.delete)}
</AppLink>
}
Expand Down Expand Up @@ -183,8 +183,8 @@ const Role = ({ onDelete }) => {
afterSubmit={() => {
dispatch(fetchRolesWithPolicies({ ...rolesPagination, offset: 0, filters: rolesFilters, usesMetaInURL: true }));
}}
cancelRoute={pathnames['role-detail'].link.replace(':roleId', roleId)}
submitRoute={getBackRoute(pathnames.roles.link, { ...rolesPagination, offset: 0 }, rolesFilters)}
cancelRoute={pathnames['role-detail'].path.replace(':roleId', roleId)}
submitRoute={getBackRoute(mergeToBasename(pathnames['roles'].link), { ...rolesPagination, offset: 0 }, rolesFilters)}
routeMatch={pathnames['role-detail-remove'].path}
/>
)}
Expand All @@ -198,7 +198,7 @@ const Role = ({ onDelete }) => {
{!isRecordLoading && (
<EditRoleModal
afterSubmit={fetchData}
cancelRoute={pathnames['role-detail'].link.replace(':roleId', roleId)}
cancelRoute={pathnames['role-detail'].path.replace(':roleId', roleId)}
routeMatch={pathnames['role-detail-edit'].path}
/>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/test/smart-components/group/edit-group-modal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ describe('<EditGroupModal />', () => {
});
wrapper.update();
wrapper.find('button').first().simulate('click');
expect(mockedNavigate).toHaveBeenCalledWith('/iam/user-access/groups', undefined);
expect(mockedNavigate).toHaveBeenCalledWith('/groups');
});
});
2 changes: 1 addition & 1 deletion src/test/smart-components/group/remove-group-modal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('<RemoveGroupModal />', () => {
const wrapper = mount(<GroupWrapper store={store} />);

wrapper.find(Button).last().simulate('click');
expect(mockedNavigate).toHaveBeenCalledWith('/iam/user-access/groups', undefined);
expect(mockedNavigate).toHaveBeenCalledWith('/groups');
});

it('should call the remove action', async () => {
Expand Down

0 comments on commit fe3c1a5

Please sign in to comment.