2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-27 10:51:33 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2018-11-14 14:00:01 +00:00
|
|
|
<template>
|
2019-03-29 10:46:42 +00:00
|
|
|
<div class="new-project-popup-container" v-on:keyup.enter="createProjectClick" v-on:keyup.esc="onCloseClick">
|
2019-01-25 13:09:46 +00:00
|
|
|
<div class="new-project-popup" id="newProjectPopup" >
|
2018-11-19 15:32:50 +00:00
|
|
|
<div class="new-project-popup__info-panel-container">
|
2019-04-08 23:34:28 +01:00
|
|
|
<h2 class="new-project-popup__info-panel-container__main-label-text">Create a Project</h2>
|
2018-11-28 16:20:23 +00:00
|
|
|
<img src="@/../static/images/dashboard/CreateNewProject.png" alt="">
|
2018-11-14 14:00:01 +00:00
|
|
|
</div>
|
2018-11-19 15:32:50 +00:00
|
|
|
<div class="new-project-popup__form-container">
|
2018-12-18 14:43:23 +00:00
|
|
|
<HeaderedInput
|
|
|
|
label="Project Name"
|
2018-11-14 14:00:01 +00:00
|
|
|
additionalLabel="Up To 20 Characters"
|
2018-11-28 16:20:23 +00:00
|
|
|
placeholder="Enter Project Name"
|
|
|
|
class="full-input"
|
|
|
|
width="100%"
|
2018-11-27 13:14:10 +00:00
|
|
|
:error="nameError"
|
2018-11-14 14:00:01 +00:00
|
|
|
@setData="setProjectName">
|
|
|
|
</HeaderedInput>
|
2018-12-18 14:43:23 +00:00
|
|
|
<HeaderedInput
|
|
|
|
label="Description"
|
2018-11-28 16:20:23 +00:00
|
|
|
placeholder="Enter Project Description"
|
2019-01-31 12:23:04 +00:00
|
|
|
additional-label="Optional"
|
2018-11-28 16:20:23 +00:00
|
|
|
class="full-input"
|
2018-11-14 14:00:01 +00:00
|
|
|
isMultiline
|
2018-11-28 16:20:23 +00:00
|
|
|
height="100px"
|
|
|
|
width="100%"
|
2018-11-27 13:14:10 +00:00
|
|
|
@setData="setProjectDescription">
|
2018-11-14 14:00:01 +00:00
|
|
|
</HeaderedInput>
|
2018-11-19 15:32:50 +00:00
|
|
|
<div class="new-project-popup__form-container__button-container">
|
2018-11-28 16:20:23 +00:00
|
|
|
<Button label="Cancel" width="205px" height="48px" :onPress="onCloseClick" isWhite/>
|
2019-03-29 10:46:42 +00:00
|
|
|
<Button label="Create Project" width="205px" height="48px" :onPress="createProjectClick"/>
|
2018-11-14 14:00:01 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2018-11-19 15:32:50 +00:00
|
|
|
<div class="new-project-popup__close-cross-container">
|
2018-11-14 14:00:01 +00:00
|
|
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" v-on:click="onCloseClick">
|
|
|
|
<path d="M15.7071 1.70711C16.0976 1.31658 16.0976 0.683417 15.7071 0.292893C15.3166 -0.0976311 14.6834 -0.0976311 14.2929 0.292893L15.7071 1.70711ZM0.292893 14.2929C-0.0976311 14.6834 -0.0976311 15.3166 0.292893 15.7071C0.683417 16.0976 1.31658 16.0976 1.70711 15.7071L0.292893 14.2929ZM1.70711 0.292893C1.31658 -0.0976311 0.683417 -0.0976311 0.292893 0.292893C-0.0976311 0.683417 -0.0976311 1.31658 0.292893 1.70711L1.70711 0.292893ZM14.2929 15.7071C14.6834 16.0976 15.3166 16.0976 15.7071 15.7071C16.0976 15.3166 16.0976 14.6834 15.7071 14.2929L14.2929 15.7071ZM14.2929 0.292893L0.292893 14.2929L1.70711 15.7071L15.7071 1.70711L14.2929 0.292893ZM0.292893 1.70711L14.2929 15.7071L15.7071 14.2929L1.70711 0.292893L0.292893 1.70711Z" fill="#384B65"/>
|
|
|
|
</svg>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2019-03-29 10:46:42 +00:00
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
|
|
|
import HeaderedInput from '@/components/common/HeaderedInput.vue';
|
|
|
|
import Checkbox from '@/components/common/Checkbox.vue';
|
|
|
|
import Button from '@/components/common/Button.vue';
|
|
|
|
import { APP_STATE_ACTIONS, NOTIFICATION_ACTIONS, PROJETS_ACTIONS } from '@/utils/constants/actionNames';
|
|
|
|
import { PM_ACTIONS } from '../../utils/constants/actionNames';
|
|
|
|
|
|
|
|
@Component(
|
|
|
|
{
|
|
|
|
beforeMount() {
|
|
|
|
this.$data.self = this as any;
|
2018-11-27 13:14:10 +00:00
|
|
|
},
|
2019-03-29 10:46:42 +00:00
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
projectName: '',
|
|
|
|
description: '',
|
|
|
|
nameError: '',
|
|
|
|
createdProjectId: '',
|
|
|
|
self: null,
|
2019-04-05 16:08:14 +01:00
|
|
|
isLoading: false,
|
2019-03-29 10:46:42 +00:00
|
|
|
};
|
2018-11-27 13:14:10 +00:00
|
|
|
},
|
2019-03-29 10:46:42 +00:00
|
|
|
methods: {
|
|
|
|
setProjectName: function (value: string): void {
|
|
|
|
this.$data.projectName = value;
|
|
|
|
this.$data.nameError = '';
|
|
|
|
},
|
|
|
|
setProjectDescription: function (value: string): void {
|
|
|
|
this.$data.description = value;
|
|
|
|
},
|
|
|
|
onCloseClick: function (): void {
|
|
|
|
this.$store.dispatch(APP_STATE_ACTIONS.TOGGLE_NEW_PROJ);
|
|
|
|
},
|
|
|
|
createProjectClick: async function (): Promise<any> {
|
2019-04-05 16:08:14 +01:00
|
|
|
if (this.$data.isLoading) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$data.isLoading = true;
|
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
if (!this.$data.self.validateProjectName(this.$data.projectName)) {
|
2019-04-05 16:08:14 +01:00
|
|
|
this.$data.isLoading = false;
|
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-01-11 10:26:18 +00:00
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
if (!await this.$data.self.createProject()) {
|
2019-04-05 16:08:14 +01:00
|
|
|
this.$data.isLoading = false;
|
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-11-27 13:14:10 +00:00
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
this.$data.self.selectCreatedProject();
|
2018-11-27 13:14:10 +00:00
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
this.$data.self.fetchProjectMembers();
|
2018-11-27 13:14:10 +00:00
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
this.$data.self.checkIfsFirstProject();
|
2019-04-05 16:08:14 +01:00
|
|
|
|
|
|
|
this.$data.isLoading = false;
|
2019-03-29 10:46:42 +00:00
|
|
|
},
|
|
|
|
validateProjectName: function(): boolean {
|
|
|
|
this.$data.projectName = this.$data.projectName.trim();
|
2018-11-28 09:43:43 +00:00
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
const rgx = /^[^/]+$/;
|
|
|
|
if (!rgx.test(this.$data.projectName)) {
|
|
|
|
this.$data.nameError = 'Name for project is invalid!';
|
2018-12-18 14:43:23 +00:00
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
2018-11-28 16:20:23 +00:00
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
if (this.$data.projectName.length > 20) {
|
|
|
|
this.$data.nameError = 'Name should be less than 21 character!';
|
2019-02-21 14:14:18 +00:00
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
2019-02-21 14:14:18 +00:00
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
return true;
|
|
|
|
},
|
|
|
|
createProject: async function(): Promise<boolean> {
|
|
|
|
let response: RequestResponse<Project> = await this.$store.dispatch(PROJETS_ACTIONS.CREATE, {
|
|
|
|
name: this.$data.projectName,
|
|
|
|
description: this.$data.description,
|
|
|
|
isTermsAccepted: this.$data.isTermsAccepted
|
|
|
|
});
|
|
|
|
if (!response.isSuccess) {
|
|
|
|
this.$data.self.notifyError(response.errorMessage);
|
2019-02-21 14:14:18 +00:00
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.$data.createdProjectId = response.data.id;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
selectCreatedProject: function () {
|
|
|
|
this.$store.dispatch(PROJETS_ACTIONS.SELECT, this.$data.createdProjectId);
|
2019-02-21 14:14:18 +00:00
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
this.$store.dispatch(APP_STATE_ACTIONS.TOGGLE_NEW_PROJ);
|
|
|
|
},
|
|
|
|
checkIfsFirstProject: function() {
|
|
|
|
let isFirstProject = this.$store.state.projectsModule.projects.length === 1;
|
|
|
|
|
|
|
|
isFirstProject
|
|
|
|
? this.$store.dispatch(APP_STATE_ACTIONS.TOGGLE_SUCCESSFUL_PROJECT_CREATION_POPUP)
|
|
|
|
: this.$data.self.notifySuccess('Project created successfully!');
|
|
|
|
},
|
|
|
|
fetchProjectMembers: async function(): Promise<any> {
|
|
|
|
this.$store.dispatch(PM_ACTIONS.SET_SEARCH_QUERY, '');
|
|
|
|
|
|
|
|
const response: RequestResponse<TeamMemberModel[]> = await this.$store.dispatch(PM_ACTIONS.FETCH);
|
|
|
|
if (!response.isSuccess) {
|
|
|
|
this.$data.self.notifyError(response.errorMessage);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
notifyError(message: string) {
|
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, message);
|
|
|
|
},
|
|
|
|
notifySuccess(message: string) {
|
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.SUCCESS, message);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
HeaderedInput,
|
|
|
|
Checkbox,
|
|
|
|
Button
|
2018-11-14 14:00:01 +00:00
|
|
|
}
|
|
|
|
}
|
2019-03-29 10:46:42 +00:00
|
|
|
)
|
2018-11-14 14:00:01 +00:00
|
|
|
|
2019-03-29 10:46:42 +00:00
|
|
|
export default class NewProjectPopup extends Vue {
|
|
|
|
}
|
2018-11-14 14:00:01 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2018-11-19 15:32:50 +00:00
|
|
|
.new-project-popup-container {
|
2018-11-14 14:00:01 +00:00
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
background-color: rgba(134, 134, 148, 0.4);
|
2018-12-12 10:06:33 +00:00
|
|
|
z-index: 1121;
|
2018-11-14 14:00:01 +00:00
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
}
|
2018-11-28 16:20:23 +00:00
|
|
|
.input-container.full-input {
|
|
|
|
width: 100%;
|
|
|
|
}
|
2018-11-19 15:32:50 +00:00
|
|
|
.new-project-popup {
|
2018-11-28 16:20:23 +00:00
|
|
|
width: 100%;
|
|
|
|
max-width: 845px;
|
2019-01-28 18:20:33 +00:00
|
|
|
height: 400px;
|
2018-11-14 14:00:01 +00:00
|
|
|
background-color: #FFFFFF;
|
|
|
|
border-radius: 6px;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
align-items: center;
|
2018-11-28 16:20:23 +00:00
|
|
|
position: relative;
|
2018-11-14 14:00:01 +00:00
|
|
|
justify-content: center;
|
2018-11-28 16:20:23 +00:00
|
|
|
padding: 100px 100px 100px 80px;
|
2018-11-19 15:32:50 +00:00
|
|
|
|
|
|
|
&__info-panel-container {
|
2018-11-28 16:20:23 +00:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: flex-start;
|
|
|
|
align-items: center;
|
|
|
|
margin-right: 55px;
|
|
|
|
height: 535px;
|
2018-11-19 15:32:50 +00:00
|
|
|
|
|
|
|
&__main-label-text {
|
2019-03-26 16:38:35 +00:00
|
|
|
font-family: 'font_bold';
|
2018-11-28 16:20:23 +00:00
|
|
|
font-size: 32px;
|
|
|
|
line-height: 39px;
|
|
|
|
color: #384B65;
|
|
|
|
margin-bottom: 60px;
|
2019-01-28 18:20:33 +00:00
|
|
|
margin-top: 50px;
|
2018-11-19 15:32:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&__form-container {
|
2018-11-28 16:20:23 +00:00
|
|
|
width: 100%;
|
|
|
|
max-width: 520px;
|
2018-11-19 15:32:50 +00:00
|
|
|
|
|
|
|
&__button-container {
|
2018-11-28 16:20:23 +00:00
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: space-between;
|
|
|
|
align-items: center;
|
|
|
|
margin-top: 30px;
|
2018-11-19 15:32:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&__close-cross-container {
|
2019-03-29 10:46:42 +00:00
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
position: absolute;
|
|
|
|
right: 30px;
|
|
|
|
top: 40px;
|
|
|
|
height: 24px;
|
|
|
|
width: 24px;
|
|
|
|
cursor: pointer;
|
2019-01-30 13:18:07 +00:00
|
|
|
|
|
|
|
&:hover svg path {
|
2019-03-29 10:46:42 +00:00
|
|
|
fill: #2683FF;
|
2018-11-19 15:32:50 +00:00
|
|
|
}
|
2018-11-14 14:00:01 +00:00
|
|
|
}
|
|
|
|
}
|
2018-11-28 16:20:23 +00:00
|
|
|
|
|
|
|
@media screen and (max-width: 720px) {
|
|
|
|
.new-project-popup {
|
|
|
|
|
|
|
|
&__info-panel-container {
|
|
|
|
display: none;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
&__form-container {
|
|
|
|
|
|
|
|
&__button-container {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-11-14 14:00:01 +00:00
|
|
|
</style>
|