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

Conversation

@dbkr
Copy link
Member

@dbkr dbkr commented Feb 13, 2017

Into a component that does Interactive Auth and a dialog that
wraps it, so we can do interactive auth not necessarily in a
dialog.

As a side effect:

  • Put the buttons for each auth stage in the stage itself.
    Some stages don't have submit buttons (and it's very possible
    other stages may have other buttons entirely, like 'resend')
    so it makes more sense for the buttons to live in the stage
    components themselves. Plus it saves the slightly evil
    calling-functions-on-react-children thing we were doing (and
    indeed extending that to show the submit button at all).
  • Give all BaseDialogs a cross in the top right to cancel. They
    were all dismissable by clicking outside or pressing esc, so
    this adds a more visually obvious way of dismissing them. Plus,
    it means our InteractiveAuthDialog can have a way of canceling
    the whole operation separate from buttons for the individual
    stages.

Requires element-hq/element-web#3217

Into a component that does Interactive Auth and a dialog that wraps it, so we can do interactive auth not necessarily in a dialog. As a side effect: * Put the buttons for each auth stage in the stage itself. Some stages don't have submit buttons (and it's very possible other stages may have other buttons entirely, like 'resend') so it makes more sense for the buttons to live in the stage components themselves. Plus it saves the slightly evil calling-functions-on-react-children thing we were doing (and indeed extending that to show the submit button at all). * Give all BaseDialogs a cross in the top right to cancel. They were all dismissable by clicking outside or pressing esc, so this adds a more visually obvious way of dismissing them. Plus, it means our InteractiveAuthDialog can have a way of canceling the whole operation separate from buttons for the individual stages.
dbkr added a commit to element-hq/element-web that referenced this pull request Feb 13, 2017
/>
<div className="mx_button_row">
<input type="submit"
className="mx_Dialog_primary"
Copy link
Member Author

Choose a reason for hiding this comment

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

Using the mx_Dialog class here: the button classes need refactoring into a single class, so rather than c+p the CSS yet again, I'm reusing this class.

onChange={this._onPasswordFieldChange}
type="password"
/>
<form onSubmit={this._onSubmit}>
Copy link
Member Author

Choose a reason for hiding this comment

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

I've put this in a form which makes the behaviour more semantic and accessible, (we then get submit-on-enter for free, etc)

},

render: function() {
const Loader = sdk.getComponent("elements.Spinner");
Copy link
Member

Choose a reason for hiding this comment

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

redundant

Copy link
Member

Choose a reason for hiding this comment

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

... except I can't see any feedback to the user that a request is in-flight. We used to show a spinner in place of the submit button when state.busy was true (which was ugly as hell imho, but still). We ought to reinstate this somehow.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

},

_onCancelClick: function(e) {
e.stopPropagation();
Copy link
Member

Choose a reason for hiding this comment

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

think e.stopPropagation(), e.preventDefault() are pretty unnecessary here

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

}
},

_onCancel: function() {
Copy link
Member

Choose a reason for hiding this comment

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

is this ever used? it looks superflous

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, done

// callback
makeRequest: React.PropTypes.func.isRequired,

onFinished: React.PropTypes.func.isRequired,
Copy link
Member

Choose a reason for hiding this comment

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

could you document how this is used, given it is no longer necessarily part of the Modal stuff with its implied convention?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

},

_onCancel: function() {
_onCancelClick: function() {
Copy link
Member

Choose a reason for hiding this comment

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

think this one is dead too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, it was. Done

* stageParams: params from the server for the stage being attempted
* errorText: error message from a previous attempt to authenticate
* submitAuthDict: a function which will be called with the new auth dict
* setSubmitButtonEnabled: a function which will enable/disable the 'submit' button
Copy link
Member

Choose a reason for hiding this comment

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

github won't let me comment on it, but could you update the comment on line 24 to refer to InteractiveAuth rather than InteractiveAuthDialog?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

* setSubmitButtonEnabled: a function which will enable/disable the 'submit' button
*
* Each component may also provide the following functions (beyond the standard React ones):
* onSubmitClick: handle a 'submit' button click
Copy link
Member

Choose a reason for hiding this comment

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

this is no longer true?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I moved the submit button into the stage components, so no need for them to be passed a function to disable one somewhere else.

Copy link
Member

Choose a reason for hiding this comment

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

... so could you remove it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I see what you mean, yes. (Still find myself thinking the line you've commented on is the line I changed rather than the one at the bottom of the diff).

// we have to make the user click a button, as browsers will block
// the popup if we open it immediately.
this._popupWindow = null;
this.props.setSubmitButtonEnabled(true);
Copy link
Member

Choose a reason for hiding this comment

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

this needs a submit button.

Copy link
Member Author

Choose a reason for hiding this comment

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

ah yes: done

},

render: function() {
const Loader = sdk.getComponent("elements.Spinner");
Copy link
Member

Choose a reason for hiding this comment

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

... except I can't see any feedback to the user that a request is in-flight. We used to show a spinner in place of the submit button when state.busy was true (which was ugly as hell imho, but still). We ought to reinstate this somehow.

@richvdh richvdh assigned dbkr and unassigned richvdh Feb 13, 2017
@dbkr
Copy link
Member Author

dbkr commented Feb 13, 2017

Have also added a spinner

@dbkr dbkr assigned richvdh and unassigned dbkr Feb 13, 2017
errorText: React.PropTypes.string,
// is the auth logic currently waiting for something to
// happen?
busy: React.PropTypes.bool,
Copy link
Member

Choose a reason for hiding this comment

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

Add this to the list of properties at the top of the file?

@richvdh
Copy link
Member

richvdh commented Feb 14, 2017

looks good apart from a couple of nits

@richvdh richvdh assigned dbkr and unassigned richvdh Feb 14, 2017
@dbkr dbkr merged commit 17b08ae into develop Feb 14, 2017
@richvdh richvdh deleted the dbkr/interactive_auth_nondialog branch February 15, 2017 13:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants