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 8, 2023
1 parent d732452 commit 2849025
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
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 need to be deleted from the repsotiory details page.')} />
<Button
ouiaId="export-csv-button"
className="pull-right"
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,7 +4,9 @@ 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>}
Expand All @@ -14,11 +16,17 @@ const EnabledRepositoryContent = ({ loading, disableTooltipId, disableRepository
>
<button
onClick={disableRepository}
style={{
style={canDisable ? {
backgroundColor: 'initial',
border: 'none',
color: '#0388ce',
}}
} : {
backgroundColor: 'initial',
border: 'none',
color: '#',
}
}
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;

0 comments on commit 2849025

Please sign in to comment.