mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge pull request #1540 from Human-Connection/remove_editor_store
Remove obsolete code
This commit is contained in:
commit
1fda99e198
@ -58,7 +58,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters, mapMutations } from 'vuex'
|
||||
import { mapGetters } from 'vuex'
|
||||
import HcUser from '~/components/User/User'
|
||||
import ContentMenu from '~/components/ContentMenu'
|
||||
import ContentViewer from '~/components/Editor/ContentViewer'
|
||||
@ -126,15 +126,11 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
...mapMutations({
|
||||
setEditPending: 'editor/SET_EDIT_PENDING',
|
||||
}),
|
||||
isAuthor(id) {
|
||||
return this.user.id === id
|
||||
},
|
||||
editCommentMenu(showMenu) {
|
||||
this.openEditCommentMenu = showMenu
|
||||
this.setEditPending(showMenu)
|
||||
},
|
||||
async deleteCommentCallback() {
|
||||
try {
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
import { mount, createLocalVue } from '@vue/test-utils'
|
||||
import CommentForm from './CommentForm'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
import Vuex from 'vuex'
|
||||
import MutationObserver from 'mutation-observer'
|
||||
|
||||
global.MutationObserver = MutationObserver
|
||||
|
||||
const localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
localVue.use(Styleguide)
|
||||
|
||||
describe('CommentForm.vue', () => {
|
||||
@ -50,21 +48,11 @@ describe('CommentForm.vue', () => {
|
||||
})
|
||||
|
||||
describe('mount', () => {
|
||||
const getters = {
|
||||
'editor/placeholder': () => {
|
||||
return 'some cool placeholder'
|
||||
},
|
||||
'editor/editPending': () => false,
|
||||
}
|
||||
const store = new Vuex.Store({
|
||||
getters,
|
||||
})
|
||||
const Wrapper = () => {
|
||||
return mount(CommentForm, {
|
||||
mocks,
|
||||
localVue,
|
||||
propsData,
|
||||
store,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<ds-form v-show="!editPending" v-model="form" @submit="handleSubmit">
|
||||
<ds-form v-model="form" @submit="handleSubmit">
|
||||
<template slot-scope="{ errors }">
|
||||
<ds-card>
|
||||
<hc-editor
|
||||
@ -30,7 +30,6 @@
|
||||
|
||||
<script>
|
||||
import gql from 'graphql-tag'
|
||||
import { mapGetters } from 'vuex'
|
||||
import HcEditor from '~/components/Editor/Editor'
|
||||
import PostQuery from '~/graphql/PostQuery'
|
||||
import CommentMutations from '~/graphql/CommentMutations'
|
||||
@ -52,11 +51,6 @@ export default {
|
||||
users: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
editPending: 'editor/editPending',
|
||||
}),
|
||||
},
|
||||
methods: {
|
||||
updateEditorContent(value) {
|
||||
const content = value.replace(/<(?:.|\n)*?>/gm, '').trim()
|
||||
|
||||
@ -26,7 +26,6 @@
|
||||
<script>
|
||||
import gql from 'graphql-tag'
|
||||
import HcEditor from '~/components/Editor/Editor'
|
||||
import { mapMutations } from 'vuex'
|
||||
import CommentMutations from '~/graphql/CommentMutations.js'
|
||||
|
||||
export default {
|
||||
@ -52,9 +51,6 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
...mapMutations({
|
||||
setEditPending: 'editor/SET_EDIT_PENDING',
|
||||
}),
|
||||
updateEditorContent(value) {
|
||||
const sanitizedContent = value.replace(/<(?:.|\n)*?>/gm, '').trim()
|
||||
this.disabled = value === this.comment.content || sanitizedContent.length < 1
|
||||
@ -80,7 +76,6 @@ export default {
|
||||
this.$toast.success(this.$t('post.comment.updated'))
|
||||
this.disabled = false
|
||||
this.$emit('showEditCommentMenu', false)
|
||||
this.setEditPending(false)
|
||||
})
|
||||
.catch(err => {
|
||||
this.$toast.error(err.message)
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { mount, createLocalVue } from '@vue/test-utils'
|
||||
import Editor from './Editor'
|
||||
import Vuex from 'vuex'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
import MutationObserver from 'mutation-observer'
|
||||
import Vue from 'vue'
|
||||
@ -8,19 +7,14 @@ import Vue from 'vue'
|
||||
global.MutationObserver = MutationObserver
|
||||
|
||||
const localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
localVue.use(Styleguide)
|
||||
|
||||
describe('Editor.vue', () => {
|
||||
let wrapper
|
||||
let propsData
|
||||
let mocks
|
||||
let getters
|
||||
|
||||
const Wrapper = () => {
|
||||
const store = new Vuex.Store({
|
||||
getters,
|
||||
})
|
||||
return (wrapper = mount(Editor, {
|
||||
mocks,
|
||||
propsData,
|
||||
@ -29,19 +23,13 @@ describe('Editor.vue', () => {
|
||||
stubs: {
|
||||
transition: false,
|
||||
},
|
||||
store,
|
||||
}))
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
propsData = {}
|
||||
mocks = {
|
||||
$t: () => {},
|
||||
}
|
||||
getters = {
|
||||
'editor/placeholder': () => {
|
||||
return 'some cool placeholder'
|
||||
},
|
||||
$t: () => 'some cool placeholder',
|
||||
}
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
@ -64,12 +52,10 @@ describe('Editor.vue', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('uses the placeholder', () => {
|
||||
it('from the store', () => {
|
||||
expect(wrapper.vm.editor.extensions.options.placeholder.emptyNodeText).toEqual(
|
||||
'some cool placeholder',
|
||||
)
|
||||
})
|
||||
it('translates the placeholder', () => {
|
||||
expect(wrapper.vm.editor.extensions.options.placeholder.emptyNodeText).toEqual(
|
||||
'some cool placeholder',
|
||||
)
|
||||
})
|
||||
|
||||
describe('optional extensions', () => {
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
import { Editor, EditorContent } from 'tiptap'
|
||||
import { History } from 'tiptap-extensions'
|
||||
import linkify from 'linkify-it'
|
||||
@ -70,7 +69,9 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({ placeholder: 'editor/placeholder' }),
|
||||
placeholder() {
|
||||
return this.$t('editor.placeholder')
|
||||
},
|
||||
optionalExtensions() {
|
||||
const extensions = []
|
||||
// Don't change the following line. The functionallity is in danger!
|
||||
|
||||
@ -1,13 +1,10 @@
|
||||
import { mount, createLocalVue } from '@vue/test-utils'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
import Vuex from 'vuex'
|
||||
import VTooltip from 'v-tooltip'
|
||||
import LocaleSwitch from './LocaleSwitch.vue'
|
||||
import { mutations } from '~/store/editor'
|
||||
|
||||
const localVue = createLocalVue()
|
||||
|
||||
localVue.use(Vuex)
|
||||
localVue.use(Styleguide)
|
||||
localVue.use(VTooltip)
|
||||
|
||||
@ -46,13 +43,8 @@ describe('LocaleSwitch.vue', () => {
|
||||
})
|
||||
|
||||
describe('mount', () => {
|
||||
const store = new Vuex.Store({
|
||||
mutations: {
|
||||
'editor/SET_PLACEHOLDER_TEXT': mutations.SET_PLACEHOLDER_TEXT,
|
||||
},
|
||||
})
|
||||
const Wrapper = () => {
|
||||
return mount(LocaleSwitch, { mocks, localVue, store, computed })
|
||||
return mount(LocaleSwitch, { mocks, localVue, computed })
|
||||
}
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
|
||||
@ -36,7 +36,6 @@
|
||||
import Dropdown from '~/components/Dropdown'
|
||||
import find from 'lodash/find'
|
||||
import orderBy from 'lodash/orderBy'
|
||||
import { mapMutations } from 'vuex'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -66,11 +65,9 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
...mapMutations({ setPlaceholderText: 'editor/SET_PLACEHOLDER_TEXT' }),
|
||||
changeLanguage(locale, toggleMenu) {
|
||||
this.$i18n.set(locale)
|
||||
toggleMenu()
|
||||
this.setPlaceholderText(this.$t('editor.placeholder'))
|
||||
},
|
||||
matcher(locale) {
|
||||
return locale === this.$i18n.locale()
|
||||
|
||||
@ -1,24 +0,0 @@
|
||||
export const state = () => {
|
||||
return {
|
||||
placeholder: null,
|
||||
editPending: false,
|
||||
}
|
||||
}
|
||||
|
||||
export const getters = {
|
||||
placeholder(state) {
|
||||
return state.placeholder
|
||||
},
|
||||
editPending(state) {
|
||||
return state.editPending
|
||||
},
|
||||
}
|
||||
|
||||
export const mutations = {
|
||||
SET_PLACEHOLDER_TEXT(state, text) {
|
||||
state.placeholder = text
|
||||
},
|
||||
SET_EDIT_PENDING(state, boolean) {
|
||||
state.editPending = boolean
|
||||
},
|
||||
}
|
||||
@ -1,20 +0,0 @@
|
||||
import { getters, mutations } from './editor.js'
|
||||
|
||||
let state
|
||||
|
||||
describe('getters', () => {
|
||||
describe('placeholder', () => {
|
||||
it('return the value in state', () => {
|
||||
state = { placeholder: null }
|
||||
expect(getters.placeholder(state)).toBe(null)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('mutations', () => {
|
||||
it('SET_PLACEHOLDER_TEXT', () => {
|
||||
state = { placeholder: null }
|
||||
mutations.SET_PLACEHOLDER_TEXT(state, 'new placeholder')
|
||||
expect(getters.placeholder(state)).toBe('new placeholder')
|
||||
})
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user