mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-12 23:35:58 +00:00
frontend lint fixes
This commit is contained in:
parent
cfd0975b24
commit
5202763dd8
@ -23,14 +23,14 @@
|
||||
import HcImage from './Image'
|
||||
export default {
|
||||
components: {
|
||||
HcImage
|
||||
HcImage,
|
||||
},
|
||||
props: {
|
||||
badges: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
}
|
||||
}
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -14,8 +14,8 @@ describe('Category', () => {
|
||||
localVue,
|
||||
propsData: {
|
||||
icon,
|
||||
name
|
||||
}
|
||||
name,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ export default {
|
||||
name: 'HcCategory',
|
||||
props: {
|
||||
icon: { type: String, required: true },
|
||||
name: { type: String, default: '' }
|
||||
}
|
||||
name: { type: String, default: '' },
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { config, shallowMount, mount, createLocalVue } from '@vue/test-utils'
|
||||
import { config, shallowMount, createLocalVue } from '@vue/test-utils'
|
||||
import Comment from './Comment.vue'
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
|
||||
@ -12,8 +11,6 @@ localVue.use(Styleguide)
|
||||
config.stubs['no-ssr'] = '<span><slot /></span>'
|
||||
|
||||
describe('Comment.vue', () => {
|
||||
let wrapper
|
||||
let Wrapper
|
||||
let propsData
|
||||
let mocks
|
||||
let getters
|
||||
@ -21,20 +18,20 @@ describe('Comment.vue', () => {
|
||||
beforeEach(() => {
|
||||
propsData = {}
|
||||
mocks = {
|
||||
$t: jest.fn()
|
||||
$t: jest.fn(),
|
||||
}
|
||||
getters = {
|
||||
'auth/user': () => {
|
||||
return {}
|
||||
},
|
||||
'auth/isModerator': () => false
|
||||
'auth/isModerator': () => false,
|
||||
}
|
||||
})
|
||||
|
||||
describe('shallowMount', () => {
|
||||
const Wrapper = () => {
|
||||
const store = new Vuex.Store({
|
||||
getters
|
||||
getters,
|
||||
})
|
||||
return shallowMount(Comment, { store, propsData, mocks, localVue })
|
||||
}
|
||||
@ -43,7 +40,7 @@ describe('Comment.vue', () => {
|
||||
beforeEach(() => {
|
||||
propsData.comment = {
|
||||
id: '2',
|
||||
contentExcerpt: 'Hello I am a comment content'
|
||||
contentExcerpt: 'Hello I am a comment content',
|
||||
}
|
||||
})
|
||||
|
||||
@ -68,7 +65,6 @@ describe('Comment.vue', () => {
|
||||
})
|
||||
|
||||
it('translates a placeholder', () => {
|
||||
const wrapper = Wrapper()
|
||||
const calls = mocks.$t.mock.calls
|
||||
const expected = [['comment.content.unavailable-placeholder']]
|
||||
expect(calls).toEqual(expect.arrayContaining(expected))
|
||||
|
||||
@ -43,20 +43,20 @@ import ContentMenu from '~/components/ContentMenu'
|
||||
export default {
|
||||
components: {
|
||||
HcUser,
|
||||
ContentMenu
|
||||
ContentMenu,
|
||||
},
|
||||
props: {
|
||||
comment: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
user: 'auth/user',
|
||||
isModerator: 'auth/isModerator'
|
||||
isModerator: 'auth/isModerator',
|
||||
}),
|
||||
displaysComment() {
|
||||
return !this.unavailable || this.isModerator
|
||||
@ -64,12 +64,12 @@ export default {
|
||||
author() {
|
||||
if (this.deleted) return {}
|
||||
return this.comment.author || {}
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
isAuthor(id) {
|
||||
return this.user.id === id
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -48,7 +48,7 @@ import Dropdown from '~/components/Dropdown'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Dropdown
|
||||
Dropdown,
|
||||
},
|
||||
props: {
|
||||
placement: { type: String, default: 'top-end' },
|
||||
@ -59,8 +59,8 @@ export default {
|
||||
required: true,
|
||||
validator: value => {
|
||||
return value.match(/(contribution|comment|organization|user)/)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
routes() {
|
||||
@ -72,17 +72,17 @@ export default {
|
||||
path: this.$router.resolve({
|
||||
name: 'post-edit-id',
|
||||
params: {
|
||||
id: this.resource.id
|
||||
}
|
||||
id: this.resource.id,
|
||||
},
|
||||
}).href,
|
||||
icon: 'edit'
|
||||
icon: 'edit',
|
||||
})
|
||||
routes.push({
|
||||
name: this.$t(`post.delete.title`),
|
||||
callback: () => {
|
||||
this.openModal('delete')
|
||||
},
|
||||
icon: 'trash'
|
||||
icon: 'trash',
|
||||
})
|
||||
}
|
||||
if (this.isOwner && this.resourceType === 'comment') {
|
||||
@ -92,7 +92,7 @@ export default {
|
||||
/* eslint-disable-next-line no-console */
|
||||
console.log('EDIT COMMENT')
|
||||
},
|
||||
icon: 'edit'
|
||||
icon: 'edit',
|
||||
})
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ export default {
|
||||
callback: () => {
|
||||
this.openModal('report')
|
||||
},
|
||||
icon: 'flag'
|
||||
icon: 'flag',
|
||||
})
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ export default {
|
||||
callback: () => {
|
||||
this.openModal('disable')
|
||||
},
|
||||
icon: 'eye-slash'
|
||||
icon: 'eye-slash',
|
||||
})
|
||||
}
|
||||
|
||||
@ -120,14 +120,14 @@ export default {
|
||||
routes.push({
|
||||
name: this.$t(`settings.name`),
|
||||
path: '/settings',
|
||||
icon: 'edit'
|
||||
icon: 'edit',
|
||||
})
|
||||
}
|
||||
return routes
|
||||
},
|
||||
isModerator() {
|
||||
return this.$store.getters['auth/isModerator']
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
openItem(route, toggleMenu) {
|
||||
@ -143,11 +143,11 @@ export default {
|
||||
name: dialog,
|
||||
data: {
|
||||
type: this.resourceType,
|
||||
resource: this.resource
|
||||
}
|
||||
resource: this.resource,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -53,26 +53,26 @@ import HcEditor from '~/components/Editor'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcEditor
|
||||
HcEditor,
|
||||
},
|
||||
props: {
|
||||
contribution: { type: Object, default: () => {} }
|
||||
contribution: { type: Object, default: () => {} },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
title: '',
|
||||
content: ''
|
||||
content: '',
|
||||
},
|
||||
formSchema: {
|
||||
title: { required: true, min: 3, max: 64 },
|
||||
content: { required: true, min: 3 }
|
||||
content: { required: true, min: 3 },
|
||||
},
|
||||
id: null,
|
||||
loading: false,
|
||||
disabled: false,
|
||||
slug: null,
|
||||
users: []
|
||||
users: [],
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -86,8 +86,8 @@ export default {
|
||||
this.slug = contribution.slug
|
||||
this.form.content = contribution.content
|
||||
this.form.title = contribution.title
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
@ -96,14 +96,12 @@ export default {
|
||||
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: this.id
|
||||
? postMutations.UpdatePost
|
||||
: postMutations.CreatePost,
|
||||
mutation: this.id ? postMutations.UpdatePost : postMutations.CreatePost,
|
||||
variables: {
|
||||
id: this.id,
|
||||
title: this.form.title,
|
||||
content: this.form.content
|
||||
}
|
||||
content: this.form.content,
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
this.loading = false
|
||||
@ -114,7 +112,7 @@ export default {
|
||||
|
||||
this.$router.push({
|
||||
name: 'post-id-slug',
|
||||
params: { id: result.id, slug: result.slug }
|
||||
params: { id: result.id, slug: result.slug },
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
@ -126,7 +124,7 @@ export default {
|
||||
updateEditorContent(value) {
|
||||
// this.form.content = value
|
||||
this.$refs.contributionForm.update('content', value)
|
||||
}
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
User: {
|
||||
@ -140,9 +138,9 @@ export default {
|
||||
},
|
||||
result(result) {
|
||||
this.users = result.data.User
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -19,19 +19,19 @@
|
||||
import CountTo from 'vue-count-to'
|
||||
export default {
|
||||
components: {
|
||||
CountTo
|
||||
CountTo,
|
||||
},
|
||||
props: {
|
||||
startVal: { type: Number, default: 0 },
|
||||
endVal: { type: Number, required: true },
|
||||
duration: { type: Number, default: 3000 },
|
||||
autoplay: { type: Boolean, default: true },
|
||||
separator: { type: String, default: '.' }
|
||||
separator: { type: String, default: '.' },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
lastEndVal: null,
|
||||
isReady: false
|
||||
isReady: false,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -39,12 +39,12 @@ export default {
|
||||
if (this.isReady && this.startVal === 0 && !this.lastEndVal) {
|
||||
this.lastEndVal = this.endVal
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
setTimeout(() => {
|
||||
this.isReady = true
|
||||
}, 500)
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -30,8 +30,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
let mouseEnterTimer = null
|
||||
let mouseLeaveTimer = null
|
||||
|
||||
@ -39,17 +37,17 @@ export default {
|
||||
props: {
|
||||
placement: { type: String, default: 'bottom-end' },
|
||||
disabled: { type: Boolean, default: false },
|
||||
offset: { type: [String, Number], default: '16' }
|
||||
offset: { type: [String, Number], default: '16' },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isPopoverOpen: false
|
||||
isPopoverOpen: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isOpen() {
|
||||
return this.isPopoverOpen
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
isPopoverOpen: {
|
||||
@ -59,19 +57,15 @@ export default {
|
||||
if (isOpen) {
|
||||
this.$nextTick(() => {
|
||||
setTimeout(() => {
|
||||
document
|
||||
.getElementsByTagName('body')[0]
|
||||
.classList.add('dropdown-open')
|
||||
document.getElementsByTagName('body')[0].classList.add('dropdown-open')
|
||||
}, 20)
|
||||
})
|
||||
} else {
|
||||
document
|
||||
.getElementsByTagName('body')[0]
|
||||
.classList.remove('dropdown-open')
|
||||
document.getElementsByTagName('body')[0].classList.remove('dropdown-open')
|
||||
}
|
||||
} catch (err) {}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
clearTimeout(mouseEnterTimer)
|
||||
@ -128,7 +122,7 @@ export default {
|
||||
clearTimeouts() {
|
||||
clearTimeout(mouseEnterTimer)
|
||||
clearTimeout(mouseLeaveTimer)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -166,12 +166,7 @@ import linkify from 'linkify-it'
|
||||
import stringHash from 'string-hash'
|
||||
import Fuse from 'fuse.js'
|
||||
import tippy from 'tippy.js'
|
||||
import {
|
||||
Editor,
|
||||
EditorContent,
|
||||
EditorFloatingMenu,
|
||||
EditorMenuBubble
|
||||
} from 'tiptap'
|
||||
import { Editor, EditorContent, EditorFloatingMenu, EditorMenuBubble } from 'tiptap'
|
||||
import EventHandler from './plugins/eventHandler.js'
|
||||
import {
|
||||
Heading,
|
||||
@ -187,7 +182,7 @@ import {
|
||||
Strike,
|
||||
Underline,
|
||||
Link,
|
||||
History
|
||||
History,
|
||||
} from 'tiptap-extensions'
|
||||
import Mention from './nodes/Mention.js'
|
||||
|
||||
@ -197,12 +192,12 @@ export default {
|
||||
components: {
|
||||
EditorContent,
|
||||
EditorFloatingMenu,
|
||||
EditorMenuBubble
|
||||
EditorMenuBubble,
|
||||
},
|
||||
props: {
|
||||
users: { type: Array, default: () => [] },
|
||||
value: { type: String, default: '' },
|
||||
doc: { type: Object, default: () => {} }
|
||||
doc: { type: Object, default: () => {} },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -227,7 +222,7 @@ export default {
|
||||
new ListItem(),
|
||||
new Placeholder({
|
||||
emptyNodeClass: 'is-empty',
|
||||
emptyNodeText: this.$t('editor.placeholder')
|
||||
emptyNodeText: this.$t('editor.placeholder'),
|
||||
}),
|
||||
new History(),
|
||||
new Mention({
|
||||
@ -290,16 +285,16 @@ export default {
|
||||
}
|
||||
const fuse = new Fuse(items, {
|
||||
threshold: 0.2,
|
||||
keys: ['slug']
|
||||
keys: ['slug'],
|
||||
})
|
||||
return fuse.search(query)
|
||||
}
|
||||
})
|
||||
},
|
||||
}),
|
||||
],
|
||||
onUpdate: e => {
|
||||
clearTimeout(throttleInputEvent)
|
||||
throttleInputEvent = setTimeout(() => this.onUpdate(e), 300)
|
||||
}
|
||||
},
|
||||
}),
|
||||
linkUrl: null,
|
||||
linkMenuIsActive: false,
|
||||
@ -308,7 +303,7 @@ export default {
|
||||
filteredUsers: [],
|
||||
navigatedUserIndex: 0,
|
||||
insertMention: () => {},
|
||||
observer: null
|
||||
observer: null,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -317,7 +312,7 @@ export default {
|
||||
},
|
||||
showSuggestions() {
|
||||
return this.query || this.hasResults
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
value: {
|
||||
@ -329,8 +324,8 @@ export default {
|
||||
}
|
||||
this.lastValueHash = contentHash
|
||||
this.editor.setContent(content)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.editor.destroy()
|
||||
@ -340,14 +335,12 @@ export default {
|
||||
// if it's the first item, navigate to the last one
|
||||
upHandler() {
|
||||
this.navigatedUserIndex =
|
||||
(this.navigatedUserIndex + this.filteredUsers.length - 1) %
|
||||
this.filteredUsers.length
|
||||
(this.navigatedUserIndex + this.filteredUsers.length - 1) % this.filteredUsers.length
|
||||
},
|
||||
// navigate to the next item
|
||||
// if it's the last item, navigate to the first one
|
||||
downHandler() {
|
||||
this.navigatedUserIndex =
|
||||
(this.navigatedUserIndex + 1) % this.filteredUsers.length
|
||||
this.navigatedUserIndex = (this.navigatedUserIndex + 1) % this.filteredUsers.length
|
||||
},
|
||||
enterHandler() {
|
||||
const user = this.filteredUsers[this.navigatedUserIndex]
|
||||
@ -363,8 +356,8 @@ export default {
|
||||
attrs: {
|
||||
// TODO: use router here
|
||||
url: `/profile/${user.id}`,
|
||||
label: user.slug
|
||||
}
|
||||
label: user.slug,
|
||||
},
|
||||
})
|
||||
this.editor.focus()
|
||||
},
|
||||
@ -384,7 +377,7 @@ export default {
|
||||
duration: [400, 200],
|
||||
showOnInit: true,
|
||||
arrow: true,
|
||||
arrowType: 'round'
|
||||
arrowType: 'round',
|
||||
})
|
||||
// we have to update tippy whenever the DOM is updated
|
||||
if (MutationObserver) {
|
||||
@ -394,7 +387,7 @@ export default {
|
||||
this.observer.observe(this.$refs.suggestions, {
|
||||
childList: true,
|
||||
subtree: true,
|
||||
characterData: true
|
||||
characterData: true,
|
||||
})
|
||||
}
|
||||
},
|
||||
@ -440,7 +433,7 @@ export default {
|
||||
if (links) {
|
||||
// add valid link
|
||||
command({
|
||||
href: links.pop().url
|
||||
href: links.pop().url,
|
||||
})
|
||||
this.hideLinkMenu()
|
||||
this.editor.focus()
|
||||
@ -451,8 +444,8 @@ export default {
|
||||
},
|
||||
clear() {
|
||||
this.editor.clearContent(true)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
import { Node } from 'tiptap'
|
||||
import { replaceText } from 'tiptap-commands'
|
||||
import { Mention as TipTapMention } from 'tiptap-extensions'
|
||||
|
||||
export default class Mention extends TipTapMention {
|
||||
@ -8,7 +6,7 @@ export default class Mention extends TipTapMention {
|
||||
|
||||
patchedSchema.attrs = {
|
||||
url: {},
|
||||
label: {}
|
||||
label: {},
|
||||
}
|
||||
patchedSchema.toDOM = node => {
|
||||
return [
|
||||
@ -16,9 +14,9 @@ export default class Mention extends TipTapMention {
|
||||
{
|
||||
class: this.options.mentionClass,
|
||||
href: node.attrs.url,
|
||||
target: '_blank'
|
||||
target: '_blank',
|
||||
},
|
||||
`${this.options.matcher.char}${node.attrs.label}`
|
||||
`${this.options.matcher.char}${node.attrs.label}`,
|
||||
]
|
||||
}
|
||||
patchedSchema.parseDOM = [
|
||||
|
||||
@ -18,10 +18,7 @@ export default class EventHandler extends Extension {
|
||||
// remove all tags with "space only"
|
||||
.replace(/<[a-z-]+>[\s]+<\/[a-z-]+>/gim, '')
|
||||
// remove all iframes
|
||||
.replace(
|
||||
/(<iframe(?!.*?src=(['"]).*?\2)[^>]*)(>)[^>]*\/*>/gim,
|
||||
''
|
||||
)
|
||||
.replace(/(<iframe(?!.*?src=(['"]).*?\2)[^>]*)(>)[^>]*\/*>/gim, '')
|
||||
.replace(/[\n]{3,}/gim, '\n\n')
|
||||
.replace(/(\r\n|\n\r|\r|\n)/g, '<br>$1')
|
||||
|
||||
@ -29,22 +26,16 @@ export default class EventHandler extends Extension {
|
||||
// limit linebreaks to max 2 (equivalent to html "br" linebreak)
|
||||
.replace(/(<br ?\/?>\s*){2,}/gim, '<br>')
|
||||
// remove additional linebreaks after p tags
|
||||
.replace(
|
||||
/<\/(p|div|th|tr)>\s*(<br ?\/?>\s*)+\s*<(p|div|th|tr)>/gim,
|
||||
'</p><p>'
|
||||
)
|
||||
.replace(/<\/(p|div|th|tr)>\s*(<br ?\/?>\s*)+\s*<(p|div|th|tr)>/gim, '</p><p>')
|
||||
// remove additional linebreaks inside p tags
|
||||
.replace(
|
||||
/<[a-z-]+>(<[a-z-]+>)*\s*(<br ?\/?>\s*)+\s*(<\/[a-z-]+>)*<\/[a-z-]+>/gim,
|
||||
''
|
||||
)
|
||||
.replace(/<[a-z-]+>(<[a-z-]+>)*\s*(<br ?\/?>\s*)+\s*(<\/[a-z-]+>)*<\/[a-z-]+>/gim, '')
|
||||
// remove additional linebreaks when first child inside p tags
|
||||
.replace(/<p>(\s*<br ?\/?>\s*)+/gim, '<p>')
|
||||
// remove additional linebreaks when last child inside p tags
|
||||
.replace(/(\s*<br ?\/?>\s*)+<\/p>/gim, '</p>')
|
||||
// console.log('#### transformPastedHTML', html)
|
||||
return html
|
||||
}
|
||||
},
|
||||
// transformPasted(slice) {
|
||||
// // console.log('#### transformPasted', slice.content)
|
||||
// let content = []
|
||||
@ -76,8 +67,8 @@ export default class EventHandler extends Extension {
|
||||
// return slice
|
||||
// // return newSlice
|
||||
// }
|
||||
}
|
||||
})
|
||||
},
|
||||
}),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ describe('Editor.vue', () => {
|
||||
beforeEach(() => {
|
||||
propsData = {}
|
||||
mocks = {
|
||||
$t: () => {}
|
||||
$t: () => {},
|
||||
}
|
||||
})
|
||||
|
||||
@ -25,7 +25,7 @@ describe('Editor.vue', () => {
|
||||
propsData,
|
||||
localVue,
|
||||
sync: false,
|
||||
stubs: { transition: false }
|
||||
stubs: { transition: false },
|
||||
}))
|
||||
}
|
||||
|
||||
@ -40,9 +40,7 @@ describe('Editor.vue', () => {
|
||||
|
||||
it.skip('renders', () => {
|
||||
wrapper = Wrapper()
|
||||
expect(wrapper.find('.ProseMirror').text()).toContain(
|
||||
'I am a piece of text'
|
||||
)
|
||||
expect(wrapper.find('.ProseMirror').text()).toContain('I am a piece of text')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
class="hc-empty-icon"
|
||||
style="margin-bottom: 5px"
|
||||
alt="Empty"
|
||||
/><br>
|
||||
><br>
|
||||
<ds-text
|
||||
v-show="message"
|
||||
class="hc-empty-message"
|
||||
@ -36,28 +36,28 @@ export default {
|
||||
required: true,
|
||||
validator: value => {
|
||||
return value.match(/(messages|events|alert|tasks|docs|file)/)
|
||||
}
|
||||
},
|
||||
},
|
||||
/**
|
||||
* Message that appears under the icon
|
||||
*/
|
||||
message: {
|
||||
type: String,
|
||||
default: null
|
||||
default: null,
|
||||
},
|
||||
/**
|
||||
* Vertical spacing
|
||||
*/
|
||||
margin: {
|
||||
type: [String, Object],
|
||||
default: 'x-large'
|
||||
}
|
||||
default: 'x-large',
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
iconPath() {
|
||||
return `/img/empty/${this.icon}.svg`
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -22,13 +22,13 @@ export default {
|
||||
|
||||
props: {
|
||||
followId: { type: String, default: null },
|
||||
isFollowed: { type: Boolean, default: false }
|
||||
isFollowed: { type: Boolean, default: false },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
disabled: false,
|
||||
loading: false,
|
||||
hovered: false
|
||||
hovered: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -45,13 +45,13 @@ export default {
|
||||
} else {
|
||||
return this.$t('followButton.follow')
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
isFollowed() {
|
||||
this.loading = false
|
||||
this.hovered = false
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onHover() {
|
||||
@ -75,8 +75,8 @@ export default {
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: this.followId
|
||||
}
|
||||
id: this.followId,
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
// this.$emit('optimistic', follow ? res.data.follow : follow)
|
||||
@ -85,7 +85,7 @@ export default {
|
||||
.catch(() => {
|
||||
this.$emit('optimistic', !follow)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -10,14 +10,14 @@ export default {
|
||||
props: {
|
||||
imageProps: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
imageSrc() {
|
||||
const src = this.imageProps.src
|
||||
return src.startsWith('/') ? src.replace('/', '/api/') : src
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -22,9 +22,7 @@ describe('Image', () => {
|
||||
})
|
||||
|
||||
it('adds a prefix to load the image from the backend', () => {
|
||||
expect(Wrapper().attributes('src')).toBe(
|
||||
'/api/img/badges/fundraisingbox_de_airship.svg'
|
||||
)
|
||||
expect(Wrapper().attributes('src')).toBe('/api/img/badges/fundraisingbox_de_airship.svg')
|
||||
})
|
||||
})
|
||||
|
||||
@ -35,9 +33,7 @@ describe('Image', () => {
|
||||
|
||||
it('keeps the URL as is', () => {
|
||||
// e.g. our seeds have absolute image URLs
|
||||
expect(Wrapper().attributes('src')).toBe(
|
||||
'http://lorempixel.com/640/480/animals'
|
||||
)
|
||||
expect(Wrapper().attributes('src')).toBe('http://lorempixel.com/640/480/animals')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
loading: { type: Boolean, default: false }
|
||||
}
|
||||
loading: { type: Boolean, default: false },
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -49,15 +49,15 @@ import orderBy from 'lodash/orderBy'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
Dropdown
|
||||
Dropdown,
|
||||
},
|
||||
props: {
|
||||
placement: { type: String, default: 'bottom-start' },
|
||||
offset: { type: [String, Number], default: '16' }
|
||||
offset: { type: [String, Number], default: '16' },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
locales: orderBy(process.env.locales, 'name')
|
||||
locales: orderBy(process.env.locales, 'name'),
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -68,11 +68,11 @@ export default {
|
||||
let routes = this.locales.map(locale => {
|
||||
return {
|
||||
name: locale.name,
|
||||
path: locale.code
|
||||
path: locale.code,
|
||||
}
|
||||
})
|
||||
return routes
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
changeLanguage(locale, toggleMenu) {
|
||||
@ -81,8 +81,8 @@ export default {
|
||||
},
|
||||
matcher(locale) {
|
||||
return locale === this.$i18n.locale()
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { shallowMount, mount, createLocalVue } from '@vue/test-utils'
|
||||
import { shallowMount, createLocalVue } from '@vue/test-utils'
|
||||
import Modal from './Modal.vue'
|
||||
import DisableModal from './Modal/DisableModal.vue'
|
||||
import ReportModal from './Modal/ReportModal.vue'
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import { getters, mutations } from '../store/modal'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
@ -13,7 +12,6 @@ localVue.use(Vuex)
|
||||
localVue.use(Styleguide)
|
||||
|
||||
describe('Modal.vue', () => {
|
||||
let Wrapper
|
||||
let wrapper
|
||||
let store
|
||||
let state
|
||||
@ -25,11 +23,11 @@ describe('Modal.vue', () => {
|
||||
state,
|
||||
getters: {
|
||||
'modal/open': getters.open,
|
||||
'modal/data': getters.data
|
||||
'modal/data': getters.data,
|
||||
},
|
||||
mutations: {
|
||||
'modal/SET_OPEN': mutations.SET_OPEN
|
||||
}
|
||||
'modal/SET_OPEN': mutations.SET_OPEN,
|
||||
},
|
||||
})
|
||||
return mountMethod(Modal, { store, mocks, localVue })
|
||||
}
|
||||
@ -38,17 +36,17 @@ describe('Modal.vue', () => {
|
||||
beforeEach(() => {
|
||||
mocks = {
|
||||
$filters: {
|
||||
truncate: a => a
|
||||
truncate: a => a,
|
||||
},
|
||||
$toast: {
|
||||
success: () => {},
|
||||
error: () => {}
|
||||
error: () => {},
|
||||
},
|
||||
$t: () => {}
|
||||
$t: () => {},
|
||||
}
|
||||
state = {
|
||||
open: null,
|
||||
data: {}
|
||||
data: {},
|
||||
}
|
||||
})
|
||||
|
||||
@ -69,9 +67,9 @@ describe('Modal.vue', () => {
|
||||
type: 'contribution',
|
||||
resource: {
|
||||
id: 'c456',
|
||||
title: 'some title'
|
||||
}
|
||||
}
|
||||
title: 'some title',
|
||||
},
|
||||
},
|
||||
}
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
@ -84,7 +82,7 @@ describe('Modal.vue', () => {
|
||||
expect(wrapper.find(DisableModal).props()).toEqual({
|
||||
type: 'contribution',
|
||||
name: 'some title',
|
||||
id: 'c456'
|
||||
id: 'c456',
|
||||
})
|
||||
})
|
||||
|
||||
@ -99,13 +97,13 @@ describe('Modal.vue', () => {
|
||||
it('passes author name to disable modal', () => {
|
||||
state.data = {
|
||||
type: 'comment',
|
||||
resource: { id: 'c456', author: { name: 'Author name' } }
|
||||
resource: { id: 'c456', author: { name: 'Author name' } },
|
||||
}
|
||||
wrapper = Wrapper()
|
||||
expect(wrapper.find(DisableModal).props()).toEqual({
|
||||
type: 'comment',
|
||||
name: 'Author name',
|
||||
id: 'c456'
|
||||
id: 'c456',
|
||||
})
|
||||
})
|
||||
|
||||
@ -115,7 +113,7 @@ describe('Modal.vue', () => {
|
||||
expect(wrapper.find(DisableModal).props()).toEqual({
|
||||
type: 'comment',
|
||||
name: '',
|
||||
id: 'c456'
|
||||
id: 'c456',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -35,17 +35,17 @@ export default {
|
||||
components: {
|
||||
DisableModal,
|
||||
ReportModal,
|
||||
DeleteModal
|
||||
DeleteModal,
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
data: 'modal/data',
|
||||
open: 'modal/open'
|
||||
open: 'modal/open',
|
||||
}),
|
||||
name() {
|
||||
if (!this.data || !this.data.resource) return ''
|
||||
const {
|
||||
resource: { name, title, author }
|
||||
resource: { name, title, author },
|
||||
} = this.data
|
||||
switch (this.data.type) {
|
||||
case 'user':
|
||||
@ -57,12 +57,12 @@ export default {
|
||||
default:
|
||||
return null
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
close() {
|
||||
this.$store.commit('modal/SET_OPEN', {})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { shallowMount, mount, createLocalVue } from '@vue/test-utils'
|
||||
import DeleteModal from './DeleteModal.vue'
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
import VueRouter from 'vue-router'
|
||||
@ -15,27 +14,26 @@ localVue.use(VueRouter)
|
||||
|
||||
describe('DeleteModal.vue', () => {
|
||||
let wrapper
|
||||
let Wrapper
|
||||
let propsData
|
||||
let mocks
|
||||
|
||||
beforeEach(() => {
|
||||
propsData = {
|
||||
type: 'contribution',
|
||||
id: 'c300'
|
||||
id: 'c300',
|
||||
}
|
||||
mocks = {
|
||||
$t: jest.fn(),
|
||||
$filters: {
|
||||
truncate: a => a
|
||||
truncate: a => a,
|
||||
},
|
||||
$toast: {
|
||||
success: () => {},
|
||||
error: () => {}
|
||||
error: () => {},
|
||||
},
|
||||
$apollo: {
|
||||
mutate: jest.fn().mockResolvedValue()
|
||||
}
|
||||
mutate: jest.fn().mockResolvedValue(),
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
@ -59,7 +57,7 @@ describe('DeleteModal.vue', () => {
|
||||
propsData = {
|
||||
id: 'p23',
|
||||
type: 'post',
|
||||
name: 'It is a post'
|
||||
name: 'It is a post',
|
||||
}
|
||||
})
|
||||
|
||||
@ -87,7 +85,7 @@ describe('DeleteModal.vue', () => {
|
||||
beforeEach(() => {
|
||||
propsData = {
|
||||
type: 'user',
|
||||
id: 'u3'
|
||||
id: 'u3',
|
||||
}
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
@ -48,18 +48,18 @@ import { SweetalertIcon } from 'vue-sweetalert-icons'
|
||||
export default {
|
||||
name: 'DeleteModal',
|
||||
components: {
|
||||
SweetalertIcon
|
||||
SweetalertIcon,
|
||||
},
|
||||
props: {
|
||||
name: { type: String, default: '' },
|
||||
type: { type: String, required: true },
|
||||
id: { type: String, required: true }
|
||||
id: { type: String, required: true },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isOpen: true,
|
||||
success: false,
|
||||
loading: false
|
||||
loading: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -69,7 +69,7 @@ export default {
|
||||
message() {
|
||||
const name = this.$filters.truncate(this.name, 30)
|
||||
return this.$t(`post.delete.message`, { name })
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async cancel() {
|
||||
@ -89,7 +89,7 @@ export default {
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: { id: this.id }
|
||||
variables: { id: this.id },
|
||||
})
|
||||
this.success = true
|
||||
this.$toast.success(this.$t('post.delete.success'))
|
||||
@ -113,8 +113,8 @@ export default {
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { shallowMount, mount, createLocalVue } from '@vue/test-utils'
|
||||
import DisableModal from './DisableModal.vue'
|
||||
import Vue from 'vue'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
|
||||
const localVue = createLocalVue()
|
||||
@ -8,7 +7,6 @@ const localVue = createLocalVue()
|
||||
localVue.use(Styleguide)
|
||||
|
||||
describe('DisableModal.vue', () => {
|
||||
let store
|
||||
let mocks
|
||||
let propsData
|
||||
let wrapper
|
||||
@ -17,20 +15,20 @@ describe('DisableModal.vue', () => {
|
||||
propsData = {
|
||||
type: 'contribution',
|
||||
name: 'blah',
|
||||
id: 'c42'
|
||||
id: 'c42',
|
||||
}
|
||||
mocks = {
|
||||
$filters: {
|
||||
truncate: a => a
|
||||
truncate: a => a,
|
||||
},
|
||||
$toast: {
|
||||
success: () => {},
|
||||
error: () => {}
|
||||
error: () => {},
|
||||
},
|
||||
$t: jest.fn(),
|
||||
$apollo: {
|
||||
mutate: jest.fn().mockResolvedValue()
|
||||
}
|
||||
mutate: jest.fn().mockResolvedValue(),
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
@ -44,7 +42,7 @@ describe('DisableModal.vue', () => {
|
||||
propsData = {
|
||||
type: 'user',
|
||||
id: 'u2',
|
||||
name: 'Bob Ross'
|
||||
name: 'Bob Ross',
|
||||
}
|
||||
})
|
||||
|
||||
@ -61,16 +59,14 @@ describe('DisableModal.vue', () => {
|
||||
propsData = {
|
||||
type: 'contribution',
|
||||
id: 'c3',
|
||||
name: 'This is some post title.'
|
||||
name: 'This is some post title.',
|
||||
}
|
||||
})
|
||||
|
||||
it('mentions contribution title', () => {
|
||||
Wrapper()
|
||||
const calls = mocks.$t.mock.calls
|
||||
const expected = [
|
||||
['disable.contribution.message', { name: 'This is some post title.' }]
|
||||
]
|
||||
const expected = [['disable.contribution.message', { name: 'This is some post title.' }]]
|
||||
expect(calls).toEqual(expect.arrayContaining(expected))
|
||||
})
|
||||
})
|
||||
@ -86,7 +82,7 @@ describe('DisableModal.vue', () => {
|
||||
beforeEach(() => {
|
||||
propsData = {
|
||||
type: 'user',
|
||||
id: 'u4711'
|
||||
id: 'u4711',
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -34,13 +34,13 @@ export default {
|
||||
props: {
|
||||
name: { type: String, default: '' },
|
||||
type: { type: String, required: true },
|
||||
id: { type: String, required: true }
|
||||
id: { type: String, required: true },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isOpen: true,
|
||||
success: false,
|
||||
loading: false
|
||||
loading: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -50,7 +50,7 @@ export default {
|
||||
message() {
|
||||
const name = this.$filters.truncate(this.name, 30)
|
||||
return this.$t(`disable.${this.type}.message`, { name })
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
cancel() {
|
||||
@ -67,7 +67,7 @@ export default {
|
||||
disable(id: $id)
|
||||
}
|
||||
`,
|
||||
variables: { id: this.id }
|
||||
variables: { id: this.id },
|
||||
})
|
||||
this.$toast.success(this.$t('disable.success'))
|
||||
this.isOpen = false
|
||||
@ -77,7 +77,7 @@ export default {
|
||||
} catch (err) {
|
||||
this.$toast.error(err.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { shallowMount, mount, createLocalVue } from '@vue/test-utils'
|
||||
import ReportModal from './ReportModal.vue'
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
|
||||
@ -11,27 +10,26 @@ localVue.use(Styleguide)
|
||||
|
||||
describe('ReportModal.vue', () => {
|
||||
let wrapper
|
||||
let Wrapper
|
||||
let propsData
|
||||
let mocks
|
||||
|
||||
beforeEach(() => {
|
||||
propsData = {
|
||||
type: 'contribution',
|
||||
id: 'c43'
|
||||
id: 'c43',
|
||||
}
|
||||
mocks = {
|
||||
$t: jest.fn(),
|
||||
$filters: {
|
||||
truncate: a => a
|
||||
truncate: a => a,
|
||||
},
|
||||
$toast: {
|
||||
success: () => {},
|
||||
error: () => {}
|
||||
error: () => {},
|
||||
},
|
||||
$apollo: {
|
||||
mutate: jest.fn().mockResolvedValue()
|
||||
}
|
||||
mutate: jest.fn().mockResolvedValue(),
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
@ -55,7 +53,7 @@ describe('ReportModal.vue', () => {
|
||||
propsData = {
|
||||
type: 'user',
|
||||
id: 'u4',
|
||||
name: 'Bob Ross'
|
||||
name: 'Bob Ross',
|
||||
}
|
||||
})
|
||||
|
||||
@ -72,7 +70,7 @@ describe('ReportModal.vue', () => {
|
||||
propsData = {
|
||||
id: 'p23',
|
||||
type: 'post',
|
||||
name: 'It is a post'
|
||||
name: 'It is a post',
|
||||
}
|
||||
})
|
||||
|
||||
@ -100,7 +98,7 @@ describe('ReportModal.vue', () => {
|
||||
beforeEach(() => {
|
||||
propsData = {
|
||||
type: 'user',
|
||||
id: 'u4711'
|
||||
id: 'u4711',
|
||||
}
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
@ -48,18 +48,18 @@ import { SweetalertIcon } from 'vue-sweetalert-icons'
|
||||
export default {
|
||||
name: 'ReportModal',
|
||||
components: {
|
||||
SweetalertIcon
|
||||
SweetalertIcon,
|
||||
},
|
||||
props: {
|
||||
name: { type: String, default: '' },
|
||||
type: { type: String, required: true },
|
||||
id: { type: String, required: true }
|
||||
id: { type: String, required: true },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isOpen: true,
|
||||
success: false,
|
||||
loading: false
|
||||
loading: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -69,7 +69,7 @@ export default {
|
||||
message() {
|
||||
const name = this.$filters.truncate(this.name, 30)
|
||||
return this.$t(`report.${this.type}.message`, { name })
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async cancel() {
|
||||
@ -89,7 +89,7 @@ export default {
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables: { id: this.id }
|
||||
variables: { id: this.id },
|
||||
})
|
||||
this.success = true
|
||||
this.$toast.success(this.$t('report.success'))
|
||||
@ -106,8 +106,8 @@ export default {
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { mount, createLocalVue } from '@vue/test-utils'
|
||||
import ChangePassword from './Change.vue'
|
||||
import Vue from 'vue'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
|
||||
const localVue = createLocalVue()
|
||||
@ -9,25 +8,24 @@ localVue.use(Styleguide)
|
||||
|
||||
describe('ChangePassword.vue', () => {
|
||||
let mocks
|
||||
let wrapper
|
||||
|
||||
beforeEach(() => {
|
||||
mocks = {
|
||||
validate: jest.fn(),
|
||||
$toast: {
|
||||
error: jest.fn(),
|
||||
success: jest.fn()
|
||||
success: jest.fn(),
|
||||
},
|
||||
$t: jest.fn(),
|
||||
$store: {
|
||||
commit: jest.fn()
|
||||
commit: jest.fn(),
|
||||
},
|
||||
$apollo: {
|
||||
mutate: jest
|
||||
.fn()
|
||||
.mockRejectedValue({ message: 'Ouch!' })
|
||||
.mockResolvedValueOnce({ data: { changePassword: 'NEWTOKEN' } })
|
||||
}
|
||||
.mockResolvedValueOnce({ data: { changePassword: 'NEWTOKEN' } }),
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
@ -63,9 +61,7 @@ describe('ChangePassword.vue', () => {
|
||||
|
||||
it.skip('displays a warning', () => {
|
||||
const calls = mocks.validate.mock.calls
|
||||
const expected = [
|
||||
['change-password.validations.old-and-new-password-match']
|
||||
]
|
||||
const expected = [['change-password.validations.old-and-new-password-match']]
|
||||
expect(calls).toEqual(expect.arrayContaining(expected))
|
||||
})
|
||||
})
|
||||
@ -112,9 +108,9 @@ describe('ChangePassword.vue', () => {
|
||||
variables: {
|
||||
oldPassword: 'supersecret',
|
||||
newPassword: 'superdupersecret',
|
||||
confirmPassword: 'superdupersecret'
|
||||
}
|
||||
})
|
||||
confirmPassword: 'superdupersecret',
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
@ -124,16 +120,11 @@ describe('ChangePassword.vue', () => {
|
||||
})
|
||||
|
||||
it('calls auth/SET_TOKEN with response', () => {
|
||||
expect(mocks.$store.commit).toHaveBeenCalledWith(
|
||||
'auth/SET_TOKEN',
|
||||
'NEWTOKEN'
|
||||
)
|
||||
expect(mocks.$store.commit).toHaveBeenCalledWith('auth/SET_TOKEN', 'NEWTOKEN')
|
||||
})
|
||||
|
||||
it('displays success message', () => {
|
||||
expect(mocks.$t).toHaveBeenCalledWith(
|
||||
'settings.security.change-password.success'
|
||||
)
|
||||
expect(mocks.$t).toHaveBeenCalledWith('settings.security.change-password.success')
|
||||
expect(mocks.$toast.success).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
@ -46,29 +46,25 @@ import PasswordStrength from './Strength'
|
||||
export default {
|
||||
name: 'ChangePassword',
|
||||
components: {
|
||||
PasswordStrength
|
||||
PasswordStrength,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
formData: {
|
||||
oldPassword: '',
|
||||
newPassword: '',
|
||||
confirmPassword: ''
|
||||
confirmPassword: '',
|
||||
},
|
||||
formSchema: {
|
||||
oldPassword: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
message: this.$t(
|
||||
'settings.security.change-password.message-old-password-required'
|
||||
)
|
||||
message: this.$t('settings.security.change-password.message-old-password-required'),
|
||||
},
|
||||
newPassword: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
message: this.$t(
|
||||
'settings.security.change-password.message-new-password-required'
|
||||
)
|
||||
message: this.$t('settings.security.change-password.message-new-password-required'),
|
||||
},
|
||||
confirmPassword: [
|
||||
{ validator: this.matchPassword },
|
||||
@ -76,13 +72,13 @@ export default {
|
||||
type: 'string',
|
||||
required: true,
|
||||
message: this.$t(
|
||||
'settings.security.change-password.message-new-password-confirm-required'
|
||||
)
|
||||
}
|
||||
]
|
||||
'settings.security.change-password.message-new-password-confirm-required',
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
loading: false,
|
||||
disabled: true
|
||||
disabled: true,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -104,13 +100,11 @@ export default {
|
||||
try {
|
||||
const { data } = await this.$apollo.mutate({ mutation, variables })
|
||||
this.$store.commit('auth/SET_TOKEN', data.changePassword)
|
||||
this.$toast.success(
|
||||
this.$t('settings.security.change-password.success')
|
||||
)
|
||||
this.$toast.success(this.$t('settings.security.change-password.success'))
|
||||
this.formData = {
|
||||
oldPassword: '',
|
||||
newPassword: '',
|
||||
confirmPassword: ''
|
||||
confirmPassword: '',
|
||||
}
|
||||
} catch (err) {
|
||||
this.$toast.error(err.message)
|
||||
@ -122,15 +116,11 @@ export default {
|
||||
var errors = []
|
||||
if (this.formData.newPassword !== value) {
|
||||
errors.push(
|
||||
new Error(
|
||||
this.$t(
|
||||
'settings.security.change-password.message-new-password-missmatch'
|
||||
)
|
||||
)
|
||||
new Error(this.$t('settings.security.change-password.message-new-password-missmatch')),
|
||||
)
|
||||
}
|
||||
callback(errors)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -28,14 +28,14 @@ export default {
|
||||
props: {
|
||||
password: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
strength: null,
|
||||
isSecure: false,
|
||||
pass: this.password || null
|
||||
pass: this.password || null,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -50,11 +50,11 @@ export default {
|
||||
this.isSecure = Boolean(strength >= 3)
|
||||
this.$emit('change', {
|
||||
strength,
|
||||
isSecure: this.isSecure
|
||||
isSecure: this.isSecure,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -89,17 +89,17 @@ export default {
|
||||
HcUser,
|
||||
HcCategory,
|
||||
HcRibbon,
|
||||
ContentMenu
|
||||
ContentMenu,
|
||||
},
|
||||
props: {
|
||||
post: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
user: 'auth/user'
|
||||
user: 'auth/user',
|
||||
}),
|
||||
excerpt() {
|
||||
return this.$filters.removeLinks(this.post.contentExcerpt)
|
||||
@ -108,8 +108,8 @@ export default {
|
||||
const { author } = this.post
|
||||
if (!author) return false
|
||||
return this.user.id === this.post.author.id
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -14,7 +14,6 @@ config.stubs['no-ssr'] = '<span><slot /></span>'
|
||||
config.stubs['v-popover'] = '<span><slot /></span>'
|
||||
|
||||
describe('PostCard', () => {
|
||||
let wrapper
|
||||
let stubs
|
||||
let mocks
|
||||
let propsData
|
||||
@ -23,35 +22,35 @@ describe('PostCard', () => {
|
||||
beforeEach(() => {
|
||||
propsData = {}
|
||||
stubs = {
|
||||
NuxtLink: RouterLinkStub
|
||||
NuxtLink: RouterLinkStub,
|
||||
}
|
||||
mocks = {
|
||||
$t: jest.fn()
|
||||
$t: jest.fn(),
|
||||
}
|
||||
getters = {
|
||||
'auth/user': () => {
|
||||
return {}
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
const Wrapper = () => {
|
||||
const store = new Vuex.Store({
|
||||
getters
|
||||
getters,
|
||||
})
|
||||
return mount(PostCard, {
|
||||
stubs,
|
||||
mocks,
|
||||
propsData,
|
||||
store,
|
||||
localVue
|
||||
localVue,
|
||||
})
|
||||
}
|
||||
|
||||
describe('given a post', () => {
|
||||
beforeEach(() => {
|
||||
propsData.post = {
|
||||
title: "It's a title"
|
||||
title: "It's a title",
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -4,14 +4,14 @@
|
||||
|
||||
<script>
|
||||
import formatRelative from 'date-fns/formatRelative'
|
||||
import { enUS, de, nl, fr, pt, es /*, pl*/ } from 'date-fns/locale'
|
||||
import { enUS, de, nl, fr, pt, es } from 'date-fns/locale' // pl currently not working library wise
|
||||
const locales = {
|
||||
en: enUS,
|
||||
de,
|
||||
nl,
|
||||
fr,
|
||||
es,
|
||||
pt
|
||||
pt,
|
||||
// pl
|
||||
}
|
||||
|
||||
@ -20,14 +20,14 @@ export default {
|
||||
props: {
|
||||
dateTime: {
|
||||
type: [Date, String],
|
||||
required: true
|
||||
}
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
relativeDateTime() {
|
||||
let locale = locales[this.$i18n.locale() || 'en']
|
||||
return formatRelative(new Date(this.dateTime), new Date(), { locale })
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -4,7 +4,6 @@ import RelativeDateTime from './'
|
||||
const localVue = createLocalVue()
|
||||
|
||||
describe('RelativeDateTime', () => {
|
||||
let wrapper
|
||||
let mocks
|
||||
let locale
|
||||
let dateTime
|
||||
@ -12,8 +11,8 @@ describe('RelativeDateTime', () => {
|
||||
beforeEach(() => {
|
||||
mocks = {
|
||||
$i18n: {
|
||||
locale: () => locale
|
||||
}
|
||||
locale: () => locale,
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
@ -22,8 +21,8 @@ describe('RelativeDateTime', () => {
|
||||
mocks,
|
||||
localVue,
|
||||
propsData: {
|
||||
dateTime
|
||||
}
|
||||
dateTime,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -10,8 +10,8 @@ describe('Ribbon', () => {
|
||||
return shallowMount(Ribbon, {
|
||||
localVue,
|
||||
propsData: {
|
||||
text
|
||||
}
|
||||
text,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -10,9 +10,9 @@ export default {
|
||||
props: {
|
||||
text: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
}
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -43,8 +43,7 @@ export default {
|
||||
bottom: -6px;
|
||||
border-width: 3px 4px 3px 3px;
|
||||
border-style: solid;
|
||||
border-color: $background-color-secondary transparent transparent
|
||||
$background-color-secondary;
|
||||
border-color: $background-color-secondary transparent transparent $background-color-secondary;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -10,7 +10,6 @@ localVue.filter('truncate', () => 'truncated string')
|
||||
localVue.filter('dateTime', () => Date.now)
|
||||
|
||||
describe('SearchInput.vue', () => {
|
||||
let wrapper
|
||||
let mocks
|
||||
let propsData
|
||||
|
||||
@ -21,7 +20,7 @@ describe('SearchInput.vue', () => {
|
||||
describe('mount', () => {
|
||||
const Wrapper = () => {
|
||||
mocks = {
|
||||
$t: () => {}
|
||||
$t: () => {},
|
||||
}
|
||||
return mount(SearchInput, { mocks, localVue, propsData })
|
||||
}
|
||||
@ -121,7 +120,7 @@ describe('SearchInput.vue', () => {
|
||||
__typename: 'User',
|
||||
id: 'u5',
|
||||
name: 'Trick',
|
||||
slug: 'trick'
|
||||
slug: 'trick',
|
||||
},
|
||||
commentsCount: 0,
|
||||
createdAt: '2019-03-13T11:00:20.835Z',
|
||||
@ -129,9 +128,9 @@ describe('SearchInput.vue', () => {
|
||||
label: 'Eos aut illo omnis quis eaque et iure aut.',
|
||||
shoutedCount: 0,
|
||||
slug: 'eos-aut-illo-omnis-quis-eaque-et-iure-aut',
|
||||
value: 'Eos aut illo omnis quis eaque et iure aut.'
|
||||
}
|
||||
]
|
||||
value: 'Eos aut illo omnis quis eaque et iure aut.',
|
||||
},
|
||||
],
|
||||
}
|
||||
wrapper = Wrapper()
|
||||
select.trigger('input')
|
||||
|
||||
@ -98,24 +98,24 @@ export default {
|
||||
props: {
|
||||
id: {
|
||||
type: String,
|
||||
default: 'nav-search'
|
||||
default: 'nav-search',
|
||||
},
|
||||
value: {
|
||||
type: String,
|
||||
default: ''
|
||||
default: '',
|
||||
},
|
||||
results: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
default: () => [],
|
||||
},
|
||||
delay: {
|
||||
type: Number,
|
||||
default: 300
|
||||
default: 300,
|
||||
},
|
||||
pending: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -123,7 +123,7 @@ export default {
|
||||
isOpen: false,
|
||||
lastSearchTerm: '',
|
||||
unprocessedSearchInput: '',
|
||||
searchValue: ''
|
||||
searchValue: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -132,10 +132,8 @@ export default {
|
||||
return !isEmpty(this.lastSearchTerm)
|
||||
},
|
||||
emptyText() {
|
||||
return this.isActive && !this.pending
|
||||
? this.$t('search.failed')
|
||||
: this.$t('search.hint')
|
||||
}
|
||||
return this.isActive && !this.pending ? this.$t('search.failed') : this.$t('search.hint')
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async query(value) {
|
||||
@ -201,8 +199,8 @@ export default {
|
||||
this.unprocessedSearchInput = ''
|
||||
this.lastSearchTerm = ''
|
||||
this.searchValue = ''
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -35,13 +35,13 @@ export default {
|
||||
count: { type: Number, default: 0 },
|
||||
postId: { type: String, default: null },
|
||||
isShouted: { type: Boolean, default: false },
|
||||
disabled: { type: Boolean, default: false }
|
||||
disabled: { type: Boolean, default: false },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
shoutedCount: this.count,
|
||||
shouted: false
|
||||
shouted: false,
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -49,8 +49,8 @@ export default {
|
||||
immediate: true,
|
||||
handler: function(shouted) {
|
||||
this.shouted = shouted
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
toggle() {
|
||||
@ -60,7 +60,7 @@ export default {
|
||||
|
||||
const backup = {
|
||||
shoutedCount: this.shoutedCount,
|
||||
shouted: this.shouted
|
||||
shouted: this.shouted,
|
||||
}
|
||||
|
||||
this.shoutedCount = count
|
||||
@ -74,8 +74,8 @@ export default {
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: this.postId
|
||||
}
|
||||
id: this.postId,
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
if (res && res.data) {
|
||||
@ -89,8 +89,8 @@ export default {
|
||||
.finally(() => {
|
||||
this.loading = false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
export default {
|
||||
name: 'HcTag',
|
||||
props: {
|
||||
name: { type: String, required: true }
|
||||
}
|
||||
name: { type: String, required: true },
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -12,8 +12,8 @@ describe('Tag', () => {
|
||||
return shallowMount(Tag, {
|
||||
localVue,
|
||||
propsData: {
|
||||
name
|
||||
}
|
||||
name,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -151,16 +151,16 @@ export default {
|
||||
HcRelativeDateTime,
|
||||
HcFollowButton,
|
||||
HcBadges,
|
||||
Dropdown
|
||||
Dropdown,
|
||||
},
|
||||
props: {
|
||||
user: { type: Object, default: null },
|
||||
trunc: { type: Number, default: null },
|
||||
dateTime: { type: [Date, String], default: null }
|
||||
dateTime: { type: [Date, String], default: null },
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
isModerator: 'auth/isModerator'
|
||||
isModerator: 'auth/isModerator',
|
||||
}),
|
||||
itsMe() {
|
||||
return this.user.slug === this.$store.getters['auth/user'].slug
|
||||
@ -177,8 +177,8 @@ export default {
|
||||
userName() {
|
||||
const { name } = this.user || {}
|
||||
return name || this.$t('profile.userAnonym')
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { config, mount, createLocalVue, RouterLinkStub } from '@vue/test-utils'
|
||||
import { mount, createLocalVue, RouterLinkStub } from '@vue/test-utils'
|
||||
import User from './index'
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import VTooltip from 'v-tooltip'
|
||||
|
||||
@ -16,35 +15,32 @@ localVue.use(Styleguide)
|
||||
localVue.filter('truncate', filter)
|
||||
|
||||
describe('User', () => {
|
||||
let wrapper
|
||||
let Wrapper
|
||||
let propsData
|
||||
let mocks
|
||||
let stubs
|
||||
let getters
|
||||
let user
|
||||
|
||||
beforeEach(() => {
|
||||
propsData = {}
|
||||
|
||||
mocks = {
|
||||
$t: jest.fn()
|
||||
$t: jest.fn(),
|
||||
}
|
||||
stubs = {
|
||||
NuxtLink: RouterLinkStub
|
||||
NuxtLink: RouterLinkStub,
|
||||
}
|
||||
getters = {
|
||||
'auth/user': () => {
|
||||
return {}
|
||||
},
|
||||
'auth/isModerator': () => false
|
||||
'auth/isModerator': () => false,
|
||||
}
|
||||
})
|
||||
|
||||
describe('mount', () => {
|
||||
const Wrapper = () => {
|
||||
const store = new Vuex.Store({
|
||||
getters
|
||||
getters,
|
||||
})
|
||||
return mount(User, { store, propsData, mocks, stubs, localVue })
|
||||
}
|
||||
@ -59,7 +55,7 @@ describe('User', () => {
|
||||
beforeEach(() => {
|
||||
propsData.user = {
|
||||
name: 'Tilda Swinton',
|
||||
slug: 'tilda-swinton'
|
||||
slug: 'tilda-swinton',
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -48,20 +48,20 @@ import HcEditor from '~/components/Editor'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcEditor
|
||||
HcEditor,
|
||||
},
|
||||
props: {
|
||||
post: { type: Object, default: () => {} },
|
||||
comments: { type: Array, default: () => [] }
|
||||
comments: { type: Array, default: () => [] },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
disabled: true,
|
||||
loading: false,
|
||||
form: {
|
||||
content: ''
|
||||
content: '',
|
||||
},
|
||||
users: []
|
||||
users: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -92,8 +92,8 @@ export default {
|
||||
`,
|
||||
variables: {
|
||||
postId: this.post.id,
|
||||
content: this.form.content
|
||||
}
|
||||
content: this.form.content,
|
||||
},
|
||||
})
|
||||
.then(res => {
|
||||
this.loading = false
|
||||
@ -105,7 +105,7 @@ export default {
|
||||
.catch(err => {
|
||||
this.$toast.error(err.message)
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
User: {
|
||||
@ -119,8 +119,8 @@ export default {
|
||||
},
|
||||
result(result) {
|
||||
this.users = result.data.User
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { config, mount, createLocalVue, createWrapper } from '@vue/test-utils'
|
||||
import CommentForm from './index.vue'
|
||||
import Vue from 'vue'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
|
||||
const localVue = createLocalVue()
|
||||
@ -17,24 +16,24 @@ describe('CommentForm.vue', () => {
|
||||
let cancelMethodSpy
|
||||
|
||||
beforeEach(() => {
|
||||
;(mocks = {
|
||||
mocks = {
|
||||
$t: jest.fn(),
|
||||
$apollo: {
|
||||
mutate: jest
|
||||
.fn()
|
||||
.mockResolvedValueOnce({
|
||||
data: { CreateComment: { contentExcerpt: 'this is a comment' } }
|
||||
data: { CreateComment: { contentExcerpt: 'this is a comment' } },
|
||||
})
|
||||
.mockRejectedValue({ message: 'Ouch!' })
|
||||
.mockRejectedValue({ message: 'Ouch!' }),
|
||||
},
|
||||
$toast: {
|
||||
error: jest.fn(),
|
||||
success: jest.fn()
|
||||
}
|
||||
}),
|
||||
(propsData = {
|
||||
post: { id: 1 }
|
||||
})
|
||||
success: jest.fn(),
|
||||
},
|
||||
}
|
||||
propsData = {
|
||||
post: { id: 1 },
|
||||
}
|
||||
})
|
||||
|
||||
describe('mount', () => {
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
import { config, mount, createLocalVue } from '@vue/test-utils'
|
||||
import CommentList from '.'
|
||||
import Empty from '~/components/Empty'
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import Filters from '~/plugins/vue-filters'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
|
||||
const localVue = createLocalVue()
|
||||
@ -24,21 +22,21 @@ describe('CommentList.vue', () => {
|
||||
let data
|
||||
|
||||
propsData = {
|
||||
post: { id: 1 }
|
||||
post: { id: 1 },
|
||||
}
|
||||
store = new Vuex.Store({
|
||||
getters: {
|
||||
'auth/user': () => {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
mocks = {
|
||||
$t: jest.fn()
|
||||
$t: jest.fn(),
|
||||
}
|
||||
data = () => {
|
||||
return {
|
||||
comments: []
|
||||
comments: [],
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,7 +48,7 @@ describe('CommentList.vue', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
wrapper.setData({
|
||||
comments: [{ id: 'c1', contentExcerpt: 'this is a comment' }]
|
||||
comments: [{ id: 'c1', contentExcerpt: 'this is a comment' }],
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@ -38,20 +38,20 @@ import HcEmpty from '~/components/Empty.vue'
|
||||
export default {
|
||||
components: {
|
||||
Comment,
|
||||
HcEmpty
|
||||
HcEmpty,
|
||||
},
|
||||
props: {
|
||||
post: { type: Object, default: () => {} }
|
||||
post: { type: Object, default: () => {} },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
comments: []
|
||||
comments: [],
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
Post(post) {
|
||||
this.comments = post[0].comments || []
|
||||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.$root.$on('refetchPostComments', comment => {
|
||||
@ -61,7 +61,7 @@ export default {
|
||||
methods: {
|
||||
refetchPostComments(comment) {
|
||||
this.$apollo.queries.Post.refetch()
|
||||
}
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
Post: {
|
||||
@ -70,11 +70,11 @@ export default {
|
||||
},
|
||||
variables() {
|
||||
return {
|
||||
slug: this.post.slug
|
||||
slug: this.post.slug,
|
||||
}
|
||||
},
|
||||
fetchPolicy: 'cache-and-network'
|
||||
}
|
||||
}
|
||||
fetchPolicy: 'cache-and-network',
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -44,13 +44,13 @@ import HcUser from '~/components/User'
|
||||
export default {
|
||||
name: 'Notification',
|
||||
components: {
|
||||
HcUser
|
||||
HcUser,
|
||||
},
|
||||
props: {
|
||||
notification: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
excerpt() {
|
||||
@ -58,8 +58,8 @@ export default {
|
||||
},
|
||||
post() {
|
||||
return this.notification.post || {}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -11,17 +11,16 @@ localVue.use(Filters)
|
||||
config.stubs['no-ssr'] = '<span><slot /></span>'
|
||||
|
||||
describe('Notification', () => {
|
||||
let wrapper
|
||||
let stubs
|
||||
let mocks
|
||||
let propsData
|
||||
beforeEach(() => {
|
||||
propsData = {}
|
||||
mocks = {
|
||||
$t: jest.fn()
|
||||
$t: jest.fn(),
|
||||
}
|
||||
stubs = {
|
||||
NuxtLink: RouterLinkStub
|
||||
NuxtLink: RouterLinkStub,
|
||||
}
|
||||
})
|
||||
|
||||
@ -30,7 +29,7 @@ describe('Notification', () => {
|
||||
stubs,
|
||||
mocks,
|
||||
propsData,
|
||||
localVue
|
||||
localVue,
|
||||
})
|
||||
}
|
||||
|
||||
@ -38,8 +37,8 @@ describe('Notification', () => {
|
||||
beforeEach(() => {
|
||||
propsData.notification = {
|
||||
post: {
|
||||
title: "It's a title"
|
||||
}
|
||||
title: "It's a title",
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -15,18 +15,18 @@ import Notification from '../Notification'
|
||||
export default {
|
||||
name: 'NotificationList',
|
||||
components: {
|
||||
Notification
|
||||
Notification,
|
||||
},
|
||||
props: {
|
||||
notifications: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
markAsRead(notificationId) {
|
||||
this.$emit('markAsRead', notificationId)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -1,13 +1,6 @@
|
||||
import {
|
||||
config,
|
||||
shallowMount,
|
||||
mount,
|
||||
createLocalVue,
|
||||
RouterLinkStub
|
||||
} from '@vue/test-utils'
|
||||
import { config, shallowMount, mount, createLocalVue, RouterLinkStub } from '@vue/test-utils'
|
||||
import NotificationList from '.'
|
||||
import Notification from '../Notification'
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import Filters from '~/plugins/vue-filters'
|
||||
|
||||
@ -25,7 +18,6 @@ config.stubs['v-popover'] = '<span><slot /></span>'
|
||||
|
||||
describe('NotificationList.vue', () => {
|
||||
let wrapper
|
||||
let Wrapper
|
||||
let mocks
|
||||
let stubs
|
||||
let store
|
||||
@ -36,14 +28,14 @@ describe('NotificationList.vue', () => {
|
||||
getters: {
|
||||
'auth/user': () => {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
mocks = {
|
||||
$t: jest.fn()
|
||||
$t: jest.fn(),
|
||||
}
|
||||
stubs = {
|
||||
NuxtLink: RouterLinkStub
|
||||
NuxtLink: RouterLinkStub,
|
||||
}
|
||||
propsData = {
|
||||
notifications: [
|
||||
@ -57,9 +49,9 @@ describe('NotificationList.vue', () => {
|
||||
author: {
|
||||
id: 'john-1',
|
||||
slug: 'john-doe',
|
||||
name: 'John Doe'
|
||||
}
|
||||
}
|
||||
name: 'John Doe',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'notification-42',
|
||||
@ -71,11 +63,11 @@ describe('NotificationList.vue', () => {
|
||||
author: {
|
||||
id: 'john-1',
|
||||
slug: 'john-doe',
|
||||
name: 'John Doe'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
name: 'John Doe',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
})
|
||||
|
||||
@ -85,7 +77,7 @@ describe('NotificationList.vue', () => {
|
||||
propsData,
|
||||
mocks,
|
||||
store,
|
||||
localVue
|
||||
localVue,
|
||||
})
|
||||
}
|
||||
|
||||
@ -105,7 +97,7 @@ describe('NotificationList.vue', () => {
|
||||
mocks,
|
||||
stubs,
|
||||
store,
|
||||
localVue
|
||||
localVue,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -66,12 +66,12 @@ export default {
|
||||
name: 'NotificationMenu',
|
||||
components: {
|
||||
NotificationList,
|
||||
Dropdown
|
||||
Dropdown,
|
||||
},
|
||||
computed: {
|
||||
totalNotifications() {
|
||||
return (this.notifications || []).length
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async markAsRead(notificationId) {
|
||||
@ -79,24 +79,24 @@ export default {
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation: MARK_AS_READ,
|
||||
variables
|
||||
variables,
|
||||
})
|
||||
} catch (err) {
|
||||
throw new Error(err)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
notifications: {
|
||||
query: NOTIFICATIONS,
|
||||
update: data => {
|
||||
const {
|
||||
currentUser: { notifications }
|
||||
currentUser: { notifications },
|
||||
} = data
|
||||
return notifications
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -14,16 +14,15 @@ config.stubs['dropdown'] = '<span class="dropdown"><slot /></span>'
|
||||
|
||||
describe('NotificationMenu.vue', () => {
|
||||
let wrapper
|
||||
let Wrapper
|
||||
let mocks
|
||||
let data
|
||||
beforeEach(() => {
|
||||
mocks = {
|
||||
$t: jest.fn()
|
||||
$t: jest.fn(),
|
||||
}
|
||||
data = () => {
|
||||
return {
|
||||
notifications: []
|
||||
notifications: [],
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -33,7 +32,7 @@ describe('NotificationMenu.vue', () => {
|
||||
return shallowMount(NotificationMenu, {
|
||||
data,
|
||||
mocks,
|
||||
localVue
|
||||
localVue,
|
||||
})
|
||||
}
|
||||
|
||||
@ -62,9 +61,9 @@ describe('NotificationMenu.vue', () => {
|
||||
author: {
|
||||
id: 'john-1',
|
||||
slug: 'john-doe',
|
||||
name: 'John Doe'
|
||||
}
|
||||
}
|
||||
name: 'John Doe',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'notification-42',
|
||||
@ -76,11 +75,11 @@ describe('NotificationMenu.vue', () => {
|
||||
author: {
|
||||
id: 'john-1',
|
||||
slug: 'john-doe',
|
||||
name: 'John Doe'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
name: 'John Doe',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -23,6 +23,6 @@ export default app => {
|
||||
contentExcerpt
|
||||
}
|
||||
}
|
||||
`)
|
||||
`),
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,6 @@
|
||||
import seo from '~/mixins/seo'
|
||||
|
||||
export default {
|
||||
mixins: [seo]
|
||||
mixins: [seo],
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -131,13 +131,12 @@ export default {
|
||||
LocaleSwitch,
|
||||
SearchInput,
|
||||
Modal,
|
||||
LocaleSwitch,
|
||||
NotificationMenu
|
||||
NotificationMenu,
|
||||
},
|
||||
mixins: [seo],
|
||||
data() {
|
||||
return {
|
||||
mobileSearchVisible: false
|
||||
mobileSearchVisible: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -147,7 +146,7 @@ export default {
|
||||
isModerator: 'auth/isModerator',
|
||||
isAdmin: 'auth/isAdmin',
|
||||
quickSearchResults: 'search/quickResults',
|
||||
quickSearchPending: 'search/quickPending'
|
||||
quickSearchPending: 'search/quickPending',
|
||||
}),
|
||||
userName() {
|
||||
const { name } = this.user || {}
|
||||
@ -161,41 +160,41 @@ export default {
|
||||
{
|
||||
name: this.$t('profile.name'),
|
||||
path: `/profile/${this.user.slug}`,
|
||||
icon: 'user'
|
||||
icon: 'user',
|
||||
},
|
||||
{
|
||||
name: this.$t('settings.name'),
|
||||
path: `/settings`,
|
||||
icon: 'cogs'
|
||||
}
|
||||
icon: 'cogs',
|
||||
},
|
||||
]
|
||||
if (this.isModerator) {
|
||||
routes.push({
|
||||
name: this.$t('moderation.name'),
|
||||
path: `/moderation`,
|
||||
icon: 'balance-scale'
|
||||
icon: 'balance-scale',
|
||||
})
|
||||
}
|
||||
if (this.isAdmin) {
|
||||
routes.push({
|
||||
name: this.$t('admin.name'),
|
||||
path: `/admin`,
|
||||
icon: 'shield'
|
||||
icon: 'shield',
|
||||
})
|
||||
}
|
||||
return routes
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
...mapActions({
|
||||
quickSearchClear: 'search/quickClear',
|
||||
quickSearch: 'search/quickSearch'
|
||||
quickSearch: 'search/quickSearch',
|
||||
}),
|
||||
goToPost(item) {
|
||||
this.$nextTick(() => {
|
||||
this.$router.push({
|
||||
name: 'post-id-slug',
|
||||
params: { id: item.id, slug: item.slug }
|
||||
params: { id: item.id, slug: item.slug },
|
||||
})
|
||||
})
|
||||
},
|
||||
@ -205,8 +204,8 @@ export default {
|
||||
return this.$route.path === url
|
||||
}
|
||||
return this.$route.path.indexOf(url) === 0
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -3,48 +3,48 @@ module.exports = [
|
||||
name: 'English',
|
||||
code: 'en',
|
||||
iso: 'en-US',
|
||||
enabled: true
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
name: 'Deutsch',
|
||||
code: 'de',
|
||||
iso: 'de-DE',
|
||||
enabled: true
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
name: 'Nederlands',
|
||||
code: 'nl',
|
||||
iso: 'nl-NL',
|
||||
enabled: true
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
name: 'Français',
|
||||
code: 'fr',
|
||||
iso: 'fr-FR',
|
||||
enabled: true
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
name: 'Italiano',
|
||||
code: 'it',
|
||||
iso: 'it-IT',
|
||||
enabled: true
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
name: 'Español',
|
||||
code: 'es',
|
||||
iso: 'es-ES',
|
||||
enabled: true
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
name: 'Português',
|
||||
code: 'pt',
|
||||
iso: 'pt-PT',
|
||||
enabled: true
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
name: 'Polski',
|
||||
code: 'pl',
|
||||
iso: 'pl-PL',
|
||||
enabled: true
|
||||
}
|
||||
enabled: true,
|
||||
},
|
||||
]
|
||||
|
||||
@ -6,7 +6,7 @@ export default function(options = {}) {
|
||||
params: { id, slug },
|
||||
redirect,
|
||||
error,
|
||||
app: { apolloProvider }
|
||||
app: { apolloProvider },
|
||||
} = context
|
||||
const idOrSlug = id || slug
|
||||
|
||||
@ -27,6 +27,6 @@ export default function(options = {}) {
|
||||
if (resource) return redirect(`/${path}/${resource.id}/${resource.slug}`)
|
||||
|
||||
return error({ statusCode: 404, message })
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,11 +2,11 @@ export default {
|
||||
head() {
|
||||
return {
|
||||
htmlAttrs: {
|
||||
lang: this.$i18n.locale()
|
||||
lang: this.$i18n.locale(),
|
||||
},
|
||||
bodyAttrs: {
|
||||
class: `page-name-${this.$route.name}`
|
||||
}
|
||||
class: `page-name-${this.$route.name}`,
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ const styleguidePath = '../Nitro-Styleguide'
|
||||
const styleguideStyles = process.env.STYLEGUIDE_DEV
|
||||
? [
|
||||
`${styleguidePath}/src/system/styles/main.scss`,
|
||||
`${styleguidePath}/src/system/styles/shared.scss`
|
||||
`${styleguidePath}/src/system/styles/shared.scss`,
|
||||
]
|
||||
: '@human-connection/styleguide/dist/shared.scss'
|
||||
|
||||
@ -20,24 +20,16 @@ module.exports = {
|
||||
|
||||
transition: {
|
||||
name: 'slide-up',
|
||||
mode: 'out-in'
|
||||
mode: 'out-in',
|
||||
},
|
||||
|
||||
env: {
|
||||
// pages which do NOT require a login
|
||||
publicPages: [
|
||||
'login',
|
||||
'logout',
|
||||
'register',
|
||||
'signup',
|
||||
'reset',
|
||||
'reset-token',
|
||||
'pages-slug'
|
||||
],
|
||||
publicPages: ['login', 'logout', 'register', 'signup', 'reset', 'reset-token', 'pages-slug'],
|
||||
// pages to keep alive
|
||||
keepAlivePages: ['index'],
|
||||
// active locales
|
||||
locales: require('./locales')
|
||||
locales: require('./locales'),
|
||||
},
|
||||
/*
|
||||
** Headers of the page
|
||||
@ -48,9 +40,9 @@ module.exports = {
|
||||
meta: [
|
||||
{ charset: 'utf-8' },
|
||||
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
||||
{ hid: 'description', name: 'description', content: pkg.description }
|
||||
{ hid: 'description', name: 'description', content: pkg.description },
|
||||
],
|
||||
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }]
|
||||
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
|
||||
},
|
||||
|
||||
/*
|
||||
@ -59,7 +51,7 @@ module.exports = {
|
||||
loading: {
|
||||
color: '#86b31e',
|
||||
height: '2px',
|
||||
duration: 20000
|
||||
duration: 20000,
|
||||
},
|
||||
|
||||
/*
|
||||
@ -71,7 +63,7 @@ module.exports = {
|
||||
** Global processed styles
|
||||
*/
|
||||
styleResources: {
|
||||
scss: styleguideStyles
|
||||
scss: styleguideStyles,
|
||||
},
|
||||
|
||||
/*
|
||||
@ -80,7 +72,7 @@ module.exports = {
|
||||
plugins: [
|
||||
{
|
||||
src: `~/plugins/styleguide${process.env.STYLEGUIDE_DEV ? '-dev' : ''}.js`,
|
||||
ssr: true
|
||||
ssr: true,
|
||||
},
|
||||
{ src: '~/plugins/i18n.js', ssr: true },
|
||||
{ src: '~/plugins/axios.js', ssr: false },
|
||||
@ -88,7 +80,7 @@ module.exports = {
|
||||
{ src: '~/plugins/vue-directives.js', ssr: false },
|
||||
{ src: '~/plugins/v-tooltip.js', ssr: false },
|
||||
{ src: '~/plugins/izi-toast.js', ssr: false },
|
||||
{ src: '~/plugins/vue-filters.js' }
|
||||
{ src: '~/plugins/vue-filters.js' },
|
||||
],
|
||||
|
||||
router: {
|
||||
@ -97,7 +89,7 @@ module.exports = {
|
||||
linkExactActiveClass: 'router-link-exact-active',
|
||||
scrollBehavior: () => {
|
||||
return { x: 0, y: 0 }
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
/*
|
||||
@ -109,7 +101,7 @@ module.exports = {
|
||||
'cookie-universal-nuxt',
|
||||
'@nuxtjs/apollo',
|
||||
'@nuxtjs/axios',
|
||||
'@nuxtjs/style-resources'
|
||||
'@nuxtjs/style-resources',
|
||||
],
|
||||
|
||||
/*
|
||||
@ -118,7 +110,7 @@ module.exports = {
|
||||
axios: {
|
||||
// See https://github.com/nuxt-community/axios-module#options
|
||||
debug: dev,
|
||||
proxy: true
|
||||
proxy: true,
|
||||
},
|
||||
proxy: {
|
||||
'/.well-known/webfinger': {
|
||||
@ -127,8 +119,8 @@ module.exports = {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'X-UI-Request': true,
|
||||
'X-API-TOKEN': process.env.BACKEND_TOKEN || 'NULL'
|
||||
}
|
||||
'X-API-TOKEN': process.env.BACKEND_TOKEN || 'NULL',
|
||||
},
|
||||
},
|
||||
'/activitypub': {
|
||||
// make this configurable (nuxt-dotenv)
|
||||
@ -137,8 +129,8 @@ module.exports = {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'X-UI-Request': true,
|
||||
'X-API-TOKEN': process.env.BACKEND_TOKEN || 'NULL'
|
||||
}
|
||||
'X-API-TOKEN': process.env.BACKEND_TOKEN || 'NULL',
|
||||
},
|
||||
},
|
||||
'/api': {
|
||||
// make this configurable (nuxt-dotenv)
|
||||
@ -148,9 +140,9 @@ module.exports = {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'X-UI-Request': true,
|
||||
'X-API-TOKEN': process.env.BACKEND_TOKEN || 'NULL'
|
||||
}
|
||||
}
|
||||
'X-API-TOKEN': process.env.BACKEND_TOKEN || 'NULL',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// Give apollo module options
|
||||
@ -164,7 +156,7 @@ module.exports = {
|
||||
console.log(
|
||||
'%cError',
|
||||
'background: red; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;',
|
||||
error.message
|
||||
error.message,
|
||||
)
|
||||
},
|
||||
|
||||
@ -177,15 +169,15 @@ module.exports = {
|
||||
// },
|
||||
// required
|
||||
clientConfigs: {
|
||||
default: '~/plugins/apollo-config.js'
|
||||
}
|
||||
default: '~/plugins/apollo-config.js',
|
||||
},
|
||||
},
|
||||
|
||||
manifest: {
|
||||
name: 'Human-Connection.org',
|
||||
description: 'Human-Connection.org',
|
||||
theme_color: '#ffffff',
|
||||
lang: 'de'
|
||||
lang: 'de',
|
||||
},
|
||||
|
||||
/*
|
||||
@ -198,15 +190,10 @@ module.exports = {
|
||||
extend(config, ctx) {
|
||||
if (process.env.STYLEGUIDE_DEV) {
|
||||
const path = require('path')
|
||||
config.resolve.alias['@@'] = path.resolve(
|
||||
__dirname,
|
||||
`${styleguidePath}/src/system`
|
||||
)
|
||||
config.resolve.alias['@@'] = path.resolve(__dirname, `${styleguidePath}/src/system`)
|
||||
config.module.rules.push({
|
||||
resourceQuery: /blockType=docs/,
|
||||
loader: require.resolve(
|
||||
`${styleguidePath}/src/loader/docs-trim-loader.js`
|
||||
)
|
||||
loader: require.resolve(`${styleguidePath}/src/loader/docs-trim-loader.js`),
|
||||
})
|
||||
}
|
||||
|
||||
@ -219,15 +206,15 @@ module.exports = {
|
||||
svgo: {
|
||||
plugins: [
|
||||
{
|
||||
removeViewBox: false
|
||||
removeViewBox: false,
|
||||
},
|
||||
{
|
||||
removeDimensions: true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
removeDimensions: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ export default {
|
||||
return [
|
||||
{
|
||||
name: this.$t('admin.dashboard.name'),
|
||||
path: `/admin`
|
||||
path: `/admin`,
|
||||
},
|
||||
// TODO implement
|
||||
/* {
|
||||
@ -54,19 +54,19 @@ export default {
|
||||
}, */
|
||||
{
|
||||
name: this.$t('admin.categories.name'),
|
||||
path: `/admin/categories`
|
||||
path: `/admin/categories`,
|
||||
},
|
||||
{
|
||||
name: this.$t('admin.tags.name'),
|
||||
path: `/admin/tags`
|
||||
}
|
||||
path: `/admin/tags`,
|
||||
},
|
||||
// TODO implement
|
||||
/* {
|
||||
name: this.$t('admin.settings.name'),
|
||||
path: `/admin/settings`
|
||||
} */
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -21,7 +21,7 @@ import gql from 'graphql-tag'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
Category: []
|
||||
Category: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -31,10 +31,10 @@ export default {
|
||||
name: this.$t('admin.categories.categoryName'),
|
||||
postCount: {
|
||||
label: this.$t('admin.categories.postCount'),
|
||||
align: 'right'
|
||||
}
|
||||
align: 'right',
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
Category: {
|
||||
@ -48,8 +48,8 @@ export default {
|
||||
postCount
|
||||
}
|
||||
}
|
||||
`)
|
||||
}
|
||||
}
|
||||
`),
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -168,17 +168,17 @@ import HcCountTo from '~/components/CountTo.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcCountTo
|
||||
HcCountTo,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
statistics: {}
|
||||
statistics: {},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isClient() {
|
||||
return process.client
|
||||
}
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.$apollo.queries.statistics.startPolling(5000)
|
||||
@ -199,8 +199,8 @@ export default {
|
||||
countShouts
|
||||
}
|
||||
}
|
||||
`)
|
||||
}
|
||||
}
|
||||
`),
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcEmpty
|
||||
}
|
||||
HcEmpty,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcEmpty
|
||||
}
|
||||
HcEmpty,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcEmpty
|
||||
}
|
||||
HcEmpty,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcEmpty
|
||||
}
|
||||
HcEmpty,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -21,7 +21,7 @@ import gql from 'graphql-tag'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
Tag: []
|
||||
Tag: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -31,14 +31,14 @@ export default {
|
||||
name: 'Name',
|
||||
taggedCountUnique: {
|
||||
label: this.$t('admin.tags.tagCountUnique'),
|
||||
align: 'right'
|
||||
align: 'right',
|
||||
},
|
||||
taggedCount: {
|
||||
label: this.$t('admin.tags.tagCount'),
|
||||
align: 'right'
|
||||
}
|
||||
align: 'right',
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
Tag: {
|
||||
@ -51,8 +51,8 @@ export default {
|
||||
taggedCountUnique
|
||||
}
|
||||
}
|
||||
`)
|
||||
}
|
||||
}
|
||||
`),
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcEmpty
|
||||
}
|
||||
HcEmpty,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -40,14 +40,14 @@ import HcLoadMore from '~/components/LoadMore.vue'
|
||||
export default {
|
||||
components: {
|
||||
HcPostCard,
|
||||
HcLoadMore
|
||||
HcLoadMore,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// Initialize your apollo data
|
||||
Post: [],
|
||||
page: 1,
|
||||
pageSize: 10
|
||||
pageSize: 10,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -56,7 +56,7 @@ export default {
|
||||
},
|
||||
offset() {
|
||||
return (this.page - 1) * this.pageSize
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
uniq(items, field = 'id') {
|
||||
@ -65,7 +65,7 @@ export default {
|
||||
href(post) {
|
||||
return this.$router.resolve({
|
||||
name: 'post-id-slug',
|
||||
params: { id: post.id, slug: post.slug }
|
||||
params: { id: post.id, slug: post.slug },
|
||||
}).href
|
||||
},
|
||||
showMoreContributions() {
|
||||
@ -75,7 +75,7 @@ export default {
|
||||
this.$apollo.queries.Post.fetchMore({
|
||||
variables: {
|
||||
first: this.pageSize,
|
||||
offset: this.offset
|
||||
offset: this.offset,
|
||||
},
|
||||
// Transform the previous result with new data
|
||||
updateQuery: (previousResult, { fetchMoreResult }) => {
|
||||
@ -83,9 +83,9 @@ export default {
|
||||
output.Post = [...previousResult.Post, ...fetchMoreResult.Post]
|
||||
return output
|
||||
},
|
||||
fetchPolicy: 'cache-and-network'
|
||||
fetchPolicy: 'cache-and-network',
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
Post: {
|
||||
@ -136,12 +136,12 @@ export default {
|
||||
variables() {
|
||||
return {
|
||||
first: this.pageSize,
|
||||
offset: 0
|
||||
offset: 0,
|
||||
}
|
||||
},
|
||||
fetchPolicy: 'cache-and-network'
|
||||
}
|
||||
}
|
||||
fetchPolicy: 'cache-and-network',
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -82,9 +82,7 @@
|
||||
:href="$t('login.moreInfoURL')"
|
||||
:title="$t('login.moreInfoHint')"
|
||||
target="_blank"
|
||||
>
|
||||
{{ $t('login.moreInfo') }}
|
||||
</a>
|
||||
>{{ $t('login.moreInfo') }}</a>
|
||||
</ds-space>
|
||||
</form>
|
||||
</ds-flex-item>
|
||||
@ -97,11 +95,9 @@
|
||||
<script>
|
||||
import LocaleSwitch from '~/components/LocaleSwitch'
|
||||
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
LocaleSwitch
|
||||
LocaleSwitch,
|
||||
},
|
||||
layout: 'blank',
|
||||
data() {
|
||||
@ -109,14 +105,14 @@ export default {
|
||||
ready: false,
|
||||
form: {
|
||||
email: '',
|
||||
password: ''
|
||||
}
|
||||
password: '',
|
||||
},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
pending() {
|
||||
return this.$store.getters['auth/pending']
|
||||
}
|
||||
},
|
||||
},
|
||||
asyncData({ store, redirect }) {
|
||||
if (store.getters['auth/isLoggedIn']) {
|
||||
@ -139,8 +135,8 @@ export default {
|
||||
} catch (err) {
|
||||
this.$toast.error(err.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -41,6 +41,6 @@ export default {
|
||||
async beforeCreate() {
|
||||
await this.$store.dispatch('auth/logout')
|
||||
this.$router.replace('/')
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -27,10 +27,10 @@ export default {
|
||||
return [
|
||||
{
|
||||
name: this.$t('moderation.reports.name'),
|
||||
path: `/moderation`
|
||||
}
|
||||
path: `/moderation`,
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -14,9 +14,12 @@
|
||||
slot-scope="scope"
|
||||
>
|
||||
<div v-if="scope.row.type === 'Post'">
|
||||
<nuxt-link :to="{ name: 'post-id-slug', params: { id: scope.row.post.id, slug: scope.row.post.slug } }">
|
||||
<nuxt-link
|
||||
:to="{ name: 'post-id-slug', params: { id: scope.row.post.id, slug: scope.row.post.slug } }"
|
||||
>
|
||||
<b>{{ scope.row.post.title | truncate(50) }}</b>
|
||||
</nuxt-link><br>
|
||||
</nuxt-link>
|
||||
<br>
|
||||
<ds-text
|
||||
size="small"
|
||||
color="soft"
|
||||
@ -25,9 +28,12 @@
|
||||
</ds-text>
|
||||
</div>
|
||||
<div v-else-if="scope.row.type === 'Comment'">
|
||||
<nuxt-link :to="{ name: 'post-id-slug', params: { id: scope.row.comment.post.id, slug: scope.row.comment.post.slug } }">
|
||||
<nuxt-link
|
||||
:to="{ name: 'post-id-slug', params: { id: scope.row.comment.post.id, slug: scope.row.comment.post.slug } }"
|
||||
>
|
||||
<b>{{ scope.row.comment.contentExcerpt | truncate(50) }}</b>
|
||||
</nuxt-link><br>
|
||||
</nuxt-link>
|
||||
<br>
|
||||
<ds-text
|
||||
size="small"
|
||||
color="soft"
|
||||
@ -36,7 +42,9 @@
|
||||
</ds-text>
|
||||
</div>
|
||||
<div v-else>
|
||||
<nuxt-link :to="{ name: 'profile-id-slug', params: { id: scope.row.user.id, slug: scope.row.user.slug } }">
|
||||
<nuxt-link
|
||||
:to="{ name: 'profile-id-slug', params: { id: scope.row.user.id, slug: scope.row.user.slug } }"
|
||||
>
|
||||
<b>{{ scope.row.user.name | truncate(50) }}</b>
|
||||
</nuxt-link>
|
||||
</div>
|
||||
@ -45,9 +53,7 @@
|
||||
slot="type"
|
||||
slot-scope="scope"
|
||||
>
|
||||
<ds-text
|
||||
color="soft"
|
||||
>
|
||||
<ds-text color="soft">
|
||||
<ds-icon
|
||||
v-if="scope.row.type === 'Post'"
|
||||
v-tooltip="{ content: $t('report.contribution.type'), placement: 'right' }"
|
||||
@ -69,7 +75,9 @@
|
||||
slot="submitter"
|
||||
slot-scope="scope"
|
||||
>
|
||||
<nuxt-link :to="{ name: 'profile-id-slug', params: { id: scope.row.submitter.id, slug: scope.row.submitter.slug } }">
|
||||
<nuxt-link
|
||||
:to="{ name: 'profile-id-slug', params: { id: scope.row.submitter.id, slug: scope.row.submitter.slug } }"
|
||||
>
|
||||
{{ scope.row.submitter.name }}
|
||||
</nuxt-link>
|
||||
</template>
|
||||
@ -106,17 +114,16 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import gql from 'graphql-tag'
|
||||
import HcEmpty from '~/components/Empty.vue'
|
||||
import query from '~/graphql/ModerationListQuery.js'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcEmpty
|
||||
HcEmpty,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
Report: []
|
||||
Report: [],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -125,16 +132,16 @@ export default {
|
||||
type: ' ',
|
||||
name: ' ',
|
||||
submitter: this.$t('moderation.reports.submitter'),
|
||||
disabledBy: this.$t('moderation.reports.disabledBy')
|
||||
disabledBy: this.$t('moderation.reports.disabledBy'),
|
||||
// actions: ' '
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
Report: {
|
||||
query,
|
||||
fetchPolicy: 'cache-and-network'
|
||||
}
|
||||
}
|
||||
fetchPolicy: 'cache-and-network',
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -41,7 +41,7 @@ const options = {
|
||||
}
|
||||
`,
|
||||
path: 'post',
|
||||
message: 'This post could not be found'
|
||||
message: 'This post could not be found',
|
||||
}
|
||||
const persistentLinks = PersistentLinks(options)
|
||||
|
||||
@ -57,8 +57,8 @@ export default {
|
||||
children: [
|
||||
{
|
||||
name: this.$t('common.comment', null, 2),
|
||||
path: `/post/${id}/${slug}#comments`
|
||||
}
|
||||
path: `/post/${id}/${slug}#comments`,
|
||||
},
|
||||
// TODO implement
|
||||
/* {
|
||||
name: this.$t('common.letsTalk'),
|
||||
@ -69,20 +69,20 @@ export default {
|
||||
name: this.$t('common.versus'),
|
||||
path: `/post/${id}/${slug}#versus`
|
||||
} */
|
||||
]
|
||||
],
|
||||
},
|
||||
{
|
||||
name: this.$t('common.moreInfo'),
|
||||
path: `/post/${id}/${slug}/more-info`
|
||||
}
|
||||
path: `/post/${id}/${slug}/more-info`,
|
||||
},
|
||||
// TODO implement
|
||||
/* {
|
||||
name: this.$t('common.takeAction'),
|
||||
path: `/post/${id}/${slug}/take-action`
|
||||
} */
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ import HcCommentList from '~/components/comments/CommentList'
|
||||
export default {
|
||||
transition: {
|
||||
name: 'slide-up',
|
||||
mode: 'out-in'
|
||||
mode: 'out-in',
|
||||
},
|
||||
components: {
|
||||
HcTag,
|
||||
@ -103,31 +103,31 @@ export default {
|
||||
HcShoutButton,
|
||||
ContentMenu,
|
||||
HcCommentForm,
|
||||
HcCommentList
|
||||
HcCommentList,
|
||||
},
|
||||
head() {
|
||||
return {
|
||||
title: this.title
|
||||
title: this.title,
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
post: null,
|
||||
ready: false,
|
||||
title: 'loading'
|
||||
title: 'loading',
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
Post(post) {
|
||||
this.post = post[0] || {}
|
||||
this.title = this.post.title
|
||||
}
|
||||
},
|
||||
},
|
||||
async asyncData(context) {
|
||||
const {
|
||||
params,
|
||||
error,
|
||||
app: { apolloProvider, $i18n }
|
||||
app: { apolloProvider, $i18n },
|
||||
} = context
|
||||
const client = apolloProvider.defaultClient
|
||||
const query = gql(`
|
||||
@ -206,7 +206,7 @@ export default {
|
||||
`)
|
||||
const variables = { slug: params.slug }
|
||||
const {
|
||||
data: { Post }
|
||||
data: { Post },
|
||||
} = await client.query({ query, variables })
|
||||
if (Post.length <= 0) {
|
||||
// TODO: custom 404 error page with translations
|
||||
@ -216,7 +216,7 @@ export default {
|
||||
const [post] = Post
|
||||
return {
|
||||
post,
|
||||
title: post.title
|
||||
title: post.title,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@ -229,8 +229,8 @@ export default {
|
||||
methods: {
|
||||
isAuthor(id) {
|
||||
return this.$store.getters['auth/user'].id === id
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -62,16 +62,16 @@ import HcEmpty from '~/components/Empty.vue'
|
||||
export default {
|
||||
transition: {
|
||||
name: 'slide-up',
|
||||
mode: 'out-in'
|
||||
mode: 'out-in',
|
||||
},
|
||||
components: {
|
||||
HcPostCard,
|
||||
HcEmpty
|
||||
HcEmpty,
|
||||
},
|
||||
computed: {
|
||||
post() {
|
||||
return this.Post ? this.Post[0] || {} : {}
|
||||
}
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
Post: {
|
||||
@ -128,11 +128,11 @@ export default {
|
||||
},
|
||||
variables() {
|
||||
return {
|
||||
slug: this.$route.params.slug
|
||||
slug: this.$route.params.slug,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcEmpty
|
||||
}
|
||||
HcEmpty,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -13,12 +13,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import gql from 'graphql-tag'
|
||||
import HcContributionForm from '~/components/ContributionForm'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcContributionForm
|
||||
}
|
||||
HcContributionForm,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -18,7 +18,7 @@ import HcContributionForm from '~/components/ContributionForm'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcContributionForm
|
||||
HcContributionForm,
|
||||
},
|
||||
computed: {
|
||||
user() {
|
||||
@ -29,14 +29,14 @@ export default {
|
||||
},
|
||||
contribution() {
|
||||
return this.Post ? this.Post[0] : {}
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
contribution() {
|
||||
if (this.author.id !== this.user.id) {
|
||||
throw new Error(`You can't edit that!`)
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
Post: {
|
||||
@ -71,11 +71,11 @@ export default {
|
||||
},
|
||||
variables() {
|
||||
return {
|
||||
id: this.$route.params.id || 'p1'
|
||||
id: this.$route.params.id || 'p1',
|
||||
}
|
||||
},
|
||||
fetchPolicy: 'cache-and-network'
|
||||
}
|
||||
}
|
||||
fetchPolicy: 'cache-and-network',
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -24,11 +24,11 @@ const options = {
|
||||
}
|
||||
`,
|
||||
message: 'This user could not be found',
|
||||
path: 'profile'
|
||||
path: 'profile',
|
||||
}
|
||||
const persistentLinks = PersistentLinks(options)
|
||||
|
||||
export default {
|
||||
mixins: [persistentLinks]
|
||||
mixins: [persistentLinks],
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -337,18 +337,18 @@ export default {
|
||||
HcBadges,
|
||||
HcLoadMore,
|
||||
HcEmpty,
|
||||
ContentMenu
|
||||
ContentMenu,
|
||||
},
|
||||
transition: {
|
||||
name: 'slide-up',
|
||||
mode: 'out-in'
|
||||
mode: 'out-in',
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
User: [],
|
||||
voted: false,
|
||||
page: 1,
|
||||
pageSize: 6
|
||||
pageSize: 6,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -367,8 +367,7 @@ export default {
|
||||
},
|
||||
hasMore() {
|
||||
return (
|
||||
this.user.contributions &&
|
||||
this.user.contributions.length < this.user.contributionsCount
|
||||
this.user.contributions && this.user.contributions.length < this.user.contributionsCount
|
||||
)
|
||||
},
|
||||
activePosts() {
|
||||
@ -381,9 +380,7 @@ export default {
|
||||
const { socialMedia = [] } = this.user
|
||||
return socialMedia.map(socialMedia => {
|
||||
const { url } = socialMedia
|
||||
const matches = url.match(
|
||||
/^(?:https?:\/\/)?(?:[^@\n])?(?:www\.)?([^:\/\n?]+)/g
|
||||
)
|
||||
const matches = url.match(/^(?:https?:\/\/)?(?:[^@\n])?(?:www\.)?([^:/\n?]+)/g)
|
||||
const [domain] = matches || []
|
||||
const favicon = domain ? `${domain}/favicon.ico` : null
|
||||
const username = url.split('/').pop()
|
||||
@ -393,14 +390,14 @@ export default {
|
||||
userName() {
|
||||
const { name } = this.user || {}
|
||||
return name || this.$t('profile.userAnonym')
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
User(val) {
|
||||
if (!val || !val.length) {
|
||||
throw new Error('User not found!')
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
uniq(items, field = 'id') {
|
||||
@ -418,20 +415,20 @@ export default {
|
||||
variables: {
|
||||
slug: this.$route.params.slug,
|
||||
first: this.pageSize,
|
||||
offset: this.offset
|
||||
offset: this.offset,
|
||||
},
|
||||
// Transform the previous result with new data
|
||||
updateQuery: (previousResult, { fetchMoreResult }) => {
|
||||
let output = { User: this.User }
|
||||
output.User[0].contributions = [
|
||||
...previousResult.User[0].contributions,
|
||||
...fetchMoreResult.User[0].contributions
|
||||
...fetchMoreResult.User[0].contributions,
|
||||
]
|
||||
return output
|
||||
},
|
||||
fetchPolicy: 'cache-and-network'
|
||||
fetchPolicy: 'cache-and-network',
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
User: {
|
||||
@ -442,12 +439,12 @@ export default {
|
||||
return {
|
||||
slug: this.$route.params.slug,
|
||||
first: this.pageSize,
|
||||
offset: 0
|
||||
offset: 0,
|
||||
}
|
||||
},
|
||||
fetchPolicy: 'cache-and-network'
|
||||
}
|
||||
}
|
||||
fetchPolicy: 'cache-and-network',
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -29,16 +29,16 @@ export default {
|
||||
return [
|
||||
{
|
||||
name: this.$t('settings.data.name'),
|
||||
path: `/settings`
|
||||
path: `/settings`,
|
||||
},
|
||||
{
|
||||
name: this.$t('settings.security.name'),
|
||||
path: `/settings/security`
|
||||
path: `/settings/security`,
|
||||
},
|
||||
{
|
||||
name: this.$t('settings.social-media.name'),
|
||||
path: `/settings/my-social-media`
|
||||
}
|
||||
path: `/settings/my-social-media`,
|
||||
},
|
||||
// TODO implement
|
||||
/* {
|
||||
name: this.$t('settings.invites.name'),
|
||||
@ -66,7 +66,7 @@ export default {
|
||||
},
|
||||
} */
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcEmpty
|
||||
}
|
||||
HcEmpty,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcEmpty
|
||||
}
|
||||
HcEmpty,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { mount, createLocalVue } from '@vue/test-utils'
|
||||
import index from './index.vue'
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
|
||||
@ -10,7 +9,6 @@ localVue.use(Vuex)
|
||||
localVue.use(Styleguide)
|
||||
|
||||
describe('index.vue', () => {
|
||||
let Wrapper
|
||||
let store
|
||||
let mocks
|
||||
let getters
|
||||
@ -28,27 +26,27 @@ describe('index.vue', () => {
|
||||
id: 'u1',
|
||||
name: 'Peter',
|
||||
locationName: 'Berlin',
|
||||
about: 'Smth'
|
||||
}
|
||||
}
|
||||
})
|
||||
about: 'Smth',
|
||||
},
|
||||
},
|
||||
}),
|
||||
},
|
||||
$toast: {
|
||||
error: jest.fn(),
|
||||
success: jest.fn()
|
||||
}
|
||||
success: jest.fn(),
|
||||
},
|
||||
}
|
||||
getters = {
|
||||
'auth/user': () => {
|
||||
return {}
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
describe('mount', () => {
|
||||
const Wrapper = () => {
|
||||
store = new Vuex.Store({
|
||||
getters
|
||||
getters,
|
||||
})
|
||||
return mount(index, { store, mocks, localVue })
|
||||
}
|
||||
|
||||
@ -51,11 +51,11 @@ import gql from 'graphql-tag'
|
||||
|
||||
import { mapGetters, mapMutations } from 'vuex'
|
||||
import { CancelToken } from 'axios'
|
||||
import find from 'lodash/find'
|
||||
|
||||
let timeout
|
||||
const mapboxToken = process.env.MAPBOX_TOKEN
|
||||
|
||||
/*
|
||||
const query = gql`
|
||||
query getUser($id: ID) {
|
||||
User(id: $id) {
|
||||
@ -66,15 +66,11 @@ const query = gql`
|
||||
}
|
||||
}
|
||||
`
|
||||
*/
|
||||
|
||||
const mutation = gql`
|
||||
mutation($id: ID!, $name: String, $locationName: String, $about: String) {
|
||||
UpdateUser(
|
||||
id: $id
|
||||
name: $name
|
||||
locationName: $locationName
|
||||
about: $about
|
||||
) {
|
||||
UpdateUser(id: $id, name: $name, locationName: $locationName, about: $about) {
|
||||
id
|
||||
name
|
||||
locationName
|
||||
@ -90,12 +86,12 @@ export default {
|
||||
cities: [],
|
||||
loadingData: false,
|
||||
loadingGeo: false,
|
||||
formData: {}
|
||||
formData: {},
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
currentUser: 'auth/user'
|
||||
currentUser: 'auth/user',
|
||||
}),
|
||||
form: {
|
||||
get: function() {
|
||||
@ -104,12 +100,12 @@ export default {
|
||||
},
|
||||
set: function(formData) {
|
||||
this.formData = formData
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
...mapMutations({
|
||||
setCurrentUser: 'auth/SET_USER'
|
||||
setCurrentUser: 'auth/SET_USER',
|
||||
}),
|
||||
async submit() {
|
||||
this.loadingData = true
|
||||
@ -117,13 +113,13 @@ export default {
|
||||
let { locationName } = this.formData
|
||||
locationName = locationName && (locationName['label'] || locationName)
|
||||
try {
|
||||
const { data } = await this.$apollo.mutate({
|
||||
await this.$apollo.mutate({
|
||||
mutation,
|
||||
variables: {
|
||||
id: this.currentUser.id,
|
||||
name,
|
||||
locationName,
|
||||
about
|
||||
about,
|
||||
},
|
||||
update: (store, { data: { UpdateUser } }) => {
|
||||
const { name, locationName, about } = UpdateUser
|
||||
@ -131,9 +127,9 @@ export default {
|
||||
...this.currentUser,
|
||||
name,
|
||||
locationName,
|
||||
about
|
||||
about,
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
this.$toast.success(this.$t('settings.data.success'))
|
||||
} catch (err) {
|
||||
@ -147,12 +143,7 @@ export default {
|
||||
timeout = setTimeout(() => this.requestGeoData(value), 500)
|
||||
},
|
||||
processCityResults(res) {
|
||||
if (
|
||||
!res ||
|
||||
!res.data ||
|
||||
!res.data.features ||
|
||||
!res.data.features.length
|
||||
) {
|
||||
if (!res || !res.data || !res.data.features || !res.data.features.length) {
|
||||
return []
|
||||
}
|
||||
let output = []
|
||||
@ -160,7 +151,7 @@ export default {
|
||||
output.push({
|
||||
label: item.place_name,
|
||||
value: item.place_name,
|
||||
id: item.id
|
||||
id: item.id,
|
||||
})
|
||||
})
|
||||
|
||||
@ -188,8 +179,8 @@ export default {
|
||||
.get(
|
||||
`https://api.mapbox.com/geocoding/v5/mapbox.places/${place}.json?access_token=${mapboxToken}&types=region,place,country&language=${lang}`,
|
||||
{
|
||||
cancelToken: this.axiosSource.token
|
||||
}
|
||||
cancelToken: this.axiosSource.token,
|
||||
},
|
||||
)
|
||||
.then(res => {
|
||||
this.cities = this.processCityResults(res)
|
||||
@ -197,7 +188,7 @@ export default {
|
||||
.finally(() => {
|
||||
this.loadingGeo = false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcEmpty
|
||||
}
|
||||
HcEmpty,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcEmpty
|
||||
}
|
||||
HcEmpty,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -12,7 +12,7 @@ import HcEmpty from '~/components/Empty.vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcEmpty
|
||||
}
|
||||
HcEmpty,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { mount, createLocalVue } from '@vue/test-utils'
|
||||
import MySocialMedia from './my-social-media.vue'
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
|
||||
@ -11,7 +10,6 @@ localVue.use(Styleguide)
|
||||
|
||||
describe('my-social-media.vue', () => {
|
||||
let wrapper
|
||||
let Wrapper
|
||||
let store
|
||||
let mocks
|
||||
let getters
|
||||
@ -27,25 +25,25 @@ describe('my-social-media.vue', () => {
|
||||
.fn()
|
||||
.mockRejectedValue({ message: 'Ouch!' })
|
||||
.mockResolvedValueOnce({
|
||||
data: { CreateSocialMeda: { id: 's1', url: socialMediaUrl } }
|
||||
})
|
||||
data: { CreateSocialMeda: { id: 's1', url: socialMediaUrl } },
|
||||
}),
|
||||
},
|
||||
$toast: {
|
||||
error: jest.fn(),
|
||||
success: jest.fn()
|
||||
}
|
||||
success: jest.fn(),
|
||||
},
|
||||
}
|
||||
getters = {
|
||||
'auth/user': () => {
|
||||
return {}
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
describe('mount', () => {
|
||||
const Wrapper = () => {
|
||||
store = new Vuex.Store({
|
||||
getters
|
||||
getters,
|
||||
})
|
||||
return mount(MySocialMedia, { store, mocks, localVue })
|
||||
}
|
||||
@ -60,9 +58,9 @@ describe('my-social-media.vue', () => {
|
||||
getters = {
|
||||
'auth/user': () => {
|
||||
return {
|
||||
socialMedia: [{ id: 's1', url: socialMediaUrl }]
|
||||
socialMedia: [{ id: 's1', url: socialMediaUrl }],
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
@ -80,20 +78,20 @@ describe('my-social-media.vue', () => {
|
||||
.fn()
|
||||
.mockRejectedValue({ message: 'Ouch!' })
|
||||
.mockResolvedValueOnce({
|
||||
data: { DeleteSocialMeda: { id: 's1', url: socialMediaUrl } }
|
||||
})
|
||||
data: { DeleteSocialMeda: { id: 's1', url: socialMediaUrl } },
|
||||
}),
|
||||
},
|
||||
$toast: {
|
||||
error: jest.fn(),
|
||||
success: jest.fn()
|
||||
}
|
||||
success: jest.fn(),
|
||||
},
|
||||
}
|
||||
getters = {
|
||||
'auth/user': () => {
|
||||
return {
|
||||
socialMedia: [{ id: 's1', url: socialMediaUrl }]
|
||||
socialMedia: [{ id: 's1', url: socialMediaUrl }],
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@ -22,7 +22,8 @@
|
||||
/>
|
||||
{{ link.url }}
|
||||
</a>
|
||||
<span class="layout-leave-active">|</span>
|
||||
|
||||
<span class="layout-leave-active">|</span>
|
||||
<ds-icon
|
||||
name="edit"
|
||||
class="layout-leave-active"
|
||||
@ -65,33 +66,31 @@ import HcImage from '~/components/Image'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HcImage
|
||||
HcImage,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
value: ''
|
||||
value: '',
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
currentUser: 'auth/user'
|
||||
currentUser: 'auth/user',
|
||||
}),
|
||||
socialMediaLinks() {
|
||||
const { socialMedia = [] } = this.currentUser
|
||||
return socialMedia.map(socialMedia => {
|
||||
const { id, url } = socialMedia
|
||||
const matches = url.match(
|
||||
/^(?:https?:\/\/)?(?:[^@\n])?(?:www\.)?([^:\/\n?]+)/g
|
||||
)
|
||||
const matches = url.match(/^(?:https?:\/\/)?(?:[^@\n])?(?:www\.)?([^:/\n?]+)/g)
|
||||
const [domain] = matches || []
|
||||
const favicon = domain ? `${domain}/favicon.ico` : null
|
||||
return { id, url, favicon }
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
...mapMutations({
|
||||
setCurrentUser: 'auth/SET_USER'
|
||||
setCurrentUser: 'auth/SET_USER',
|
||||
}),
|
||||
handleAddSocialMedia() {
|
||||
this.$apollo
|
||||
@ -105,22 +104,19 @@ export default {
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
url: this.value
|
||||
url: this.value,
|
||||
},
|
||||
update: (store, { data }) => {
|
||||
const socialMedia = [
|
||||
...this.currentUser.socialMedia,
|
||||
data.CreateSocialMedia
|
||||
]
|
||||
const socialMedia = [...this.currentUser.socialMedia, data.CreateSocialMedia]
|
||||
this.setCurrentUser({
|
||||
...this.currentUser,
|
||||
socialMedia
|
||||
socialMedia,
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
this.$toast.success(this.$t('settings.social-media.successAdd')),
|
||||
(this.value = '')
|
||||
this.$toast.success(this.$t('settings.social-media.successAdd'))
|
||||
this.value = ''
|
||||
})
|
||||
.catch(error => {
|
||||
this.$toast.error(error.message)
|
||||
@ -138,17 +134,17 @@ export default {
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
id: link.id
|
||||
id: link.id,
|
||||
},
|
||||
update: (store, { data }) => {
|
||||
const socialMedia = this.currentUser.socialMedia.filter(
|
||||
element => element.id !== link.id
|
||||
element => element.id !== link.id,
|
||||
)
|
||||
this.setCurrentUser({
|
||||
...this.currentUser,
|
||||
socialMedia
|
||||
socialMedia,
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
this.$toast.success(this.$t('settings.social-media.successDelete'))
|
||||
@ -156,8 +152,8 @@ export default {
|
||||
.catch(error => {
|
||||
this.$toast.error(error.message)
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -5,12 +5,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import HcEmpty from '~/components/Empty.vue'
|
||||
import ChangePassword from '~/components/Password/Change'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ChangePassword
|
||||
}
|
||||
ChangePassword,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -3,11 +3,11 @@ export default ({ app }) => {
|
||||
return {
|
||||
httpEndpoint: process.server ? backendUrl : '/api',
|
||||
httpLinkOptions: {
|
||||
credentials: 'same-origin'
|
||||
credentials: 'same-origin',
|
||||
},
|
||||
credentials: true,
|
||||
tokenName: 'human-connection-token',
|
||||
persisting: false,
|
||||
websocketsOnly: false
|
||||
websocketsOnly: false,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import vuexI18n from 'vuex-i18n/dist/vuex-i18n.umd.js'
|
||||
import { debounce, isEmpty, find } from 'lodash'
|
||||
import { isEmpty, find } from 'lodash'
|
||||
|
||||
/**
|
||||
* TODO: Refactor and simplify browser detection
|
||||
@ -48,11 +47,9 @@ export default ({ app, req, cookie, store }) => {
|
||||
onTranslationNotFound: function(locale, key) {
|
||||
if (debug) {
|
||||
/* eslint-disable-next-line no-console */
|
||||
console.warn(
|
||||
`vuex-i18n :: Key '${key}' not found for locale '${locale}'`
|
||||
)
|
||||
console.warn(`vuex-i18n :: Key '${key}' not found for locale '${locale}'`)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
// register the fallback locales
|
||||
@ -80,9 +77,7 @@ export default ({ app, req, cookie, store }) => {
|
||||
}
|
||||
|
||||
const availableLocales = process.env.locales.filter(lang => !!lang.enabled)
|
||||
const locale = find(availableLocales, ['code', userLocale])
|
||||
? userLocale
|
||||
: 'en'
|
||||
const locale = find(availableLocales, ['code', userLocale]) ? userLocale : 'en'
|
||||
|
||||
if (locale !== 'en') {
|
||||
Vue.i18n.add(locale, require(`~/locales/${locale}.json`))
|
||||
|
||||
@ -8,6 +8,6 @@ export default ({ app }) => {
|
||||
position: 'bottomRight',
|
||||
transitionIn: 'bounceInLeft',
|
||||
layout: 2,
|
||||
theme: 'dark'
|
||||
theme: 'dark',
|
||||
})
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ if (!process.server) {
|
||||
if (this.$metaInfo && !keepAlivePages.includes(lastRoute)) {
|
||||
this.$destroy()
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
Vue.use(keepAliveHook)
|
||||
|
||||
@ -4,13 +4,13 @@ import VTooltip from 'v-tooltip'
|
||||
Vue.use(VTooltip, {
|
||||
defaultDelay: {
|
||||
show: 500,
|
||||
hide: 50
|
||||
hide: 50,
|
||||
},
|
||||
defaultOffset: 2,
|
||||
defaultPopperOptions: {
|
||||
removeOnDestroy: true
|
||||
removeOnDestroy: true,
|
||||
},
|
||||
popover: {
|
||||
// defaultArrowClass: 'm-dropdown__arrow'
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@ -10,7 +10,7 @@ export default ({ app }) => {
|
||||
el.focus()
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
Vue.directive('router-link', {
|
||||
@ -28,6 +28,6 @@ export default ({ app }) => {
|
||||
if (binding.clickEventListener) {
|
||||
el.removeEventListener('click', binding.clickEventListener)
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ import Vue from 'vue'
|
||||
|
||||
import { enUS, de, nl, fr, es } from 'date-fns/locale'
|
||||
import format from 'date-fns/format'
|
||||
import formatRelative from 'date-fns/formatRelative'
|
||||
import addSeconds from 'date-fns/addSeconds'
|
||||
import accounting from 'accounting'
|
||||
|
||||
@ -14,7 +13,7 @@ export default ({ app = {} }) => {
|
||||
fr: fr,
|
||||
es: es,
|
||||
pt: es,
|
||||
pl: de
|
||||
pl: de,
|
||||
}
|
||||
const getLocalizedFormat = () => {
|
||||
let locale = app.$i18n.locale()
|
||||
@ -25,22 +24,16 @@ export default ({ app = {} }) => {
|
||||
date: (value, fmt = 'dd. MMM yyyy') => {
|
||||
if (!value) return ''
|
||||
return format(new Date(value), fmt, {
|
||||
locale: getLocalizedFormat()
|
||||
locale: getLocalizedFormat(),
|
||||
})
|
||||
},
|
||||
dateTime: (value, fmt = 'dd. MMM yyyy HH:mm') => {
|
||||
if (!value) return ''
|
||||
return format(new Date(value), fmt, {
|
||||
locale: getLocalizedFormat()
|
||||
locale: getLocalizedFormat(),
|
||||
})
|
||||
},
|
||||
number: (
|
||||
value,
|
||||
precision = 2,
|
||||
thousands = '.',
|
||||
decimals = ',',
|
||||
fallback = null
|
||||
) => {
|
||||
number: (value, precision = 2, thousands = '.', decimals = ',', fallback = null) => {
|
||||
if (isNaN(value) && fallback) {
|
||||
return fallback
|
||||
}
|
||||
@ -99,7 +92,7 @@ export default ({ app = {} }) => {
|
||||
}
|
||||
|
||||
return excerpt
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
// add all methods as filters on each vue component
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user