Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UFI-60 #237

Merged
merged 2 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions src/plugin/iframe_root/modules/reactComponents/SignUpForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ define([
);
}

canSubmitForm() {
return this.formIsValid() && this.state.policiesResolved;
}

async loadOrganizations() {
const fetchJSON = async (name) => {
const path = `${this.props.runtime.pluginResourcePath}/dataSources/`;
Expand Down Expand Up @@ -308,7 +312,7 @@ define([
},
{
validate: async (value) => {
if (/^[0-9]+/.test(value)) {
if (/^\d+/.test(value)) {
return {
isValid: false,
message: 'A username may not begin with a number'
Expand Down Expand Up @@ -947,8 +951,19 @@ define([
this.props.onCancelSignUp();
}

renderFormMessage() {
if (!this.canSubmitForm()) {
return html`
<div className="alert alert-warning" style=${{marginBottom: '1rem'}}><b>Reminder -</b> All fields must be completed in order to create a KBase account</>
`;
}
return html`
<div className="alert alert-success" style=${{marginBottom: '1rem'}}><b>Ready -</b> All fields are complete, you may now create your account</>
`;
}

renderFormButtons() {
const disabled = !(this.formIsValid() && this.state.policiesResolved);
const disabled = !(this.canSubmitForm());
return html`
<div className="btn-toolbar" style=${{display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'center'}}>
<button className="btn btn-primary"
Expand Down Expand Up @@ -1029,7 +1044,7 @@ define([
<p>
Some field values have been pre-populated from your
<span style=${{padding: '0 0.25em', fontWeight: 'bold'}}>${this.props.choice.provider}</span>
account
account. <b>All fields are required.</b>
</p>
</div>
</div>
Expand All @@ -1048,6 +1063,7 @@ define([
<hr />
<${UseAgreements} policiesToResolve=${this.props.policiesToResolve} onAgreed=${this.onAgreed.bind(this)}/>
<hr />
${this.renderFormMessage()}
${this.renderFormButtons()}
</form>
</div>
Expand All @@ -1064,15 +1080,6 @@ define([
${this.renderSignupForm()}
</>
`;

// return html`
// <${Panel}
// type="default"
// classes=${['kb-panel-light']}
// title="Sign up for KBase">
// ${this.renderSignupForm()}
// </>
// `;
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ define([
});

const phrase = (() => {
if (this.props.policiesToResolve.length === 1) {
if (this.props.policiesToResolve.length >= 1) {
switch (this.props.policiesToResolve[0].status) {
case 'new':
return 'not yet been agreed to by this account';
Expand Down