diff --git a/ember/app/components/project-form/component.js b/ember/app/components/project-form/component.js index c89d9808..080600ba 100644 --- a/ember/app/components/project-form/component.js +++ b/ember/app/components/project-form/component.js @@ -34,6 +34,10 @@ export default class ProjectFormComponent extends Component { saveProject = dropTask(async () => { try { + if (this.project.repoType === 'public') { + this.project.accessToken = ''; + } + const project = await this.project.save({ adapterOptions: { include: @@ -61,6 +65,7 @@ export default class ProjectFormComponent extends Component { }); this.router.transitionTo('projects.detailed', project.id); + this.project.accessToken = ''; this.notification.success('Successfully saved!'); } catch (e) { this.notification.danger(e); @@ -79,4 +84,8 @@ export default class ProjectFormComponent extends Component { get users() { return this.store.peekAll('user'); } + + get repoTypes() { + return ['public', 'access-token']; + } } diff --git a/ember/app/components/project-form/template.hbs b/ember/app/components/project-form/template.hbs index 9eabb803..cfdcc972 100644 --- a/ember/app/components/project-form/template.hbs +++ b/ember/app/components/project-form/template.hbs @@ -11,7 +11,25 @@ as |f| > - +
+ +
+ + +
+
+ + div:first-of-type { + width: 90%; + } + + & > div:last-of-type { + min-width: 8rem; + display: grid; + align-content: start; + width: 100%; + flex-shrink: 9; + } +} diff --git a/ember/app/validations/project.js b/ember/app/validations/project.js index b03c1e0a..e65e5076 100644 --- a/ember/app/validations/project.js +++ b/ember/app/validations/project.js @@ -2,16 +2,31 @@ import { validatePresence, validateLength, validateFormat, + validateInclusion, } from 'ember-changeset-validations/validators'; +import validationsWhenOther from 'outdated/utils/validations-when-other'; + export default { - name: [validatePresence(true), validateLength({ max: 100 })], + name: [ + validatePresence({ presence: true, ignoreBlank: true }), + validateLength({ max: 100 }), + ], + repoType: [validatePresence(true)], repo: [ - validatePresence(true), + validatePresence({ presence: true, ignoreBlank: true }), validateLength({ max: 200 }), validateFormat({ regex: /^([-_\w]+\.[-._\w]+)\/([-_\w]+)\/([-_\w]+)$/, }), ], + accessToken: validationsWhenOther({ + field: 'repoType', + otherFieldValidator: validateInclusion({ in: ['access-token'] }), + fieldValidators: [ + validatePresence({ presence: true, ignoreBlank: true }), + validateFormat({ regex: /^[-_a-zA-Z\d]*$/ }), + ], + }), maintainers: [], };