Remove obsolete code

I believe this is obsolete code. Could someone double-check?

@mattwr18 I tried to see any difference to `master` and I couldn't. Did
I miss sth.?

For context: During my work on https://github.com/Human-Connection/Human-Connection/pull/1517
the webapp was complaining about missing mutations when I changed the
dropdown.
This commit is contained in:
roschaefer 2019-09-09 23:13:48 +02:00
parent 3d419c1f21
commit a8222c5290
10 changed files with 11 additions and 106 deletions

View File

@ -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 {

View File

@ -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,
})
}

View File

@ -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()

View File

@ -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)

View File

@ -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', () => {

View File

@ -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!

View File

@ -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()

View File

@ -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()

View File

@ -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
},
}

View File

@ -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')
})
})