Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Move manage integrations button from settings page to room header as a stand-alone component #1286

Merged
merged 22 commits into from
Aug 18, 2017

Conversation

rxl881
Copy link
Contributor

@rxl881 rxl881 commented Aug 9, 2017

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).

@rxl881 rxl881 requested a review from dbkr August 9, 2017 13:34
@@ -0,0 +1,127 @@
/*
Copyright 2017 Vector Creations Ltd
Copy link
Contributor

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,
Copy link
Contributor

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);
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Cheers.

Copy link
Member

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,
Copy link
Contributor

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?

Copy link
Contributor Author

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,
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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

Copy link
Contributor Author

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}
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting that!

@lukebarnard1 lukebarnard1 assigned rxl881 and unassigned lukebarnard1 Aug 11, 2017
@rxl881
Copy link
Contributor Author

rxl881 commented Aug 17, 2017

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.

@t3chguy t3chguy assigned lukebarnard1 and unassigned rxl881 Aug 17, 2017
@rxl881 rxl881 requested a review from ara4n August 17, 2017 17:18
ScalarMessaging.startListening();
this.scalarClient = null;

if (SdkConfig.get().integrations_ui_url && SdkConfig.get().integrations_rest_url) {
Copy link
Contributor

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);
Copy link
Contributor

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?

Copy link
Contributor Author

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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,
Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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 = {
Copy link
Contributor

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,
Copy link
Contributor

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.

@lukebarnard1 lukebarnard1 assigned rxl881 and unassigned lukebarnard1 Aug 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants