-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UIIN-2590: ECS: Show info message when user in member tenant tries to…
… view shared instance details without permission (#2328)
- Loading branch information
1 parent
0ac2099
commit 6515018
Showing
18 changed files
with
307 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/Instance/InstanceDetails/InstanceLoadingPane/InstanceLoadingPane.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { useIntl } from 'react-intl'; | ||
|
||
import { AppIcon } from '@folio/stripes/core'; | ||
import { | ||
Pane, | ||
Icon, | ||
} from '@folio/stripes/components'; | ||
|
||
const InstanceLoadingPane = ({ onClose }) => { | ||
const intl = useIntl(); | ||
|
||
return ( | ||
<Pane | ||
data-test-instance-details | ||
appIcon={<AppIcon app="inventory" iconKey="instance" />} | ||
paneTitle={intl.formatMessage({ id: 'ui-inventory.edit' })} | ||
dismissible | ||
onClose={onClose} | ||
defaultWidth="fill" | ||
> | ||
<Icon | ||
icon="spinner-ellipsis" | ||
width="100px" | ||
/> | ||
</Pane> | ||
); | ||
}; | ||
|
||
InstanceLoadingPane.propTypes = { onClose: PropTypes.func.isRequired }; | ||
|
||
export default InstanceLoadingPane; |
53 changes: 53 additions & 0 deletions
53
src/Instance/InstanceDetails/InstanceLoadingPane/InstanceLoadingPane.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { | ||
fireEvent, | ||
screen, | ||
} from '@folio/jest-config-stripes/testing-library/react'; | ||
|
||
import '../../../../test/jest/__mock__'; | ||
|
||
import { Icon } from '@folio/stripes/components'; | ||
|
||
import { | ||
renderWithIntl, | ||
translationsProperties, | ||
} from '../../../../test/jest/helpers'; | ||
|
||
import InstanceLoadingPane from './InstanceLoadingPane'; | ||
|
||
Icon.mockClear().mockImplementation(({ icon }) => <span>{icon}</span>); | ||
|
||
const mockOnClose = jest.fn(); | ||
|
||
const renderInstanceLoadingPane = () => { | ||
const component = <InstanceLoadingPane onClose={mockOnClose} />; | ||
|
||
return renderWithIntl(component, translationsProperties); | ||
}; | ||
|
||
describe('InstanceLoadingPane', () => { | ||
it('should render loading spinner', () => { | ||
renderInstanceLoadingPane(); | ||
|
||
expect(screen.getByText('spinner-ellipsis')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render correct header', () => { | ||
renderInstanceLoadingPane(); | ||
|
||
expect(screen.getByText('Edit')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should not render action menu', () => { | ||
renderInstanceLoadingPane(); | ||
|
||
expect(screen.queryByRole('button', { name: 'Actions' })).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should call onClose cb when pane is closed', () => { | ||
renderInstanceLoadingPane(); | ||
|
||
fireEvent.click(screen.getByRole('button', { name: 'Close Edit' })); | ||
|
||
expect(mockOnClose).toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './InstanceLoadingPane'; |
38 changes: 38 additions & 0 deletions
38
src/Instance/InstanceDetails/InstanceWarningPane/InstanceWarningPane.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { useIntl } from 'react-intl'; | ||
|
||
import { AppIcon } from '@folio/stripes/core'; | ||
import { | ||
Pane, | ||
MessageBanner, | ||
} from '@folio/stripes/components'; | ||
|
||
const InstanceWarningPane = ({ | ||
onClose, | ||
messageBannerText, | ||
}) => { | ||
const intl = useIntl(); | ||
|
||
return ( | ||
<Pane | ||
data-test-instance-details | ||
appIcon={<AppIcon app="inventory" iconKey="instance" />} | ||
paneTitle={intl.formatMessage({ id: 'ui-inventory.edit' })} | ||
dismissible | ||
onClose={onClose} | ||
defaultWidth="fill" | ||
> | ||
<MessageBanner type="warning"> | ||
{messageBannerText} | ||
</MessageBanner> | ||
</Pane> | ||
); | ||
}; | ||
|
||
InstanceWarningPane.propTypes = { | ||
onClose: PropTypes.func.isRequired, | ||
messageBannerText: PropTypes.oneOfType([PropTypes.element, PropTypes.string]).isRequired, | ||
}; | ||
|
||
export default InstanceWarningPane; |
58 changes: 58 additions & 0 deletions
58
src/Instance/InstanceDetails/InstanceWarningPane/InstanceWarningPane.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { | ||
fireEvent, | ||
screen, | ||
} from '@folio/jest-config-stripes/testing-library/react'; | ||
|
||
import '../../../../test/jest/__mock__'; | ||
|
||
import { Icon } from '@folio/stripes/components'; | ||
|
||
import { | ||
renderWithIntl, | ||
translationsProperties, | ||
} from '../../../../test/jest/helpers'; | ||
|
||
import InstanceWarningPane from './InstanceWarningPane'; | ||
|
||
Icon.mockClear().mockImplementation(({ icon }) => <span>{icon}</span>); | ||
|
||
const mockOnClose = jest.fn(); | ||
|
||
const renderInstanceLoadingPane = (messageBannerText = 'warning text') => { | ||
const component = ( | ||
<InstanceWarningPane | ||
onClose={mockOnClose} | ||
messageBannerText={messageBannerText} | ||
/> | ||
); | ||
|
||
return renderWithIntl(component, translationsProperties); | ||
}; | ||
|
||
describe('InstanceWarningPane', () => { | ||
it('should render warning banner', () => { | ||
renderInstanceLoadingPane(); | ||
|
||
expect(screen.getByText('warning text')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render correct header', () => { | ||
renderInstanceLoadingPane(); | ||
|
||
expect(screen.getByText('Edit')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should not render action menu', () => { | ||
renderInstanceLoadingPane(); | ||
|
||
expect(screen.queryByRole('button', { name: 'Actions' })).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should call onClose cb when pane is closed', () => { | ||
renderInstanceLoadingPane(); | ||
|
||
fireEvent.click(screen.getByRole('button', { name: 'Close Edit' })); | ||
|
||
expect(mockOnClose).toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './InstanceWarningPane'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.