Skip to content

Commit

Permalink
- Added the new author form
Browse files Browse the repository at this point in the history
  • Loading branch information
Potentii committed Dec 25, 2019
1 parent 2f3c05a commit 3ff4d37
Show file tree
Hide file tree
Showing 9 changed files with 348 additions and 10 deletions.
1 change: 1 addition & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions packages/ui/account/account.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import ProjectGitConfigs from '../project/project-git-configs';



export default class Account{

/**
*
* @param {String} name
* @param {String} email
*/
constructor(name, email){
this.name = name;
this.email = email;
}


static from(obj){
return new Account(
obj.name,
obj.email,
);
}

}
20 changes: 20 additions & 0 deletions packages/ui/account/provider-account.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Account from './account';



export default class ProviderAccount extends Account{

/**
*
* @param {String} name
* @param {String} email
* @param {String} pass
* @param {String} provider
*/
constructor(name, email, pass, provider){
super(name, email);
this.pass = pass;
this.provider = provider;
}

}
1 change: 0 additions & 1 deletion packages/ui/git/git-diff-parser.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default class GitDiffParser{
*/
_newImpl(data){
return parseDiff(data).map(diff => {
console.log(diff);
const hunks = diff.chunks.map(chunk => {
const a_range = new DiffHunkRange(chunk.oldStart, chunk.oldLines);
const b_range = new DiffHunkRange(chunk.newStart, chunk.newLines);
Expand Down
6 changes: 4 additions & 2 deletions packages/ui/project/project-details.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// import ProjectRemote from './project-remote';
import ProjectGitConfigs from './project-git-configs';
import Account from '../account/account';



export default class ProjectDetails{

constructor(location, git_configs){
constructor(location, git_configs, account){
this.location = location;
this.git_configs = git_configs;

this.account = account;
}


Expand All @@ -17,6 +18,7 @@ export default class ProjectDetails{
obj.location,
// Array.isArray(obj.remotes) ? obj.remotes.map(ProjectRemote.from) : null,
obj.git_configs ? ProjectGitConfigs.from(obj.git_configs) : null,
obj.account ? Account.from(obj.account) : null,
);
}

Expand Down
14 changes: 14 additions & 0 deletions packages/ui/project/project-vo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class ProjectVO{
this.commits = commits;
}


get _id(){
return this.project?._id;
}
Expand All @@ -36,6 +37,19 @@ export default class ProjectVO{
}


/**
*
* @returns {Account|null}
*/
get account(){
return this.project?.details?.account;
}

set account(account){
this.project.details.account = account;
}


/**
*
* @returns {Promise<String|null|undefined>}
Expand Down
219 changes: 219 additions & 0 deletions packages/ui/project/v-new-author-form.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
<template>
<div class="v-new-author-form">

<div class="-header">
<span class="-title">Author information:</span>

<select class="-provider" v-model="provider" v-if="false">
<option value="">Select remote</option>
<option value="github">Github</option>
<option value="gitlab">GitLab</option>
<option value="bitbucket">BitBucket</option>
</select>
</div>

<form class="-form" @submit.prevent="onSubmit">

<div class="-inputs">
<input class="-input -name" type="text" placeholder="Username" v-model="non_provider_form.name" autofocus/>
<input class="-input -email" type="email" placeholder="E-mail" v-model="non_provider_form.email"/>
</div>

<v-button
class="-ok --form-control"
type="submit"
text="Save"
title="Save information"
capsule
uppercase>
</v-button>
</form>

</div>
</template>



<script>
import ProjectVO from './project-vo';
import VButton from '../@components/v-button';
import Account from '../account/account';
export default {
name: 'v-new-author-form',
components: { VButton },
props: {
/**
* @type {ProjectVO}
*/
project_vo: {
type: ProjectVO,
required: true,
}
},
data(){
return {
provider: '',
non_provider_form: {
name: null,
email: null,
},
provider_form: {
email_or_username: null,
password: null,
},
};
},
computed: {
// async has_push_remotes(){
// return (await this.project_vo?.git.remote.getAll()).some(remote => remote.is_push);
// }
},
methods: {
async onSubmit(){
this.$states.add('saving');
this.$states.remove('saved');
try{
if(!this.non_provider_form.name || !this.non_provider_form.name)
throw new Error(`Invalid user name or e-mail`);
const account = new Account(this.non_provider_form.name, this.non_provider_form.email);
this.$emit('created', account);
this.$states.add('saved');
} catch(err){
console.error(err);
} finally{
this.$states.remove('saving');
}
},
},
}
</script>



<style>
.v-new-author-form{
display: flex;
flex-direction: column;
}
.v-new-author-form > .-header{
display: flex;
flex-direction: column;
}
.v-new-author-form > .-header > .-title{
font-size: 14px;
font-family: 'Roboto Medium', sans-serif;
letter-spacing: 0.03em;
margin-bottom: 0.7em;
}
.v-new-author-form > .-header > .-provider{
padding: 0.5em 1em;
margin-bottom: 0.7em;
box-shadow: 0 0 0 1.0pt rgba(0,0,0,0.08);
border-radius: 30em;
font-size: 14px;
font-family: 'Roboto', sans-serif;
color: var(--blank-fg--base);
letter-spacing: 0.03em;
transition: box-shadow 0.2s ease;
}
.v-new-author-form > .-header > .-provider:focus{
box-shadow: 0 0 0 1.0pt rgba(0,0,0,0.2);
outline: 1px solid transparent;
}
.v-new-author-form > .-form{
display: flex;
flex-direction: column;
}
.v-new-author-form > .-form > .-inputs{
display: flex;
flex-direction: column;
margin-bottom: 0.7em;
}
.v-new-author-form > .-form > .-inputs > .-input{
flex: 1 1 auto;
padding: 0.6em 1em;
box-shadow: 0 0 0 1.0pt rgba(0,0,0,0.08);
border-radius: 30em;
font-size: 14px;
font-family: 'Roboto', sans-serif;
color: var(--blank-fg--base);
letter-spacing: 0.03em;
transition: box-shadow 0.2s ease;
}
.v-new-author-form > .-form > .-inputs > .-input:focus{
box-shadow: 0 0 0 1.0pt rgba(0,0,0,0.2);
outline: 1px solid transparent;
}
.v-new-author-form > .-form > .-inputs > .-input + .-input{
margin-top: 1em;
}
.v-new-author-form > .-form > .-ok{
align-self: flex-end;
}
/*.v-new-author-form > .-input{*/
/* flex: 1 1 auto;*/
/* padding: 0.8em 1em;*/
/* resize: none;*/
/* border: 1px solid rgba(0,0,0,0.06);*/
/* border-radius: 8px;*/
/* font-size: 14px;*/
/* font-family: 'Roboto', sans-serif;*/
/* color: var(--blank-fg--base);*/
/* letter-spacing: 0.03em;*/
/* transition: border-color 0.15s ease;*/
/*}*/
/*.v-new-author-form > .-input:focus{*/
/* border-color: rgba(0,0,0,0.13);*/
/*}*/
/*.v-new-author-form > .-actions{*/
/* display: flex;*/
/* justify-content: flex-end;*/
/* align-items: center;*/
/* margin-top: 0.8em;*/
/*}*/
/*.v-new-author-form > .-actions > .-action + .-action{*/
/* margin-left: 0.8em;*/
/*}*/
</style>
Loading

0 comments on commit 3ff4d37

Please sign in to comment.