2021-01-22 01:19:00 +08:00
|
|
|
<template>
|
2021-02-05 14:51:51 +08:00
|
|
|
<v-stepper v-model="step">
|
|
|
|
<v-stepper-header>
|
2021-06-06 17:04:26 +08:00
|
|
|
<v-stepper-step step="1" :complete="step > 1">
|
|
|
|
{{ $t('project.new.step1.title') }}
|
|
|
|
</v-stepper-step>
|
2021-02-05 14:51:51 +08:00
|
|
|
<v-divider />
|
2021-06-06 17:04:26 +08:00
|
|
|
<v-stepper-step step="2" :complete="step > 2 && forms.step2" :rules="[() => noBasicSettingsError]">
|
|
|
|
{{ $t('project.new.step2.title') }}<small v-show="!noBasicSettingsError">Missing Information</small>
|
|
|
|
</v-stepper-step>
|
2021-02-05 14:51:51 +08:00
|
|
|
<v-divider />
|
2021-06-06 17:04:26 +08:00
|
|
|
<v-stepper-step step="3" :complete="step > 3">
|
|
|
|
{{ $t('project.new.step3.title') }}<small>{{ $t('project.new.step3.optional') }}</small>
|
|
|
|
</v-stepper-step>
|
2021-02-05 14:51:51 +08:00
|
|
|
<v-divider />
|
2021-06-06 17:04:26 +08:00
|
|
|
<v-stepper-step step="4" :complete="step > 4">
|
|
|
|
{{ $t('project.new.step4.title') }}<small>{{ $t('project.new.step4.optional') }}</small>
|
|
|
|
</v-stepper-step>
|
2021-02-05 14:51:51 +08:00
|
|
|
<v-divider />
|
2021-06-06 17:04:26 +08:00
|
|
|
<v-stepper-step step="5" :complete="!projectLoading">
|
|
|
|
{{ $t('project.new.step5.title') }}
|
|
|
|
</v-stepper-step>
|
2021-02-05 14:51:51 +08:00
|
|
|
</v-stepper-header>
|
|
|
|
<v-stepper-items>
|
|
|
|
<StepperStepContent :step="1" @back="$router.push('/')" @continue="step = 2">
|
|
|
|
<v-card class="mb-12 pa-1" min-height="200px">
|
|
|
|
<v-card-title v-if="$vuetify.breakpoint.smAndDown">
|
|
|
|
{{ $t('project.new.step1.title') }}
|
|
|
|
</v-card-title>
|
2021-02-11 19:48:52 +08:00
|
|
|
<!-- eslint-disable-next-line vue/no-v-html -->
|
2021-06-06 17:04:26 +08:00
|
|
|
<v-card-text v-html="$t('project.new.step1.text')" />
|
2021-02-05 14:51:51 +08:00
|
|
|
</v-card>
|
|
|
|
</StepperStepContent>
|
|
|
|
<StepperStepContent :step="2" :allow-continue="noBasicSettingsError" @back="step = 1" @continue="step = 3">
|
|
|
|
<v-card max-width="800" class="mx-auto">
|
|
|
|
<v-card-title v-if="$vuetify.breakpoint.smAndDown">
|
|
|
|
{{ $t('project.new.step2.title') }}
|
|
|
|
</v-card-title>
|
2021-02-06 03:50:18 +08:00
|
|
|
<v-form v-model="forms.step2">
|
2021-02-05 14:51:51 +08:00
|
|
|
<v-container>
|
|
|
|
<v-row justify="space-around">
|
|
|
|
<v-col cols="12" md="6">
|
|
|
|
<v-select
|
|
|
|
v-model="form.ownerId"
|
|
|
|
:items="projectOwners"
|
|
|
|
dense
|
|
|
|
filled
|
|
|
|
item-text="name"
|
|
|
|
item-value="userId"
|
2021-04-10 14:27:27 +08:00
|
|
|
:label="$t('project.new.step2.userSelect')"
|
|
|
|
:rules="[$util.$vc.require($t('project.new.step2.userSelect'))]"
|
2021-02-05 14:51:51 +08:00
|
|
|
:append-icon="createAsIcon"
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
<v-col cols="12" md="6">
|
|
|
|
<v-text-field
|
|
|
|
v-model.trim="form.name"
|
|
|
|
autofocus
|
|
|
|
dense
|
|
|
|
filled
|
2021-02-12 13:44:49 +08:00
|
|
|
:error-messages="nameErrors"
|
2021-04-10 14:27:27 +08:00
|
|
|
:label="$t('project.new.step2.projectName')"
|
|
|
|
:rules="[$util.$vc.require($t('project.new.step2.projectName'))]"
|
2021-02-05 14:51:51 +08:00
|
|
|
append-icon="mdi-form-textbox"
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
<v-col cols="12" md="8">
|
|
|
|
<v-text-field
|
|
|
|
v-model.trim="form.description"
|
|
|
|
dense
|
|
|
|
filled
|
|
|
|
clearable
|
2021-04-10 14:27:27 +08:00
|
|
|
:label="$t('project.new.step2.projectSummary')"
|
|
|
|
:rules="[$util.$vc.require($t('project.new.step2.projectSummary')), $util.$vc.maxLength(validations.project.desc.max)]"
|
2021-02-05 14:51:51 +08:00
|
|
|
append-icon="mdi-card-text"
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
<v-col cols="12" md="4">
|
|
|
|
<v-select
|
|
|
|
v-model="form.category"
|
2021-03-18 13:25:52 +08:00
|
|
|
:prepend-inner-icon="categoryIcon"
|
2021-02-05 14:51:51 +08:00
|
|
|
:items="$store.getters.visibleCategories"
|
|
|
|
dense
|
|
|
|
filled
|
2021-04-10 14:27:27 +08:00
|
|
|
:label="$t('project.new.step2.projectCategory')"
|
2021-02-05 14:51:51 +08:00
|
|
|
item-text="title"
|
|
|
|
item-value="apiName"
|
2021-04-10 14:27:27 +08:00
|
|
|
:rules="[$util.$vc.require($t('project.new.step2.projectCategory'))]"
|
2021-02-05 14:51:51 +08:00
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-container>
|
|
|
|
</v-form>
|
|
|
|
</v-card>
|
|
|
|
</StepperStepContent>
|
|
|
|
<StepperStepContent :step="3" @back="step = 2" @continue="step = 4">
|
|
|
|
<v-card max-width="800" class="mx-auto">
|
|
|
|
<v-card-title v-if="$vuetify.breakpoint.smAndDown">
|
|
|
|
{{ $t('project.new.step3.title') }}
|
|
|
|
</v-card-title>
|
2021-02-06 03:50:18 +08:00
|
|
|
<v-container>
|
|
|
|
<div class="text-h6 pt-1">
|
2021-06-06 17:04:26 +08:00
|
|
|
<v-icon color="info" large style="transform: rotate(-45deg)" class="mb-1"> mdi-link </v-icon>
|
2021-02-06 03:50:18 +08:00
|
|
|
{{ $t('project.new.step3.links') }}
|
|
|
|
</div>
|
|
|
|
<v-divider class="mb-2" />
|
|
|
|
<v-row>
|
|
|
|
<v-col cols="12">
|
|
|
|
<v-text-field
|
2021-03-18 14:10:12 +08:00
|
|
|
v-model.trim="form.settings.homepage"
|
2021-02-06 03:50:18 +08:00
|
|
|
dense
|
|
|
|
hide-details
|
|
|
|
filled
|
|
|
|
:label="$t('project.new.step3.homepage')"
|
2021-03-20 08:00:38 +08:00
|
|
|
:rules="[$util.$vc.url]"
|
2021-02-06 03:50:18 +08:00
|
|
|
append-icon="mdi-home-search"
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
<v-col cols="12">
|
|
|
|
<v-text-field
|
2021-03-18 14:10:12 +08:00
|
|
|
v-model.trim="form.settings.issues"
|
2021-02-06 03:50:18 +08:00
|
|
|
dense
|
|
|
|
hide-details
|
|
|
|
filled
|
|
|
|
:label="$t('project.new.step3.issues')"
|
2021-03-20 08:00:38 +08:00
|
|
|
:rules="[$util.$vc.url]"
|
2021-02-06 03:50:18 +08:00
|
|
|
append-icon="mdi-bug"
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
<v-col cols="12">
|
|
|
|
<v-text-field
|
2021-03-18 14:10:12 +08:00
|
|
|
v-model.trim="form.settings.source"
|
2021-02-06 03:50:18 +08:00
|
|
|
dense
|
|
|
|
hide-details
|
|
|
|
filled
|
|
|
|
:label="$t('project.new.step3.source')"
|
2021-03-20 08:00:38 +08:00
|
|
|
:rules="[$util.$vc.url]"
|
2021-02-06 03:50:18 +08:00
|
|
|
append-icon="mdi-source-branch"
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
<v-col cols="12">
|
|
|
|
<v-text-field
|
2021-03-18 14:10:12 +08:00
|
|
|
v-model.trim="form.settings.support"
|
2021-02-06 03:50:18 +08:00
|
|
|
dense
|
|
|
|
hide-details
|
|
|
|
filled
|
|
|
|
:label="$t('project.new.step3.support')"
|
2021-03-20 08:00:38 +08:00
|
|
|
:rules="[$util.$vc.url]"
|
2021-02-06 03:50:18 +08:00
|
|
|
append-icon="mdi-face-agent"
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
<div class="text-h6 pt-5">
|
2021-06-06 17:04:26 +08:00
|
|
|
<v-icon color="info" large class="mb-1"> mdi-license </v-icon>
|
2021-04-10 14:27:27 +08:00
|
|
|
{{ $t('project.new.step3.license') }}
|
2021-02-06 03:50:18 +08:00
|
|
|
</div>
|
|
|
|
<v-divider class="mb-2" />
|
|
|
|
<v-row>
|
|
|
|
<v-col cols="12" :md="isCustomLicense ? 4 : 6">
|
|
|
|
<v-select
|
2021-03-18 14:10:12 +08:00
|
|
|
v-model="form.settings.license.type"
|
2021-02-06 03:50:18 +08:00
|
|
|
dense
|
|
|
|
hide-details
|
|
|
|
filled
|
|
|
|
clearable
|
2021-04-10 14:27:27 +08:00
|
|
|
:items="licenses"
|
2021-02-06 03:50:18 +08:00
|
|
|
:label="$t('project.new.step3.type')"
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
<v-col v-if="isCustomLicense" cols="12" md="8">
|
2021-03-18 14:32:23 +08:00
|
|
|
<v-text-field v-model.trim="form.settings.license.name" dense hide-details filled :label="$t('project.new.step3.customName')" />
|
2021-02-06 03:50:18 +08:00
|
|
|
</v-col>
|
|
|
|
<v-col cols="12" :md="isCustomLicense ? 12 : 6">
|
2021-03-20 08:00:38 +08:00
|
|
|
<v-text-field
|
|
|
|
v-model.trim="form.settings.license.url"
|
|
|
|
dense
|
|
|
|
hide-details
|
|
|
|
filled
|
|
|
|
:label="$t('project.new.step3.url')"
|
|
|
|
:rules="[$util.$vc.url]"
|
|
|
|
/>
|
2021-02-06 03:50:18 +08:00
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
<div class="text-h6 pt-5">
|
2021-06-06 17:04:26 +08:00
|
|
|
<v-icon color="info" large class="mb-1"> mdi-cloud-search </v-icon>
|
2021-02-06 03:50:18 +08:00
|
|
|
{{ $t('project.new.step3.seo') }}
|
|
|
|
</div>
|
|
|
|
<v-divider class="mb-2" />
|
|
|
|
<v-row>
|
|
|
|
<v-col cols="12">
|
|
|
|
<v-combobox
|
2021-03-18 14:10:12 +08:00
|
|
|
v-model="form.settings.keywords"
|
2021-02-06 03:50:18 +08:00
|
|
|
small-chips
|
|
|
|
deletable-chips
|
|
|
|
multiple
|
|
|
|
dense
|
|
|
|
hide-details
|
|
|
|
filled
|
2021-03-20 08:00:38 +08:00
|
|
|
clearable
|
2021-02-06 03:50:18 +08:00
|
|
|
:delimiters="[' ', ',', '.']"
|
|
|
|
:label="$t('project.new.step3.keywords')"
|
|
|
|
append-icon="mdi-file-word-box"
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
</v-container>
|
2021-02-05 14:51:51 +08:00
|
|
|
</v-card>
|
|
|
|
</StepperStepContent>
|
2021-02-06 03:50:18 +08:00
|
|
|
<StepperStepContent
|
|
|
|
:step="4"
|
|
|
|
@back="step = 3"
|
|
|
|
@continue="
|
|
|
|
step = 5;
|
|
|
|
createProject();
|
|
|
|
"
|
|
|
|
>
|
2021-02-05 14:51:51 +08:00
|
|
|
<v-tabs v-model="spigotConvertTab" fixed-tabs>
|
2021-04-11 09:01:23 +08:00
|
|
|
<v-tab v-text="$t('project.new.step4.convert')" />
|
|
|
|
<v-tab :disabled="!converter.markdown" v-text="$t('project.new.step4.preview')" />
|
|
|
|
<v-tab v-text="$t('project.new.step4.tutorial')" />
|
2021-02-05 14:51:51 +08:00
|
|
|
</v-tabs>
|
|
|
|
<v-tabs-items v-model="spigotConvertTab">
|
2021-04-10 14:27:27 +08:00
|
|
|
<v-tab-item>
|
|
|
|
<v-card-text>
|
|
|
|
<v-textarea v-model="converter.bbCode" hide-details dense :rows="6" filled :label="$t('project.new.step4.convertLabels.bbCode')" />
|
|
|
|
<div>
|
|
|
|
<v-btn block color="primary" class="my-3" :loading="converter.loading" @click="convertBBCode">
|
2021-06-06 17:04:26 +08:00
|
|
|
<v-icon left large> mdi-chevron-double-down </v-icon>
|
2021-04-10 14:27:27 +08:00
|
|
|
{{ $t('project.new.step4.convert') }}
|
2021-06-06 17:04:26 +08:00
|
|
|
<v-icon right large> mdi-chevron-double-down </v-icon>
|
2021-04-10 14:27:27 +08:00
|
|
|
</v-btn>
|
|
|
|
</div>
|
|
|
|
<v-textarea
|
|
|
|
v-model="converter.markdown"
|
|
|
|
hide-details
|
|
|
|
dense
|
|
|
|
:rows="6"
|
|
|
|
filled
|
|
|
|
:label="$t('project.new.step4.convertLabels.output')"
|
|
|
|
/>
|
|
|
|
</v-card-text>
|
|
|
|
</v-tab-item>
|
2021-04-10 17:21:58 +08:00
|
|
|
<v-tab-item>
|
2021-04-11 09:01:23 +08:00
|
|
|
<v-card-text>
|
|
|
|
<v-btn block color="primary" class="my-2" :disabled="form.pageContent === converter.markdown" @click="saveAsHomePage">
|
2021-06-06 17:04:26 +08:00
|
|
|
<v-icon left> mdi-content-save </v-icon>
|
2021-04-11 09:01:23 +08:00
|
|
|
{{ $t('project.new.step4.saveAsHomePage') }}
|
|
|
|
</v-btn>
|
|
|
|
<Markdown :raw="converter.markdown" />
|
|
|
|
</v-card-text>
|
2021-04-10 17:21:58 +08:00
|
|
|
</v-tab-item>
|
2021-04-10 14:27:27 +08:00
|
|
|
<v-tab-item>
|
|
|
|
<v-card-text class="text-center">
|
|
|
|
{{ $t('project.new.step4.tutorialInstructions.line1') }}<br />
|
|
|
|
{{ $t('project.new.step4.tutorialInstructions.line2') }}<br />
|
|
|
|
<img src="https://i.imgur.com/8CyLMf3.png" alt="Edit Project" /><br />
|
|
|
|
{{ $t('project.new.step4.tutorialInstructions.line3') }}<br />
|
|
|
|
<img src="https://i.imgur.com/FLVIuQK.png" width="425" height="198" alt="Show BBCode" /><br />
|
|
|
|
{{ $t('project.new.step4.tutorialInstructions.line4') }}<br />
|
|
|
|
</v-card-text>
|
|
|
|
</v-tab-item>
|
2021-02-05 14:51:51 +08:00
|
|
|
</v-tabs-items>
|
|
|
|
</StepperStepContent>
|
|
|
|
<StepperStepContent :step="5" hide-buttons>
|
|
|
|
<v-card>
|
|
|
|
<v-card-text class="text-center">
|
2021-06-06 17:04:26 +08:00
|
|
|
<v-progress-circular v-if="projectLoading" indeterminate color="red" size="50" />
|
|
|
|
<div v-if="!projectError" class="text-h5 mt-2">
|
|
|
|
{{ $t('project.new.step5.text') }}
|
|
|
|
</div>
|
2021-02-06 03:50:18 +08:00
|
|
|
<template v-else>
|
2021-06-06 17:04:26 +08:00
|
|
|
<div class="text-h5 mt-2">
|
|
|
|
{{ $t('project.new.error.create') }}
|
|
|
|
</div>
|
|
|
|
<v-btn @click="retry"> Retry </v-btn>
|
2021-02-06 03:50:18 +08:00
|
|
|
</template>
|
2021-02-05 14:51:51 +08:00
|
|
|
</v-card-text>
|
|
|
|
</v-card>
|
|
|
|
</StepperStepContent>
|
|
|
|
</v-stepper-items>
|
2021-01-31 01:27:36 +08:00
|
|
|
</v-stepper>
|
2021-01-22 01:19:00 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-03-21 10:06:09 +08:00
|
|
|
import { Component, Watch } from 'nuxt-property-decorator';
|
2021-02-05 14:51:51 +08:00
|
|
|
import { Context } from '@nuxt/types';
|
2021-03-18 14:10:12 +08:00
|
|
|
import { ProjectOwner, ProjectSettingsForm } from 'hangar-internal';
|
2021-02-12 13:44:49 +08:00
|
|
|
import { AxiosError } from 'axios';
|
2021-02-13 14:36:53 +08:00
|
|
|
import { TranslateResult } from 'vue-i18n';
|
2021-02-05 14:51:51 +08:00
|
|
|
import StepperStepContent from '~/components/steppers/StepperStepContent.vue';
|
|
|
|
import { RootState } from '~/store';
|
|
|
|
import { ProjectCategory } from '~/types/enums';
|
2021-03-21 10:06:09 +08:00
|
|
|
import { HangarComponent } from '~/components/mixins';
|
2021-03-22 13:03:41 +08:00
|
|
|
import { LoggedIn } from '~/utils/perms';
|
2021-04-10 17:21:58 +08:00
|
|
|
import Markdown from '~/components/markdown/Markdown.vue';
|
2021-02-05 14:51:51 +08:00
|
|
|
|
2021-03-18 14:10:12 +08:00
|
|
|
interface NewProjectForm extends ProjectSettingsForm {
|
2021-02-05 14:51:51 +08:00
|
|
|
ownerId: ProjectOwner['userId'];
|
|
|
|
name: string;
|
|
|
|
pageContent: string | null;
|
|
|
|
}
|
2021-01-31 10:00:11 +08:00
|
|
|
|
2021-01-31 01:27:36 +08:00
|
|
|
@Component({
|
2021-02-05 14:51:51 +08:00
|
|
|
components: {
|
2021-04-10 17:21:58 +08:00
|
|
|
Markdown,
|
2021-02-05 14:51:51 +08:00
|
|
|
StepperStepContent,
|
|
|
|
},
|
2021-01-31 01:27:36 +08:00
|
|
|
})
|
2021-03-22 13:03:41 +08:00
|
|
|
@LoggedIn
|
2021-03-21 10:06:09 +08:00
|
|
|
export default class NewProjectPage extends HangarComponent {
|
2021-01-31 01:27:36 +08:00
|
|
|
step = 1;
|
|
|
|
spigotConvertTab = 0;
|
2021-02-06 03:50:18 +08:00
|
|
|
projectLoading = true;
|
|
|
|
projectError = false;
|
|
|
|
projectOwners!: ProjectOwner[];
|
2021-04-10 14:27:27 +08:00
|
|
|
licenses!: string[];
|
2021-02-06 03:50:18 +08:00
|
|
|
error = null as string | null;
|
2021-03-18 14:10:12 +08:00
|
|
|
form: NewProjectForm = {
|
2021-02-05 14:51:51 +08:00
|
|
|
category: ProjectCategory.ADMIN_TOOLS,
|
2021-05-18 07:52:45 +08:00
|
|
|
settings: {
|
2021-03-18 14:10:12 +08:00
|
|
|
license: {} as ProjectSettingsForm['settings']['license'],
|
2021-04-09 11:00:27 +08:00
|
|
|
donation: {} as ProjectSettingsForm['settings']['donation'],
|
2021-03-18 14:10:12 +08:00
|
|
|
keywords: [],
|
2021-05-18 07:52:45 +08:00
|
|
|
} as unknown as ProjectSettingsForm['settings'],
|
2021-03-18 14:10:12 +08:00
|
|
|
} as NewProjectForm;
|
2021-02-05 14:51:51 +08:00
|
|
|
|
2021-02-13 14:36:53 +08:00
|
|
|
nameErrors: TranslateResult[] = [];
|
2021-02-12 13:44:49 +08:00
|
|
|
|
2021-04-10 14:27:27 +08:00
|
|
|
converter = {
|
|
|
|
bbCode: '',
|
|
|
|
markdown: '',
|
|
|
|
loading: false,
|
|
|
|
};
|
|
|
|
|
2021-02-05 14:51:51 +08:00
|
|
|
forms = {
|
2021-02-06 03:50:18 +08:00
|
|
|
step2: false,
|
2021-02-05 14:51:51 +08:00
|
|
|
};
|
|
|
|
|
2021-05-23 02:48:27 +08:00
|
|
|
head() {
|
|
|
|
return this.$seo.head('New Project', null, this.$route, null);
|
|
|
|
}
|
|
|
|
|
2021-02-05 14:51:51 +08:00
|
|
|
get categoryIcon() {
|
|
|
|
return (this.$store.state as RootState).projectCategories.get(this.form.category)?.icon;
|
|
|
|
}
|
2021-01-31 01:27:36 +08:00
|
|
|
|
2021-02-05 14:51:51 +08:00
|
|
|
get createAsIcon() {
|
|
|
|
return this.projectOwners.find((po) => po.userId === this.form.ownerId)?.isOrganization ? 'mdi-account-multiple' : 'mdi-account';
|
2021-01-31 01:27:36 +08:00
|
|
|
}
|
|
|
|
|
2021-02-05 14:51:51 +08:00
|
|
|
get isCustomLicense() {
|
2021-03-18 14:10:12 +08:00
|
|
|
return this.form.settings.license.type === '(custom)';
|
2021-01-31 01:27:36 +08:00
|
|
|
}
|
2021-01-22 01:19:00 +08:00
|
|
|
|
2021-02-05 14:51:51 +08:00
|
|
|
get noBasicSettingsError() {
|
2021-02-06 03:50:18 +08:00
|
|
|
return this.step !== 2 || this.forms.step2;
|
2021-02-05 14:51:51 +08:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:19:16 +08:00
|
|
|
async asyncData({ $api, $util }: Context) {
|
2021-04-10 14:27:27 +08:00
|
|
|
const data = await Promise.all([$api.requestInternal('projects/possibleOwners'), $api.requestInternal('data/licenses', false)]).catch(
|
2021-04-10 08:19:16 +08:00
|
|
|
$util.handlePageRequestError
|
|
|
|
);
|
|
|
|
if (typeof data === 'undefined') return;
|
2021-02-05 14:51:51 +08:00
|
|
|
return {
|
2021-04-10 14:27:27 +08:00
|
|
|
projectOwners: data[0],
|
|
|
|
licenses: data[1],
|
2021-02-05 14:51:51 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.form.ownerId = this.projectOwners.find((po) => !po.isOrganization)?.userId!;
|
|
|
|
}
|
2021-01-22 01:19:00 +08:00
|
|
|
|
2021-02-06 03:50:18 +08:00
|
|
|
createProject() {
|
|
|
|
this.$api
|
2021-02-06 15:45:13 +08:00
|
|
|
.requestInternal<string>('projects/create', true, 'post', this.form)
|
|
|
|
.then((url) => {
|
|
|
|
this.$router.push(url);
|
2021-02-06 03:50:18 +08:00
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.projectError = true;
|
2021-02-13 14:36:53 +08:00
|
|
|
this.$util.handleRequestError(err, 'project.new.error.create');
|
2021-02-06 03:50:18 +08:00
|
|
|
})
|
|
|
|
.finally(() => {
|
|
|
|
this.projectLoading = false;
|
|
|
|
});
|
|
|
|
}
|
2021-02-12 13:44:49 +08:00
|
|
|
|
2021-04-10 14:27:27 +08:00
|
|
|
convertBBCode() {
|
|
|
|
this.converter.loading = true;
|
|
|
|
this.$api
|
|
|
|
.requestInternal<string>('pages/convert-bbcode', false, 'post', {
|
|
|
|
content: this.converter.bbCode,
|
|
|
|
})
|
|
|
|
.then((markdown) => {
|
|
|
|
this.converter.markdown = markdown;
|
|
|
|
})
|
|
|
|
.catch(this.$util.handleRequestError)
|
|
|
|
.finally(() => {
|
|
|
|
this.converter.loading = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-04-11 09:01:23 +08:00
|
|
|
saveAsHomePage() {
|
|
|
|
this.$set(this.form, 'pageContent', this.converter.markdown);
|
|
|
|
}
|
|
|
|
|
2021-02-13 14:36:53 +08:00
|
|
|
retry() {
|
|
|
|
this.step = 1;
|
|
|
|
this.projectLoading = true;
|
|
|
|
this.projectError = false;
|
|
|
|
}
|
|
|
|
|
2021-02-12 13:44:49 +08:00
|
|
|
@Watch('form.name')
|
|
|
|
onProjectNameChange(val: string) {
|
|
|
|
if (!val) {
|
|
|
|
this.nameErrors = [];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.$api
|
|
|
|
.requestInternal('projects/validateName', false, 'get', {
|
|
|
|
userId: this.form.ownerId,
|
|
|
|
value: val,
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
this.nameErrors = [];
|
|
|
|
})
|
|
|
|
.catch((err: AxiosError) => {
|
|
|
|
this.nameErrors = [];
|
|
|
|
if (!err.response?.data.isHangarApiException) {
|
|
|
|
return this.$util.handleRequestError(err);
|
|
|
|
}
|
2021-02-13 14:36:53 +08:00
|
|
|
this.nameErrors.push(this.$t(err.response.data.message));
|
2021-02-12 13:44:49 +08:00
|
|
|
});
|
|
|
|
}
|
2021-01-31 01:27:36 +08:00
|
|
|
}
|
2021-02-05 14:51:51 +08:00
|
|
|
</script>
|