mirror of
https://github.com/leafOfTree/vim-vue-plugin.git
synced 2026-11-03 10:57:34 +08:00
Add tests and GitHub Actions
Replace the Travis tests, which used a separate repo and no longer ran, with tests in this repo. Each case in test/cases is indented as a whole and should be unchanged, with optional syntax, fold and tag checks. The cases are from the previous tests, plus script-setup.vue for <script setup> keywords and a sync check in oneline.vim. test/run.sh runs the cases with Vim in a pseudo terminal, as syntax in Ex mode isn't the same, and Neovim headless.
This commit is contained in:
27 files changed
+974
-19
No files matched your search
@@ -0,0 +1,151 @@
|
||||
<template>
|
||||
<div class="editor-page">
|
||||
<div class="container page">
|
||||
<div class="row">
|
||||
<div class="col-md-10 offset-md-1 col-xs-12">
|
||||
<RwvListErrors :errors="errors" />
|
||||
<form @submit.prevent="onPublish(article.slug)">
|
||||
<fieldset :disabled="inProgress">
|
||||
<fieldset class="form-group">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control form-control-lg"
|
||||
v-model="article.title"
|
||||
placeholder="Article Title"
|
||||
/>
|
||||
</fieldset>
|
||||
<fieldset class="form-group">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
v-model="article.description"
|
||||
placeholder="What's this article about?"
|
||||
/>
|
||||
</fieldset>
|
||||
<fieldset class="form-group">
|
||||
<textarea
|
||||
class="form-control"
|
||||
rows="8"
|
||||
v-model="article.body"
|
||||
placeholder="Write your article (in markdown)"
|
||||
>
|
||||
</textarea>
|
||||
</fieldset>
|
||||
<fieldset class="form-group">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
placeholder="Enter tags"
|
||||
v-model="tagInput"
|
||||
@keypress.enter.prevent="addTag(tagInput)"
|
||||
/>
|
||||
<div class="tag-list">
|
||||
<span
|
||||
class="tag-default tag-pill"
|
||||
v-for="(tag, index) of article.tagList"
|
||||
:key="tag + index"
|
||||
>
|
||||
<i class="ion-close-round" @click="removeTag(tag)"> </i>
|
||||
{{ tag }}
|
||||
</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
</fieldset>
|
||||
<button
|
||||
:disabled="inProgress"
|
||||
class="btn btn-lg pull-xs-right btn-primary"
|
||||
type="submit"
|
||||
>
|
||||
Publish Article
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from "vuex";
|
||||
import store from "@/store";
|
||||
import RwvListErrors from "@/components/ListErrors";
|
||||
import {
|
||||
ARTICLE_PUBLISH,
|
||||
ARTICLE_EDIT,
|
||||
FETCH_ARTICLE,
|
||||
ARTICLE_EDIT_ADD_TAG,
|
||||
ARTICLE_EDIT_REMOVE_TAG,
|
||||
ARTICLE_RESET_STATE
|
||||
} from "@/store/actions.type";
|
||||
|
||||
export default {
|
||||
name: "RwvArticleEdit",
|
||||
components: { RwvListErrors },
|
||||
props: {
|
||||
previousArticle: {
|
||||
type: Object,
|
||||
required: false
|
||||
}
|
||||
},
|
||||
async beforeRouteUpdate(to, from, next) {
|
||||
// Reset state if user goes from /editor/:id to /editor
|
||||
// The component is not recreated so we use to hook to reset the state.
|
||||
await store.dispatch(ARTICLE_RESET_STATE);
|
||||
return next();
|
||||
},
|
||||
async beforeRouteEnter(to, from, next) {
|
||||
// SO: https://github.com/vuejs/vue-router/issues/1034
|
||||
// If we arrive directly to this url, we need to fetch the article
|
||||
await store.dispatch(ARTICLE_RESET_STATE);
|
||||
if (to.params.slug !== undefined) {
|
||||
await store.dispatch(
|
||||
FETCH_ARTICLE,
|
||||
to.params.slug,
|
||||
to.params.previousArticle
|
||||
);
|
||||
}
|
||||
return next();
|
||||
},
|
||||
async beforeRouteLeave(to, from, next) {
|
||||
await store.dispatch(ARTICLE_RESET_STATE);
|
||||
next();
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tagInput: null,
|
||||
inProgress: false,
|
||||
errors: {}
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(["article"])
|
||||
},
|
||||
methods: {
|
||||
onPublish(slug) {
|
||||
let action = slug ? ARTICLE_EDIT : ARTICLE_PUBLISH;
|
||||
this.inProgress = true;
|
||||
this.$store
|
||||
.dispatch(action)
|
||||
.then(({ data }) => {
|
||||
this.inProgress = false;
|
||||
this.$router.push({
|
||||
name: "article",
|
||||
params: { slug: data.article.slug }
|
||||
});
|
||||
})
|
||||
.catch(({ response }) => {
|
||||
this.inProgress = false;
|
||||
this.errors = response.data.errors;
|
||||
});
|
||||
},
|
||||
removeTag(tag) {
|
||||
this.$store.dispatch(ARTICLE_EDIT_REMOVE_TAG, tag);
|
||||
},
|
||||
addTag(tag) {
|
||||
this.$store.dispatch(ARTICLE_EDIT_ADD_TAG, tag);
|
||||
this.tagInput = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in new issue
Block a user