storj/web/satellite/src/components/project/ProjectDetails.vue

354 lines
11 KiB
Vue
Raw Normal View History

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
<template>
2019-07-09 16:04:51 +01:00
<div>
<div class="project-details">
<h1 class="project-details__title">Project Details</h1>
2019-07-09 16:04:51 +01:00
<div class="project-details-info-container">
<div class="project-details-info-container__name-container">
<h2 class="project-details-info-container__name-container__title">Project Name</h2>
<h3 class="project-details-info-container__name-container__project-name">{{name}}</h3>
2019-07-09 16:04:51 +01:00
</div>
</div>
<div class="project-details-info-container">
<div class="project-details-info-container__description-container" v-if="!isEditing">
<div class="project-details-info-container__description-container__text">
<h2 class="project-details-info-container__description-container__text__title">Description</h2>
<h3 class="project-details-info-container__description-container__text__project-description">{{displayedDescription}}</h3>
2019-07-09 16:04:51 +01:00
</div>
<EditIcon
class="project-details-svg"
@click="toggleEditing"
/>
2019-07-09 16:04:51 +01:00
</div>
<div class="project-details-info-container__description-container--editing" v-if="isEditing">
<HeaderedInput
label="Description"
placeholder="Enter Description"
width="205%"
2019-07-09 16:04:51 +01:00
height="10vh"
is-multiline="true"
:init-value="storedDescription"
@setData="setNewDescription"
/>
2019-07-09 16:04:51 +01:00
<div class="project-details-info-container__description-container__buttons-area">
<VButton
label="Cancel"
width="180px"
height="48px"
:on-press="toggleEditing"
is-white="true"
/>
<VButton
label="Save"
width="180px"
height="48px"
:on-press="onSaveButtonClick"
/>
2019-07-09 16:04:51 +01:00
</div>
</div>
</div>
<div class="project-details-info-container">
<ProjectLimitsArea />
</div>
<p class="project-details__limits-increase-text">
To increase your limits please contact us at
<a
href="mailto:support@tardigrade.io"
class="project-details__limits-increase-text__link"
>
support@tardigrade.io
</a>
</p>
2019-07-09 16:04:51 +01:00
</div>
</div>
</template>
<script lang="ts">
2019-09-09 11:33:39 +01:00
import { Component, Vue } from 'vue-property-decorator';
2019-09-09 11:33:39 +01:00
import EmptyState from '@/components/common/EmptyStateArea.vue';
import HeaderedInput from '@/components/common/HeaderedInput.vue';
import VButton from '@/components/common/VButton.vue';
2019-09-09 11:33:39 +01:00
import DeleteProjectPopup from '@/components/project/DeleteProjectPopup.vue';
import ProjectLimitsArea from '@/components/project/ProjectLimitsArea.vue';
import EditIcon from '@/../static/images/project/edit.svg';
2019-09-09 11:33:39 +01:00
import { RouteConfig } from '@/router';
import { PROJECTS_ACTIONS } from '@/store/modules/projects';
import { UpdateProjectModel } from '@/types/projects';
import { APP_STATE_ACTIONS } from '@/utils/constants/actionNames';
import { SegmentEvent } from '@/utils/constants/analyticsEventNames';
import { LocalData } from '@/utils/localData';
2019-09-09 11:33:39 +01:00
@Component({
components: {
VButton,
2019-09-09 11:33:39 +01:00
HeaderedInput,
EmptyState,
DeleteProjectPopup,
EditIcon,
ProjectLimitsArea,
},
2019-09-09 11:33:39 +01:00
})
export default class ProjectDetailsArea extends Vue {
private isEditing: boolean = false;
private newDescription: string = '';
2019-09-09 11:33:39 +01:00
public async mounted(): Promise<void> {
try {
await this.$store.dispatch(PROJECTS_ACTIONS.FETCH);
this.$segment.track(SegmentEvent.PROJECT_VIEWED, {
project_id: this.$store.getters.selectedProject.id,
});
} catch (error) {
await this.$notify.error(error.message);
}
2019-09-09 11:33:39 +01:00
}
2019-09-09 11:33:39 +01:00
public get name(): string {
return this.$store.getters.selectedProject.name;
}
public get storedDescription(): string {
return this.$store.getters.selectedProject.description;
}
public get displayedDescription(): string {
2019-09-09 11:33:39 +01:00
return this.$store.getters.selectedProject.description ?
this.$store.getters.selectedProject.description :
'No description yet. Please enter some information about the project if any.';
}
2019-09-09 11:33:39 +01:00
public get isPopupShown(): boolean {
return this.$store.state.appStateModule.appState.isDeleteProjectPopupShown;
}
public setNewDescription(value: string): void {
this.newDescription = value;
}
2019-09-09 11:33:39 +01:00
public async onSaveButtonClick(): Promise<void> {
try {
await this.$store.dispatch(
PROJECTS_ACTIONS.UPDATE,
new UpdateProjectModel(this.$store.getters.selectedProject.id, this.newDescription),
2019-09-09 11:33:39 +01:00
);
LocalData.setSelectedProjectId(this.$store.getters.selectedProject.id);
} catch (error) {
await this.$notify.error(`Unable to update project description. ${error.message}`);
return;
}
2019-09-09 11:33:39 +01:00
this.toggleEditing();
await this.$notify.success('Project updated successfully!');
2019-09-09 11:33:39 +01:00
}
public toggleDeleteDialog(): void {
this.$store.dispatch(APP_STATE_ACTIONS.TOGGLE_DEL_PROJ);
}
public onMoreClick(): void {
this.$router.push(RouteConfig.UsageReport.path);
}
public toggleEditing(): void {
2019-09-09 11:33:39 +01:00
this.isEditing = !this.isEditing;
this.newDescription = this.storedDescription;
}
2019-09-09 11:33:39 +01:00
}
</script>
<style scoped lang="scss">
h1,
h2,
h3 {
margin-block-start: 0.5em;
margin-block-end: 0.5em;
}
2019-07-10 10:55:40 +01:00
.project-details {
position: relative;
overflow: hidden;
font-family: 'font_regular', sans-serif;
&__title {
font-family: 'font_bold', sans-serif;
font-size: 32px;
line-height: 39px;
color: #263549;
user-select: none;
margin: 0;
2019-07-10 10:55:40 +01:00
}
2019-07-10 10:55:40 +01:00
&__button-area {
margin-top: 3vh;
margin-bottom: 100px;
}
&__limits-increase-text {
font-family: 'font_regular', sans-serif;
font-size: 16px;
color: #afb7c1;
margin-top: 42px;
&__link {
text-decoration: underline;
color: #2683ff;
}
}
2019-07-10 10:55:40 +01:00
}
2019-07-10 10:55:40 +01:00
.project-details-info-container {
height: auto;
margin-top: 37px;
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: flex-start;
2019-07-10 10:55:40 +01:00
&__name-container {
min-height: 67px;
width: 100%;
border-radius: 6px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
padding: 28px;
background-color: #fff;
&__title {
font-size: 16px;
line-height: 21px;
color: rgba(56, 75, 101, 0.4);
user-select: none;
}
&__project-name {
font-size: 16px;
line-height: 21px;
color: #354049;
}
2019-07-10 10:55:40 +01:00
}
2019-07-10 10:55:40 +01:00
&__description-container {
min-height: 67px;
width: 100%;
border-radius: 6px;
display: flex;
2019-07-10 10:55:40 +01:00
height: auto;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: 28px;
background-color: #fff;
::-webkit-scrollbar,
::-webkit-scrollbar-track,
::-webkit-scrollbar-thumb {
margin-top: 0;
}
2019-07-10 10:55:40 +01:00
&__text {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
margin-right: 20px;
width: 100%;
&__title {
font-size: 16px;
line-height: 21px;
color: rgba(56, 75, 101, 0.4);
user-select: none;
}
&__project-description {
font-size: 16px;
line-height: 21px;
color: #354049;
2019-07-10 10:55:40 +01:00
width: 100%;
max-height: 25vh;
overflow-y: scroll;
word-break: break-word;
white-space: pre-line;
2019-07-10 10:55:40 +01:00
}
}
2019-07-10 10:55:40 +01:00
&--editing {
min-height: 67px;
width: 100%;
border-radius: 6px;
2019-07-10 10:55:40 +01:00
display: flex;
height: auto;
padding: 28px;
background-color: #fff;
2019-07-10 10:55:40 +01:00
flex-direction: column;
justify-content: center;
align-items: flex-start;
}
2019-07-10 10:55:40 +01:00
&__buttons-area {
margin-top: 2vh;
display: flex;
flex-direction: row;
align-items: center;
width: 380px;
justify-content: space-between;
}
.project-details-svg {
2019-07-10 10:55:40 +01:00
cursor: pointer;
min-width: 40px;
2019-07-10 10:55:40 +01:00
&:hover {
.project-details-svg__rect {
fill: #2683ff;
2019-07-10 10:55:40 +01:00
}
.project-details-svg__path {
fill: white;
2019-07-10 10:55:40 +01:00
}
}
}
}
2019-07-10 10:55:40 +01:00
&__portability-container {
min-height: 67px;
width: 100%;
border-radius: 6px;
display: flex;
height: auto;
flex-direction: row;
justify-content: space-between;
align-items: center;
padding: 28px;
background-color: #fff;
2019-07-10 10:55:40 +01:00
&__info {
display: flex;
flex-direction: row;
align-items: center;
2019-07-10 10:55:40 +01:00
&__text {
margin-left: 2vw;
}
}
2019-07-10 10:55:40 +01:00
&__buttons-area {
display: flex;
flex-direction: row;
align-items: center;
2019-07-10 10:55:40 +01:00
width: 380px;
justify-content: space-between;
}
}
}
</style>