Skip to content

Commit

Permalink
Merge branch 'master' into essntl-5210
Browse files Browse the repository at this point in the history
  • Loading branch information
gkarat authored Aug 15, 2023
2 parents 92db956 + 070d9e2 commit 65917af
Show file tree
Hide file tree
Showing 18 changed files with 316 additions and 217 deletions.
2 changes: 1 addition & 1 deletion src/components/GeneralInfo/EditButton/EditButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const InnerButton = ({ link, onClick }) => (
onClick={onClick}
className="ins-c-inventory__detail--action"
aria-label="Edit"
variant="plain"
variant="link"
>
<PencilAltIcon />
</Button>
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/GeneralInfo/InfoTable/InfoTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class InfoTable extends Component {
) : (
<TextContent>
{prepareRows(activeRows, pagination).map((row, key) => (
<Text component={TextVariants.small} key={key}>
<Text component={TextVariants.p} key={key}>
{row.title || row}
</Text>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8229,19 +8229,19 @@ exports[`InfoTable should render one cell 1`] = `
/>
<TextContent>
<Text
component="small"
component="p"
key="0"
>
first
</Text>
<Text
component="small"
component="p"
key="1"
>
second from title
</Text>
<Text
component="small"
component="p"
key="2"
>
multiple
Expand Down

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/components/GroupSystems/GroupSystems.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ const GroupSystems = ({ groupName, groupId }) => {
<AddSystemsToGroupModal
isModalOpen={addToGroupModalOpen}
setIsModalOpen={(value) => {
resetTable();
setAddToGroupModalOpen(value);
}}
groupId={groupId}
Expand All @@ -145,6 +144,7 @@ const GroupSystems = ({ groupName, groupId }) => {
isModalOpen={removeHostsFromGroupModalOpen}
setIsModalOpen={setRemoveHostsFromGroupModalOpen}
modalState={currentSystem}
reloadTimeout={1000}
reloadData={() => {
if (calculateSelected() > 0) {
dispatch(selectEntity(-1, false));
Expand All @@ -158,6 +158,7 @@ const GroupSystems = ({ groupName, groupId }) => {
<InventoryTable
columns={(columns) => prepareColumns(columns, true)}
hideFilters={{ hostGroupFilter: true }}
initialLoading
getEntities={async (items, config, showTags, defaultGetEntities) =>
await defaultGetEntities(
items,
Expand Down
13 changes: 1 addition & 12 deletions src/components/InventoryGroupDetail/NoSystemsEmptyState.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import React, { useState } from 'react';
import {
Button,
EmptyState,
EmptyStateBody,
EmptyStateIcon,
EmptyStateSecondaryActions,
Title,
} from '@patternfly/react-core';
import { ExternalLinkAltIcon, PlusCircleIcon } from '@patternfly/react-icons';
import { PlusCircleIcon } from '@patternfly/react-icons';

import { global_palette_black_600 as globalPaletteBlack600 } from '@patternfly/react-tokens/dist/js/global_palette_black_600';
import AddSystemsToGroupModal from '../InventoryGroups/Modals/AddSystemsToGroupModal';
Expand Down Expand Up @@ -52,15 +50,6 @@ const NoSystemsEmptyState = ({ groupId, groupName }) => {
>
Add systems
</ActionButton>
<EmptyStateSecondaryActions>
<Button
variant="link"
icon={<ExternalLinkAltIcon />}
iconPosition="right"
>
Learn more about system groups
</Button>
</EmptyStateSecondaryActions>
</EmptyState>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/InventoryGroups/InventoryGroups.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('groups table page', () => {
cy.wait('@getGroups');

cy.get('#groups-table').should('not.exist');
cy.get('.pf-c-empty-state').find('h4').contains('Create a system group');
cy.get('.pf-c-empty-state').find('h4').contains('No inventory groups');
});

it('renders error message when request fails', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,7 @@ const AddSystemsToGroupModal = ({
setConfirmationModalOpen(true); // switch to the confirmation modal
} else {
await handleSystemAddition([...selected.keys()]);
setTimeout(
() => dispatch(fetchGroupDetail(groupId)),
500
); // refetch data for this group
dispatch(fetchGroupDetail(groupId));
setIsModalOpen(false);
}
}}
Expand Down
12 changes: 11 additions & 1 deletion src/components/InventoryGroups/Modals/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const RepoModal = ({
initialValues,
variant,
reloadData,
reloadTimeout,
size,
onSubmit,
customFormTemplate,
Expand Down Expand Up @@ -56,7 +57,11 @@ const RepoModal = ({
await onSubmit(values);

if (reloadData !== undefined) {
setTimeout(async () => await reloadData(), 500);
if (reloadTimeout) {
setTimeout(async () => await reloadData(), reloadTimeout);
} else {
await reloadData();
}
}

closeModal();
Expand All @@ -82,6 +87,11 @@ RepoModal.propTypes = {
additionalMappers: PropTypes.object,
titleIconVariant: PropTypes.any,
customFormTemplate: PropTypes.node,
reloadTimeout: PropTypes.number,
};

RepoModal.defaultProps = {
reloadTimeout: 500,
};

export default RepoModal;
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const RemoveHostsFromGroupModal = ({
setIsModalOpen,
modalState: hosts,
reloadData,
reloadTimeout,
}) => {
const dispatch = useDispatch();
// the current iteration of groups feature a host can be in at maximum one group
Expand All @@ -55,8 +56,8 @@ const RemoveHostsFromGroupModal = ({

apiWithToast(
dispatch,
() =>
removeHostsFromGroup(
async () =>
await removeHostsFromGroup(
groupId,
hosts.map(({ id }) => id)
),
Expand All @@ -74,6 +75,7 @@ const RemoveHostsFromGroupModal = ({
schema={schema(groupName, hosts)}
onSubmit={handleRemoveHosts}
reloadData={reloadData}
reloadTimeout={reloadTimeout}
/>
);
};
Expand All @@ -95,6 +97,7 @@ RemoveHostsFromGroupModal.propTypes = {
isModalOpen: PropTypes.bool.isRequired,
setIsModalOpen: PropTypes.func.isRequired,
reloadData: PropTypes.func,
reloadTimeout: PropTypes.number,
};

export default RemoveHostsFromGroupModal;
17 changes: 3 additions & 14 deletions src/components/InventoryGroups/NoGroupsEmptyState.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ import {
EmptyState,
EmptyStateBody,
EmptyStateIcon,
EmptyStateSecondaryActions,
Title,
Tooltip,
} from '@patternfly/react-core';
import { ExternalLinkAltIcon, PlusCircleIcon } from '@patternfly/react-icons';
import { PlusCircleIcon } from '@patternfly/react-icons';
import PropTypes from 'prop-types';

import { global_palette_black_600 as globalPaletteBlack600 } from '@patternfly/react-tokens/dist/js/global_palette_black_600';
Expand Down Expand Up @@ -39,10 +38,10 @@ const NoGroupsEmptyState = ({ reloadData }) => {
color={globalPaletteBlack600.value}
/>
<Title headingLevel="h4" size="lg">
Create a system group
No inventory groups
</Title>
<EmptyStateBody>
Manage device operations efficiently by creating system groups.
Manage device operations efficiently by creating inventory groups.
</EmptyStateBody>
{canModifyGroups ? (
<Button variant="primary" onClick={() => setCreateGroupModalOpen(true)}>
Expand All @@ -55,16 +54,6 @@ const NoGroupsEmptyState = ({ reloadData }) => {
</Button>
</Tooltip>
)}
<EmptyStateSecondaryActions>
<Button
variant="link"
icon={<ExternalLinkAltIcon />}
iconPosition="right"
// TODO: component={(props) => <a href='' {...props} />}
>
Learn more about system groups
</Button>
</EmptyStateSecondaryActions>
</EmptyState>
);
};
Expand Down
40 changes: 40 additions & 0 deletions src/components/InventoryGroups/SmallComponents/Popover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import {
Button,
Popover,
Text,
TextContent,
TextVariants,
Title,
} from '@patternfly/react-core';
import { OutlinedQuestionCircleIcon } from '@patternfly/react-icons';
import React from 'react';

const InventoryGroupsPopover = () => (
<Popover
aria-label="Inventory Groups popover"
headerContent={<Title headingLevel="h4">Inventory groups</Title>}
position="right"
bodyContent={
<TextContent>
<Text component={TextVariants.p}>
Inventory groups allow you to select specific systems and group them
together to better organize your inventory.
</Text>
<Text component={TextVariants.p}>
You can also manage user access to specific inventory groups to
enhance security within your organization.
</Text>
</TextContent>
}
>
<Button
variant="plain"
aria-label="Open Inventory groups popover"
style={{ padding: 0 }}
>
<OutlinedQuestionCircleIcon />
</Button>
</Popover>
);

export default InventoryGroupsPopover;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('NoGroupsEmptyState', () => {
</MemoryRouter>
);
// toHaveTextContent is a part of @testing-library/jest-dom
expect(getByRole('heading')).toHaveTextContent('Create a system group');
expect(getByRole('heading')).toHaveTextContent('No inventory groups');
expect(container.querySelector('.pf-c-empty-state__icon')).not.toBe(null);
});

Expand All @@ -32,8 +32,5 @@ describe('NoGroupsEmptyState', () => {
expect(container.querySelector('.pf-m-primary')).toHaveTextContent(
'Create group'
);
const link = container.querySelector('.pf-m-link');
expect(link).toHaveTextContent('Learn more about system groups');
// TODO: expect(link).toHaveAttribute('href', '');
});
});
16 changes: 14 additions & 2 deletions src/components/InventoryTable/ActionWithRBAC.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ export const ActionButton = ({
noAccessTooltip,
checkAll,
override,
ignoreResourceDefinitions,
...props
}) => {
const { hasAccess: enabled } =
override !== undefined
? { hasAccess: override }
: usePermissionsWithContext(requiredPermissions, checkAll);
: usePermissionsWithContext(
requiredPermissions,
checkAll,
!ignoreResourceDefinitions
);

return enabled ? (
<Button {...props} />
Expand All @@ -34,6 +39,7 @@ ActionButton.propTypes = {
noAccessTooltip: PropTypes.string,
checkAll: PropTypes.bool,
override: PropTypes.bool,
ignoreResourceDefinitions: PropTypes.bool,
};

ActionButton.defaultProps = {
Expand All @@ -45,12 +51,17 @@ export const ActionDropdownItem = ({
noAccessTooltip,
checkAll,
override,
ignoreResourceDefinitions,
...props
}) => {
const { hasAccess: enabled } =
override !== undefined
? { hasAccess: override }
: usePermissionsWithContext(requiredPermissions, checkAll);
: usePermissionsWithContext(
requiredPermissions,
checkAll,
!ignoreResourceDefinitions
);

return enabled ? (
<DropdownItem {...props} />
Expand All @@ -64,6 +75,7 @@ ActionDropdownItem.propTypes = {
noAccessTooltip: PropTypes.string,
checkAll: PropTypes.bool,
override: PropTypes.bool,
ignoreResourceDefinitions: PropTypes.bool,
};

ActionDropdownItem.defaultProps = {
Expand Down
7 changes: 6 additions & 1 deletion src/routes/InventoryGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
PageHeader,
PageHeaderTitle,
} from '@redhat-cloud-services/frontend-components/PageHeader';
import { Flex } from '@patternfly/react-core';
import InventoryGroupsPopover from '../components/InventoryGroups/SmallComponents/Popover';

const Groups = () => {
const chrome = useChrome();
Expand All @@ -16,7 +18,10 @@ const Groups = () => {
return (
<React.Fragment>
<PageHeader>
<PageHeaderTitle title="Groups" />
<Flex spaceItems={{ default: 'spaceItemsSm' }}>
<PageHeaderTitle title="Groups" />
<InventoryGroupsPopover />
</Flex>
</PageHeader>
<InventoryGroups />
</React.Fragment>
Expand Down
Loading

0 comments on commit 65917af

Please sign in to comment.