Feature: Add login-test for PinEdit UI

This commit is contained in:
winkidney
2019-12-07 17:14:15 +08:00
committed by Isaac Bythewood
parent 4f4a291925
commit 68638deeb3
3 changed files with 18 additions and 9 deletions

View File

@@ -68,6 +68,7 @@ export default {
(user) => { (user) => {
self.$emit('login.succeed', user); self.$emit('login.succeed', user);
self.$parent.close(); self.$parent.close();
window.location.reload();
}, },
(resp) => { (resp) => {
self.helper.markFieldsAsDanger(resp.data); self.helper.markFieldsAsDanger(resp.data);

View File

@@ -24,7 +24,7 @@
v-show="shouldShowEdit(item.id)" v-show="shouldShowEdit(item.id)"
:pin="item" :pin="item"
:currentUsername="editorMeta.user.meta.username" :currentUsername="editorMeta.user.meta.username"
:currentBoardId="editorMeta.currentBoard.id" :currentBoard="editorMeta.currentBoard"
v-on:pin-delete-succeed="reset" v-on:pin-delete-succeed="reset"
v-on:pin-remove-from-board-succeed="reset" v-on:pin-remove-from-board-succeed="reset"
></EditorUI> ></EditorUI>
@@ -150,6 +150,9 @@ export default {
}, },
methods: { methods: {
shouldShowEdit(id) { shouldShowEdit(id) {
if (!this.editorMeta.user.loggedIn) {
return false;
}
return this.editorMeta.currentEditId === id; return this.editorMeta.currentEditId === id;
}, },
showEditButtons(id) { showEditButtons(id) {

View File

@@ -1,7 +1,7 @@
<template> <template>
<div class="editor"> <div class="editor">
<div class="editor-buttons"> <div class="editor-buttons">
<span class="icon-container" v-if="inBoard" @click="removeFromBoard"> <span class="icon-container" v-if="inOwnedBoard" @click="removeFromBoard">
<b-icon <b-icon
type="is-light" type="is-light"
icon="minus-box" icon="minus-box"
@@ -39,12 +39,14 @@ import API from '../api';
export default { export default {
name: 'Editor', name: 'Editor',
props: { props: {
currentBoardId: { currentBoard: {
type: Number, type: Object,
default: null, default() {
return {};
},
}, },
currentUsername: { currentUsername: {
default: '', default: null,
type: String, type: String,
}, },
pin: { pin: {
@@ -58,8 +60,11 @@ export default {
isOwner() { isOwner() {
return this.pin.author === this.currentUsername; return this.pin.author === this.currentUsername;
}, },
inBoard() { inOwnedBoard() {
return this.currentBoardId !== null; return (
Object.values(this.currentBoard).length !== 0
&& this.currentBoard.submitter.username === this.currentUsername
);
}, },
}, },
methods: { methods: {
@@ -67,7 +72,7 @@ export default {
this.$buefy.dialog.confirm({ this.$buefy.dialog.confirm({
message: 'Remove Pin from Board?', message: 'Remove Pin from Board?',
onConfirm: () => { onConfirm: () => {
API.Board.removeFromBoard(this.currentBoardId, [this.pin.id]).then( API.Board.removeFromBoard(this.currentBoard.id, [this.pin.id]).then(
() => { () => {
this.$buefy.toast.open('Pin removed'); this.$buefy.toast.open('Pin removed');
this.$emit('pin-remove-from-board-succeed', this.pin.id); this.$emit('pin-remove-from-board-succeed', this.pin.id);