mirror of
https://github.com/ansible/awx.git
synced 2026-02-21 13:10:11 -03:30
clear Lookup query params when lookup is closed
This commit is contained in:
@@ -64,7 +64,7 @@ class Lookup extends React.Component {
|
|||||||
count: 0,
|
count: 0,
|
||||||
error: null,
|
error: null,
|
||||||
};
|
};
|
||||||
this.qsConfig = getQSConfig('lookup', {
|
this.qsConfig = getQSConfig(props.qsNamespace, {
|
||||||
page: 1,
|
page: 1,
|
||||||
page_size: 5,
|
page_size: 5,
|
||||||
order_by: props.sortedColumnKey,
|
order_by: props.sortedColumnKey,
|
||||||
@@ -73,6 +73,7 @@ class Lookup extends React.Component {
|
|||||||
this.toggleSelected = this.toggleSelected.bind(this);
|
this.toggleSelected = this.toggleSelected.bind(this);
|
||||||
this.saveModal = this.saveModal.bind(this);
|
this.saveModal = this.saveModal.bind(this);
|
||||||
this.getData = this.getData.bind(this);
|
this.getData = this.getData.bind(this);
|
||||||
|
this.clearQSParams = this.clearQSParams.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@@ -163,6 +164,8 @@ class Lookup extends React.Component {
|
|||||||
lookupSelectedItems = multiple ? [...value] : [value];
|
lookupSelectedItems = multiple ? [...value] : [value];
|
||||||
}
|
}
|
||||||
this.setState({ lookupSelectedItems });
|
this.setState({ lookupSelectedItems });
|
||||||
|
} else {
|
||||||
|
this.clearQSParams();
|
||||||
}
|
}
|
||||||
this.setState(prevState => ({
|
this.setState(prevState => ({
|
||||||
isModalOpen: !prevState.isModalOpen,
|
isModalOpen: !prevState.isModalOpen,
|
||||||
@@ -179,6 +182,14 @@ class Lookup extends React.Component {
|
|||||||
this.handleModalToggle();
|
this.handleModalToggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearQSParams() {
|
||||||
|
const { history } = this.props;
|
||||||
|
const parts = history.location.search.replace(/^\?/, '').split('&');
|
||||||
|
const ns = this.qsConfig.namespace;
|
||||||
|
const otherParts = parts.filter(param => !param.startsWith(`${ns}.`))
|
||||||
|
history.push(`${history.location.pathname}?${otherParts.join('&')}`);
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
isModalOpen,
|
isModalOpen,
|
||||||
@@ -303,6 +314,7 @@ Lookup.propTypes = {
|
|||||||
sortedColumnKey: string.isRequired,
|
sortedColumnKey: string.isRequired,
|
||||||
multiple: bool,
|
multiple: bool,
|
||||||
required: bool,
|
required: bool,
|
||||||
|
qsNamespace: string,
|
||||||
};
|
};
|
||||||
|
|
||||||
Lookup.defaultProps = {
|
Lookup.defaultProps = {
|
||||||
@@ -312,6 +324,7 @@ Lookup.defaultProps = {
|
|||||||
value: null,
|
value: null,
|
||||||
multiple: false,
|
multiple: false,
|
||||||
required: false,
|
required: false,
|
||||||
|
qsNamespace: 'lookup',
|
||||||
};
|
};
|
||||||
|
|
||||||
export { Lookup as _Lookup };
|
export { Lookup as _Lookup };
|
||||||
|
|||||||
Reference in New Issue
Block a user