-
-
Notifications
You must be signed in to change notification settings - Fork 832
Move manage integrations button from settings page to room header as a stand-alone component #1286
Conversation
@@ -0,0 +1,127 @@ | |||
/* | |||
Copyright 2017 Vector Creations Ltd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not anymore!
super(props); | ||
|
||
this.state = { | ||
scalar_error: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be camelCase
let integrationsError; | ||
if (this.scalarClient !== null) { | ||
if (this.state.showIntegrationsError && this.state.scalar_error) { | ||
console.error(this.state.scalar_error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be logged after line 50
ScalarMessaging.startListening(); | ||
this.scalarClient = null; | ||
|
||
if (SdkConfig.get().integrations_ui_url && SdkConfig.get().integrations_rest_url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's strange that we don't pass these URLs into the auth client here, and have to check the config before creating a ScakarAuthClient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an argument against fixing it, but this is simply copied across from the existing code on the settings page -- https://github.com/matrix-org/matrix-react-sdk/pull/1286/files#diff-7810353d2ee5218b7242e81423030433L141.
Unless you think this is broken, I'm inclined to leave it. What do you reckon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not broken, it's just a weird API that made sense when we only ever made one Scalar client. Feel free to leave it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. Cheers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote this check to hide all instances of Manage Integrations/Scalar/Modular if there is are no integrations URLs defined in the config. i.e a way to hide the buttons.
This seems to have regressed from the original function: #816
Modal.createDialog(IntegrationsManager, { | ||
src: (this.scalarClient !== null && this.scalarClient.hasCredentials()) ? | ||
this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId) : | ||
null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this not open an iFrame with a null
src?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with some of the previous comments, this has just been cargo-culted across from the existing room settings code (https://github.com/matrix-org/matrix-react-sdk/pull/1286/files#diff-7810353d2ee5218b7242e81423030433L520). As it is not currently considered broken, I'm inclined to leave it as is, for now.
} | ||
|
||
ManageIntegsButton.propTypes = { | ||
room: PropTypes.object.isRequired, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer a roomId
going in here, ManageIntegsButton
doesn't need the rest of room state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
null, | ||
onFinished: ()=>{ | ||
if (this.props.onCancelClick) { | ||
this.props.onCancelClick(ev); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably don't want to be returning this ev
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with one of the previous comments, this code is directly copied across from the existing settings page - https://github.com/matrix-org/matrix-react-sdk/pull/1286/files#diff-7810353d2ee5218b7242e81423030433L525.
I'm inclined to leave it, for fear of breaking existing expected behaviour.
if (!this.props.editing) { | ||
rightRow = | ||
<div className="mx_RoomHeader_rightRow"> | ||
{ settingsButton } | ||
<ManageIntegsButton | ||
onCancelClick={this.props.onCancelClick} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems quite bizarre to be bubbling the onCancelClick
of the integrations manager to the onCancelClick
of the room header. Stranger still that the onCancelClick
that is passed to RoomView will close room settings, so this is definitely wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for spotting that!
Show a dialog if the maximum number of widgets allowed has been reached.
Thanks Luke. Hopefully that is mainly sorted now. There are two items that were copied across from existing code and I'm tempted to leave, unless you think that they should be addressed now. Can you PTAL? Cheers. |
ScalarMessaging.startListening(); | ||
this.scalarClient = null; | ||
|
||
if (SdkConfig.get().integrations_ui_url && SdkConfig.get().integrations_rest_url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not broken, it's just a weird API that made sense when we only ever made one Scalar client. Feel free to leave it for now.
null, | ||
onFinished: ()=>{ | ||
if (this.props.onCancelClick) { | ||
this.props.onCancelClick(ev); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for fear of breaking existing expected behaviour.
This property is never set - the entire if
is redundant and we should absolutely avoid redundant, potentially confusing code.
This means that the behaviour has changed, given you've copied it. Oh! I guess this is the thing where if you close the integrations manager, you also close the room settings. Maybe that wasn't so bizarre after all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed IRL, I've removed this all together from the ManageIntegsButton component, as it doesn't appear to be used at the moment.
let integrationsError; | ||
if (this.scalarClient !== null) { | ||
if (this.state.showIntegrationsError && this.state.scalarError) { | ||
console.error(this.state.scalarError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest moving this to where the error is first caught.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -47,13 +48,15 @@ module.exports = React.createClass({ | |||
onSaveClick: React.PropTypes.func, | |||
onSearchClick: React.PropTypes.func, | |||
onLeaveClick: React.PropTypes.func, | |||
onCancelClick: React.PropTypes.func, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onCancelClick
is not used by anything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it is not used by anything that I have added, this prop actually is used elsewhere in the code... https://github.com/matrix-org/matrix-react-sdk/pull/1286/files#diff-96b79748dd7ebec5d36339d2478e92cbR194
I was adding it in to the component props and default to make it clear to future people (like me) that this prop is passed in are available to be used by other components and to make sure that there is a sensible default if the function is not passed.
I can remove it if you want, but I think it makes more sense to leave it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, this looks to be necessary. I think I was confused by the fact that it wasn't in prop types previously.
roomId: PropTypes.string.isRequired, | ||
}; | ||
|
||
ManageIntegsButton.defaultProps = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty default props
@@ -47,13 +48,15 @@ module.exports = React.createClass({ | |||
onSaveClick: React.PropTypes.func, | |||
onSearchClick: React.PropTypes.func, | |||
onLeaveClick: React.PropTypes.func, | |||
onCancelClick: React.PropTypes.func, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, this looks to be necessary. I think I was confused by the fact that it wasn't in prop types previously.
The intent of this PR is to move the existing manage integrations button out from the settings page in to a reusable component, so that it can be used in the room header (and other places, as needed).