Skip to content

Commit

Permalink
Fixes #36733 - Disable published redhat repo disable button
Browse files Browse the repository at this point in the history
(cherry picked from commit 93fc11107f4a9a159a240a35a41a50d9cc95c505)
  • Loading branch information
sjha4 committed Sep 11, 2023
1 parent d732452 commit cf7dd14
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 8 deletions.
4 changes: 4 additions & 0 deletions webpack/redux/reducers/RedHatRepositories/enabled.fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const requestSuccessResponse = Immutable({
],
},
last_sync: null,
content_view_versions: [],
content_counts: {
docker_manifest: 0,
docker_manifest_list: 0,
Expand Down Expand Up @@ -95,6 +96,7 @@ export const requestSuccessResponse = Immutable({
],
},
last_sync: null,
content_view_versions: [1],
content_counts: {
docker_manifest: 0,
docker_manifest_list: 0,
Expand Down Expand Up @@ -128,6 +130,7 @@ export const successState = Immutable({
productId: 20,
releasever: '7.0',
type: 'yum',
canDisable: true,
},
{
arch: 'x86_64',
Expand All @@ -139,6 +142,7 @@ export const successState = Immutable({
productId: 20,
releasever: '7.1',
type: 'yum',
canDisable: false,
},
],
searchIsActive: false,
Expand Down
1 change: 1 addition & 0 deletions webpack/redux/reducers/RedHatRepositories/enabled.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const mapRepo = (repo) => {
orphaned: repo.product.orphaned,
contentId: parseInt(repo.content_id, 10),
productId: parseInt(repo.product.id, 10),
canDisable: repo.content_view_versions.length === 0,
});
};

Expand Down
3 changes: 2 additions & 1 deletion webpack/scenes/RedHatRepositories/RedHatRepositoriesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PropTypes from 'prop-types';
import { isEmpty } from 'lodash';
import { Grid, Row, Col } from 'react-bootstrap';
import { Skeleton, Alert } from '@patternfly/react-core';
import { Button } from 'patternfly-react';
import { Button, FieldLevelHelp } from 'patternfly-react';
import { translate as __ } from 'foremanReact/common/I18n';
import PermissionDenied from 'foremanReact/components/PermissionDenied';
import { LoadingState } from '../../components/LoadingState';
Expand Down Expand Up @@ -96,6 +96,7 @@ class RedHatRepositoriesPage extends Component {
<Col sm={6} className="enabled-repositories-container">
<h2>
{__('Enabled Repositories')}
<FieldLevelHelp content={__('Only repositories not published in a content view can be disabled. Published repositories must be deleted from the repository details page.')} />
<Button
ouiaId="export-csv-button"
className="pull-right"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ exports[`RedHatRepositories page should render 1`] = `
>
<h2>
Enabled Repositories
<FieldLevelHelp
buttonClass=""
content="Only repositories not published in a content view can be disabled. Published repositories must be deleted from the repository details page."
placement="top"
rootClose={true}
/>
<Button
active={false}
block={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class EnabledRepository extends Component {

render() {
const {
name, id, type, orphaned, label,
name, id, type, orphaned, label, canDisable,
} = this.props;

return (
Expand All @@ -73,6 +73,7 @@ class EnabledRepository extends Component {
loading={this.props.loading}
disableTooltipId={this.disableTooltipId}
disableRepository={this.disableRepository}
canDisable={canDisable}
/>
}
leftContent={<RepositoryTypeIcon id={id} type={type} />}
Expand Down Expand Up @@ -106,6 +107,7 @@ EnabledRepository.propTypes = {
loading: PropTypes.bool,
releasever: PropTypes.string,
orphaned: PropTypes.bool,
canDisable: PropTypes.bool,
setRepositoryDisabled: PropTypes.func.isRequired,
loadEnabledRepos: PropTypes.func.isRequired,
disableRepository: PropTypes.func.isRequired,
Expand All @@ -116,6 +118,7 @@ EnabledRepository.defaultProps = {
orphaned: false,
search: {},
loading: false,
canDisable: true,
};

export default EnabledRepository;
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,29 @@ import cx from 'classnames';
import { Spinner, OverlayTrigger, Tooltip } from 'patternfly-react';
import { translate as __ } from 'foremanReact/common/I18n';

const EnabledRepositoryContent = ({ loading, disableTooltipId, disableRepository }) => (
const EnabledRepositoryContent = ({
loading, disableTooltipId, disableRepository, canDisable,
}) => (
<Spinner loading={loading} inline>
<OverlayTrigger
overlay={<Tooltip id={disableTooltipId}>{__('Disable')}</Tooltip>}
overlay={<Tooltip id={disableTooltipId}>{canDisable ? __('Disable') : __('Cannot be disabled because it is part of a published content view')}</Tooltip>}
placement="bottom"
trigger={['hover', 'focus']}
rootClose={false}
>
<button
onClick={disableRepository}
style={{
style={canDisable ? {
backgroundColor: 'initial',
border: 'none',
color: '#0388ce',
}}
} : {
backgroundColor: 'initial',
border: 'none',
color: '#d2d2d2',
}
}
disabled={!canDisable}
>
<i className={cx('fa-2x', 'fa fa-minus-circle')} />
</button>
Expand All @@ -30,6 +38,7 @@ EnabledRepositoryContent.propTypes = {
loading: PropTypes.bool.isRequired,
disableTooltipId: PropTypes.string.isRequired,
disableRepository: PropTypes.func.isRequired,
canDisable: PropTypes.bool.isRequired,
};

export default EnabledRepositoryContent;
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('Enabled Repositories Content Component', () => {
loading
disableTooltipId="disable-1"
disableRepository={mockCallBack}
canDisable={false}
/>);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports[`Enabled Repositories Component should render 1`] = `
<ListViewItem
actions={
<EnabledRepositoryContent
canDisable={true}
disableRepository={[Function]}
disableTooltipId="disable-1"
loading={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports[`Enabled Repositories Content Component should render 1`] = `
id="disable-1"
placement="right"
>
Disable
Cannot be disabled because it is part of a published content view
</Tooltip>
}
placement="bottom"
Expand All @@ -29,12 +29,13 @@ exports[`Enabled Repositories Content Component should render 1`] = `
}
>
<button
disabled={true}
onClick={[MockFunction]}
style={
Object {
"backgroundColor": "initial",
"border": "none",
"color": "#0388ce",
"color": "#d2d2d2",
}
}
>
Expand Down

0 comments on commit cf7dd14

Please sign in to comment.