Fix bug in Share Object Modal (#6257)

Fixes #6249
This commit is contained in:
Sanat Mouli 2018-08-09 09:45:43 -07:00 committed by kannappanr
parent 71979376b5
commit efac90461a
3 changed files with 41 additions and 26 deletions

View File

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

View File

@ -88,8 +88,21 @@ describe("ObjectActions", () => {
object={{ name: "obj1" }} object={{ name: "obj1" }}
currentPrefix={"pre1/"} currentPrefix={"pre1/"}
showShareObjectModal={true} showShareObjectModal={true}
shareObjectName={"obj1"}
/> />
) )
expect(wrapper.find("Connect(ShareObjectModal)").length).toBe(1) 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