Fixed: Prevent loss of restrictions when attempting to edit multiple restrictions at once

Closes #4917
This commit is contained in:
Mark McDowall 2023-03-16 00:36:32 -07:00
parent bd228e88c3
commit b16094a9e3
6 changed files with 36 additions and 4 deletions

View File

@ -76,9 +76,15 @@ class TagInput extends Component {
// Listeners
onTagEdit = ({ value, ...otherProps }) => {
this.setState({ value });
const currentValue = this.state.value;
if (currentValue && this.props.onTagReplace) {
this.props.onTagReplace(otherProps, { name: currentValue });
} else {
this.props.onTagDelete(otherProps);
}
this.setState({ value });
};
onInputContainerPress = () => {
@ -234,7 +240,7 @@ class TagInput extends Component {
<AutoSuggestInput
{...otherProps}
forwardedRef={this._setAutosuggestRef}
className={styles.internalInput}
className={className}
inputContainerClassName={classNames(
inputContainerClassName,
isFocused && styles.isFocused,
@ -276,7 +282,8 @@ TagInput.propTypes = {
hasWarning: PropTypes.bool,
tagComponent: PropTypes.elementType.isRequired,
onTagAdd: PropTypes.func.isRequired,
onTagDelete: PropTypes.func.isRequired
onTagDelete: PropTypes.func.isRequired,
onTagReplace: PropTypes.func
};
TagInput.defaultProps = {

View File

@ -138,6 +138,7 @@ class TagInputConnector extends Component {
<TagInput
onTagAdd={this.onTagAdd}
onTagDelete={this.onTagDelete}
onTagReplace={this.onTagReplace}
{...this.props}
/>
);

View File

@ -71,6 +71,20 @@ class TextTagInputConnector extends Component {
});
};
onTagReplace = (tagToReplace, newTag) => {
const {
name,
valueArray,
onChange
} = this.props;
const newValue = [...valueArray];
newValue.splice(tagToReplace.index, 1);
newValue.push(newTag.name.trim());
onChange({ name, value: newValue });
};
//
// Render
@ -80,6 +94,7 @@ class TextTagInputConnector extends Component {
tagList={[]}
onTagAdd={this.onTagAdd}
onTagDelete={this.onTagDelete}
onTagReplace={this.onTagReplace}
{...this.props}
/>
);

View File

@ -3,3 +3,9 @@
margin-right: auto;
}
.tagInternalInput {
composes: internalInput from '~Components/Form/TagInput.css';
flex: 0 0 100%;
}

View File

@ -2,6 +2,7 @@
// Please do not change this file!
interface CssExports {
'deleteButton': string;
'tagInternalInput': string;
}
export const cssExports: CssExports;
export default cssExports;

View File

@ -76,6 +76,7 @@ function EditReleaseProfileModalContent(props) {
<FormInputGroup
{...required}
inputClassName={styles.tagInternalInput}
type={inputTypes.TEXT_TAG}
name="required"
helpText="The release must contain at least one of these terms (case insensitive)"
@ -92,6 +93,7 @@ function EditReleaseProfileModalContent(props) {
<FormInputGroup
{...ignored}
inputClassName={styles.tagInternalInput}
type={inputTypes.TEXT_TAG}
name="ignored"
helpText="The release will be rejected if it contains one or more of terms (case insensitive)"