Fix bug in Share Object Modal (#6257)

Fixes #6249
master
Sanat Mouli 6 years ago committed by kannappanr
parent 71979376b5
commit efac90461a
  1. 8
      browser/app/js/objects/ObjectActions.js
  2. 13
      browser/app/js/objects/__tests__/ObjectActions.test.js
  3. 46
      browser/ui-assets.go

@ -57,7 +57,7 @@ export class ObjectActions extends React.Component {
})
}
render() {
const { object, showShareObjectModal } = this.props
const { object, showShareObjectModal, shareObjectName } = this.props
return (
<Dropdown id={`obj-actions-${object.name}`}>
<Dropdown.Toggle noCaret className="fia-toggle" />
@ -77,7 +77,8 @@ export class ObjectActions extends React.Component {
<i className="fa fa-trash" />
</a>
</Dropdown.Menu>
{showShareObjectModal && <ShareObjectModal object={object} />}
{(showShareObjectModal && shareObjectName === object.name) &&
<ShareObjectModal object={object} />}
{this.state.showDeleteConfirmation && (
<DeleteObjectConfirmModal
deleteObject={this.deleteObject.bind(this)}
@ -92,7 +93,8 @@ export class ObjectActions extends React.Component {
const mapStateToProps = (state, ownProps) => {
return {
object: ownProps.object,
showShareObjectModal: state.objects.shareObject.show
showShareObjectModal: state.objects.shareObject.show,
shareObjectName: state.objects.shareObject.object
}
}

@ -88,8 +88,21 @@ describe("ObjectActions", () => {
object={{ name: "obj1" }}
currentPrefix={"pre1/"}
showShareObjectModal={true}
shareObjectName={"obj1"}
/>
)
expect(wrapper.find("Connect(ShareObjectModal)").length).toBe(1)
})
it("shouldn't render ShareObjectModal when the names of the objects don't match", () => {
const wrapper = shallow(
<ObjectActions
object={{ name: "obj1" }}
currentPrefix={"pre1/"}
showShareObjectModal={true}
shareObjectName={"obj2"}
/>
)
expect(wrapper.find("Connect(ShareObjectModal)").length).toBe(0)
})
})

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save