From 5805792211d2a770e6cc4ad7728247a8319fab3a Mon Sep 17 00:00:00 2001
From: Angelina Filippova
Date: Mon, 30 Mar 2020 18:50:36 +0300
Subject: [PATCH 01/35] Update Import from FS and ListRemotePacks APIs
---
src/api/emojiPacks.js | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/api/emojiPacks.js b/src/api/emojiPacks.js
index cc07b1b6..d2093280 100644
--- a/src/api/emojiPacks.js
+++ b/src/api/emojiPacks.js
@@ -25,8 +25,8 @@ export async function reloadEmoji(host, token) {
export async function importFromFS(host, token) {
return await request({
baseURL: baseName(host),
- url: '/api/pleroma/emoji/packs/import_from_fs',
- method: 'post',
+ url: '/api/pleroma/emoji/packs/import',
+ method: 'get',
headers: authHeaders(token)
})
}
@@ -51,10 +51,9 @@ export async function listPacks(host) {
export async function listRemotePacks(host, token, instance) {
return await request({
baseURL: baseName(host),
- url: `/api/pleroma/emoji/packs/list_from`,
- method: 'post',
- headers: authHeaders(token),
- data: { instance_address: baseName(instance) }
+ url: `/api/pleroma/emoji/packs/remote?url=${baseName(instance)}`,
+ method: 'get',
+ headers: authHeaders(token)
})
}
From 1f488a18be94f116b1c1a61e892c69445ed831bd Mon Sep 17 00:00:00 2001
From: Angelina Filippova
Date: Mon, 30 Mar 2020 19:48:41 +0300
Subject: [PATCH 02/35] Update API for downloading remote packs
---
src/api/emojiPacks.js | 6 +++---
src/store/modules/emojiPacks.js | 3 +++
src/views/emojiPacks/components/RemoteEmojiPack.vue | 10 ++++++----
src/views/emojiPacks/index.vue | 9 ++++++++-
4 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/src/api/emojiPacks.js b/src/api/emojiPacks.js
index d2093280..22d8f7ad 100644
--- a/src/api/emojiPacks.js
+++ b/src/api/emojiPacks.js
@@ -57,17 +57,17 @@ export async function listRemotePacks(host, token, instance) {
})
}
-export async function downloadFrom(host, instance_address, pack_name, as, token) {
+export async function downloadFrom(host, instance, pack_name, as, token) {
if (as.trim() === '') {
as = null
}
return await request({
baseURL: baseName(host),
- url: '/api/pleroma/emoji/packs/download_from',
+ url: '/api/pleroma/emoji/packs/download',
method: 'post',
headers: authHeaders(token),
- data: { instance_address: baseName(instance_address), pack_name, as },
+ data: { url: baseName(instance), name: pack_name, as },
timeout: 0
})
}
diff --git a/src/store/modules/emojiPacks.js b/src/store/modules/emojiPacks.js
index f92e0fa5..3b376769 100644
--- a/src/store/modules/emojiPacks.js
+++ b/src/store/modules/emojiPacks.js
@@ -116,6 +116,9 @@ const packs = {
commit('SET_REMOTE_INSTANCE', remoteInstance)
commit('SET_REMOTE_PACKS', data)
},
+ SetRemoteInstance({ commit }, instance) {
+ commit('SET_REMOTE_INSTANCE', instance)
+ },
async UpdateAndSavePackFile({ commit, getters }, args) {
const result = await updatePackFile(getters.authHost, getters.token, args)
diff --git a/src/views/emojiPacks/components/RemoteEmojiPack.vue b/src/views/emojiPacks/components/RemoteEmojiPack.vue
index 0c9ecaf3..be1bc858 100644
--- a/src/views/emojiPacks/components/RemoteEmojiPack.vue
+++ b/src/views/emojiPacks/components/RemoteEmojiPack.vue
@@ -52,7 +52,7 @@
-
+
{{ isDesktop ? $t('emoji.downloadSharedPack') : $t('emoji.downloadSharedPackMobile') }}
@@ -113,6 +113,9 @@ export default {
loadRemotePack() {
return this.$store.state.emojiPacks.activeCollapseItems.includes(this.name)
},
+ remoteInstanceAddress() {
+ return this.$store.state.emojiPacks.remoteInstance
+ },
share: {
get() { return this.pack.pack['share-files'] },
set(value) {
@@ -171,11 +174,10 @@ export default {
}
},
methods: {
- downloadFromInstance(url) {
- const instanceAddress = `${new URL(url).protocol}//${new URL(url).hostname}`
+ downloadFromInstance() {
this.$store.dispatch(
'DownloadFrom',
- { instanceAddress, packName: this.name, as: this.downloadSharedAs }
+ { instanceAddress: this.remoteInstanceAddress, packName: this.name, as: this.downloadSharedAs }
).then(() => this.$store.dispatch('ReloadEmoji'))
.then(() => this.$store.dispatch('SetLocalEmojiPacks'))
}
diff --git a/src/views/emojiPacks/index.vue b/src/views/emojiPacks/index.vue
index 8154f254..7c4539b5 100644
--- a/src/views/emojiPacks/index.vue
+++ b/src/views/emojiPacks/index.vue
@@ -63,7 +63,6 @@ export default {
components: { LocalEmojiPack, RemoteEmojiPack },
data() {
return {
- remoteInstanceAddress: '',
newPackName: '',
activeLocalPack: [],
activeRemotePack: [],
@@ -89,6 +88,14 @@ export default {
localPacks() {
return this.$store.state.emojiPacks.localPacks
},
+ remoteInstanceAddress: {
+ get() {
+ return this.$store.state.emojiPacks.remoteInstance
+ },
+ set(instance) {
+ this.$store.dispatch('SetRemoteInstance', instance)
+ }
+ },
remotePacks() {
return this.$store.state.emojiPacks.remotePacks
}
From 0e876da85289fbbb2ab15d8e2ce97bdf58539643 Mon Sep 17 00:00:00 2001
From: Angelina Filippova
Date: Tue, 31 Mar 2020 03:18:20 +0300
Subject: [PATCH 03/35] Update emoji APIs for adding, updating and removing
emoji files
---
src/api/emojiPacks.js | 93 ++++++-------------
src/store/modules/emojiPacks.js | 69 ++++++++++----
.../emojiPacks/components/LocalEmojiPack.vue | 4 +-
.../components/NewEmojiUploader.vue | 28 +++---
.../components/SingleEmojiEditor.vue | 60 ++++++------
5 files changed, 128 insertions(+), 126 deletions(-)
diff --git a/src/api/emojiPacks.js b/src/api/emojiPacks.js
index 22d8f7ad..b45dfb11 100644
--- a/src/api/emojiPacks.js
+++ b/src/api/emojiPacks.js
@@ -2,8 +2,6 @@ import request from '@/utils/request'
import { getToken } from '@/utils/auth'
import { baseName } from './utils'
-import _ from 'lodash'
-
export async function deletePack(host, token, name) {
return await request({
baseURL: baseName(host),
@@ -35,7 +33,7 @@ export async function createPack(host, token, name) {
return await request({
baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${name}`,
- method: 'put',
+ method: 'post',
headers: authHeaders(token)
})
}
@@ -72,79 +70,44 @@ export async function downloadFrom(host, instance, pack_name, as, token) {
})
}
-export async function savePackMetadata(host, token, name, new_data) {
+export async function savePackMetadata(host, token, name, metadata) {
return await request({
baseURL: baseName(host),
- url: `/api/pleroma/emoji/packs/${name}/update_metadata`,
- method: 'post',
+ url: `/api/pleroma/emoji/packs/${name}`,
+ method: 'patch',
headers: authHeaders(token),
- data: { name, new_data },
+ data: { metadata },
timeout: 0 // This might take a long time
})
}
-function fileUpdateFormData(d) {
- const data = new FormData()
-
- _.each(d, (v, k) => {
- data.set(k, v)
- })
-
- return data
-}
-
-export async function updatePackFile(host, token, args) {
- let data = null
-
- switch (args.action) {
- case 'add': {
- const { shortcode, file, fileName } = args
-
- data = fileUpdateFormData({
- action: 'add',
- shortcode: shortcode,
- file: file
- })
- if (fileName.trim() !== '') {
- data.set('filename', fileName)
- }
-
- break
- }
-
- case 'update': {
- const { oldName, newName, newFilename } = args
-
- data = fileUpdateFormData({
- action: 'update',
- shortcode: oldName,
- new_shortcode: newName,
- new_filename: newFilename
- })
-
- break
- }
-
- case 'remove': {
- const { name } = args
- data = fileUpdateFormData({
- action: 'remove',
- shortcode: name
- })
-
- break
- }
- }
-
- const { packName } = args
-
+export async function addNewEmojiFile(packName, file, shortcode, filename, host, token) {
return await request({
baseURL: baseName(host),
- url: `/api/pleroma/emoji/packs/${packName}/update_file`,
+ url: `/api/pleroma/emoji/packs/${packName}/files`,
method: 'post',
headers: authHeaders(token),
- data: data,
- timeout: 0
+ data: { file, shortcode, filename: filename || null }
+ })
+}
+
+export async function updateEmojiFile(packName, shortcode, newShortcode, newFilename, force, host, token) {
+ return await request({
+ baseURL: baseName(host),
+ url: `/api/pleroma/emoji/packs/${packName}/files`,
+ method: 'patch',
+ headers: authHeaders(token),
+ data: { shortcode, new_shortcode: newShortcode, new_filename: newFilename, force }
+ })
+}
+
+export async function deleteEmojiFile(packName, shortcode, host, token) {
+ return await request({
+ baseURL: baseName(host),
+ url: `/api/pleroma/emoji/packs/${packName}/files`,
+ method: 'delete',
+ headers: authHeaders(token),
+ data: { shortcode }
})
}
diff --git a/src/store/modules/emojiPacks.js b/src/store/modules/emojiPacks.js
index 3b376769..e4748c26 100644
--- a/src/store/modules/emojiPacks.js
+++ b/src/store/modules/emojiPacks.js
@@ -1,13 +1,16 @@
import {
+ addNewEmojiFile,
+ createPack,
+ deleteEmojiFile,
+ deletePack,
+ downloadFrom,
+ importFromFS,
listPacks,
listRemotePacks,
- downloadFrom,
reloadEmoji,
- createPack,
- deletePack,
savePackMetadata,
- importFromFS,
- updatePackFile } from '@/api/emojiPacks'
+ updateEmojiFile
+} from '@/api/emojiPacks'
import i18n from '@/lang'
import { Message } from 'element-ui'
@@ -49,6 +52,36 @@ const packs = {
}
},
actions: {
+ async AddNewEmojiFile({ commit, getters }, { packName, file, shortcode, filename }) {
+ let result
+ try {
+ result = await addNewEmojiFile(packName, file, shortcode, filename, getters.authHost, getters.token)
+ } catch (_e) {
+ return
+ }
+ Message({
+ message: `${i18n.t('settings.successfullyUpdated')} ${packName} ${i18n.t('settings.metadatLowerCase')}`,
+ type: 'success',
+ duration: 5 * 1000
+ })
+
+ commit('UPDATE_LOCAL_PACK_FILES', { name: packName, files: result.data })
+ },
+ async DeleteEmojiFile({ commit, getters }, { packName, shortcode }) {
+ let result
+ try {
+ result = await deleteEmojiFile(packName, shortcode, getters.authHost, getters.token)
+ } catch (_e) {
+ return
+ }
+ Message({
+ message: `${i18n.t('settings.successfullyUpdated')} ${packName} ${i18n.t('settings.metadatLowerCase')}`,
+ type: 'success',
+ duration: 5 * 1000
+ })
+
+ commit('UPDATE_LOCAL_PACK_FILES', { name: packName, files: result.data })
+ },
async CreatePack({ getters }, { name }) {
await createPack(getters.authHost, getters.token, name)
},
@@ -119,20 +152,20 @@ const packs = {
SetRemoteInstance({ commit }, instance) {
commit('SET_REMOTE_INSTANCE', instance)
},
- async UpdateAndSavePackFile({ commit, getters }, args) {
- const result = await updatePackFile(getters.authHost, getters.token, args)
-
- if (result.status === 200) {
- const { packName } = args
-
- Message({
- message: `${i18n.t('settings.successfullyUpdated')} ${packName} ${i18n.t('settings.metadatLowerCase')}`,
- type: 'success',
- duration: 5 * 1000
- })
-
- commit('UPDATE_LOCAL_PACK_FILES', { name: packName, files: result.data })
+ async UpdateEmojiFile({ commit, getters }, { packName, shortcode, newShortcode, newFilename, force }) {
+ let result
+ try {
+ result = await updateEmojiFile(packName, shortcode, newShortcode, newFilename, force, getters.authHost, getters.token)
+ } catch (_e) {
+ return
}
+ Message({
+ message: `${i18n.t('settings.successfullyUpdated')} ${packName} ${i18n.t('settings.metadatLowerCase')}`,
+ type: 'success',
+ duration: 5 * 1000
+ })
+
+ commit('UPDATE_LOCAL_PACK_FILES', { name: packName, files: result.data })
},
async UpdateLocalPackVal({ commit }, args) {
commit('UPDATE_LOCAL_PACK_VAL', args)
diff --git a/src/views/emojiPacks/components/LocalEmojiPack.vue b/src/views/emojiPacks/components/LocalEmojiPack.vue
index 917ff4dd..7d997e31 100644
--- a/src/views/emojiPacks/components/LocalEmojiPack.vue
+++ b/src/views/emojiPacks/components/LocalEmojiPack.vue
@@ -96,9 +96,9 @@ export default {
if (this.isMobile) {
return '90px'
} else if (this.isTablet) {
- return '120px'
+ return '155px'
} else {
- return '120px'
+ return '155px'
}
},
share: {
diff --git a/src/views/emojiPacks/components/NewEmojiUploader.vue b/src/views/emojiPacks/components/NewEmojiUploader.vue
index f364b49e..8e86f243 100644
--- a/src/views/emojiPacks/components/NewEmojiUploader.vue
+++ b/src/views/emojiPacks/components/NewEmojiUploader.vue
@@ -52,20 +52,22 @@ export default {
}
},
methods: {
- uploadEmoji({ file }) {
- this.$store.dispatch('UpdateAndSavePackFile', {
- action: 'add',
- packName: this.packName,
- shortcode: this.shortcode,
- file: file || this.imageUploadURL,
- fileName: this.customFileName
- }).then(() => {
- this.shortcode = ''
- this.imageUploadURL = ''
- this.customFileName = ''
+ async uploadEmoji({ file }) {
+ try {
+ this.$store.dispatch('AddNewEmojiFile', {
+ packName: this.packName,
+ file: file || this.imageUploadURL,
+ shortcode: this.shortcode,
+ filename: this.customFileName
+ })
+ } catch (e) {
+ return
+ }
+ this.shortcode = ''
+ this.imageUploadURL = ''
+ this.customFileName = ''
- this.$store.dispatch('ReloadEmoji')
- })
+ this.$store.dispatch('ReloadEmoji')
}
}
}
diff --git a/src/views/emojiPacks/components/SingleEmojiEditor.vue b/src/views/emojiPacks/components/SingleEmojiEditor.vue
index cd0eeb7f..d2237e82 100644
--- a/src/views/emojiPacks/components/SingleEmojiEditor.vue
+++ b/src/views/emojiPacks/components/SingleEmojiEditor.vue
@@ -106,19 +106,22 @@ export default {
}
},
methods: {
- update() {
- this.$store.dispatch('UpdateAndSavePackFile', {
- action: 'update',
- packName: this.packName,
- oldName: this.name,
- newName: this.emojiName,
- newFilename: this.emojiFile
- }).then(() => {
- this.newName = null
- this.newFile = null
+ async update() {
+ try {
+ this.$store.dispatch('UpdateEmojiFile', {
+ packName: this.packName,
+ shortcode: this.name,
+ newShortcode: this.emojiName,
+ newFilename: this.emojiFile,
+ force: true
+ })
+ } catch (e) {
+ return
+ }
+ this.newName = null
+ this.newFile = null
- this.$store.dispatch('ReloadEmoji')
- })
+ this.$store.dispatch('ReloadEmoji')
},
remove() {
this.$confirm('This will delete the emoji, are you sure?', 'Warning', {
@@ -126,10 +129,9 @@ export default {
cancelButtonText: 'No, leave it be',
type: 'warning'
}).then(() => {
- this.$store.dispatch('UpdateAndSavePackFile', {
- action: 'remove',
+ this.$store.dispatch('DeleteEmojiFile', {
packName: this.packName,
- name: this.name
+ shortcode: this.name
}).then(() => {
this.newName = null
this.newFile = null
@@ -139,20 +141,22 @@ export default {
})
},
copyToLocal() {
- this.$store.dispatch('UpdateAndSavePackFile', {
- action: 'add',
- packName: this.copyToLocalPackName,
- shortcode: this.copyToShortcode.trim() !== '' ? this.copyToShortcode.trim() : this.name,
- fileName: this.copyToFilename.trim() !== '' ? this.copyToFilename.trim() : this.file,
- file: this.addressOfEmojiInPack(this.host, this.packName, this.file)
- }).then(() => {
- this.copyToLocalPackName = null
- this.copyToLocalVisible = false
- this.copyToShortcode = ''
- this.copyToFilename = ''
+ try {
+ this.$store.dispatch('AddNewEmojiFile', {
+ packName: this.copyToLocalPackName,
+ file: this.addressOfEmojiInPack(this.host, this.packName, this.file),
+ shortcode: this.copyToShortcode.trim() !== '' ? this.copyToShortcode.trim() : this.name,
+ filename: this.copyToFilename.trim() !== '' ? this.copyToFilename.trim() : this.file
+ })
+ } catch (e) {
+ return
+ }
+ this.copyToLocalPackName = null
+ this.copyToLocalVisible = false
+ this.copyToShortcode = ''
+ this.copyToFilename = ''
- this.$store.dispatch('ReloadEmoji')
- })
+ this.$store.dispatch('ReloadEmoji')
},
addressOfEmojiInPack
}
From d131b5bd880ba01f25080e55e3cd587f2c4f8c11 Mon Sep 17 00:00:00 2001
From: Angelina Filippova
Date: Tue, 31 Mar 2020 22:24:19 +0300
Subject: [PATCH 04/35] Rename shortcode
---
.../emojiPacks/components/LocalEmojiPack.vue | 6 ++---
.../emojiPacks/components/RemoteEmojiPack.vue | 6 ++---
.../components/SingleEmojiEditor.vue | 22 +++++++++----------
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/src/views/emojiPacks/components/LocalEmojiPack.vue b/src/views/emojiPacks/components/LocalEmojiPack.vue
index 7d997e31..c03ba580 100644
--- a/src/views/emojiPacks/components/LocalEmojiPack.vue
+++ b/src/views/emojiPacks/components/LocalEmojiPack.vue
@@ -44,11 +44,11 @@
diff --git a/src/views/emojiPacks/components/RemoteEmojiPack.vue b/src/views/emojiPacks/components/RemoteEmojiPack.vue
index be1bc858..0f31d88c 100644
--- a/src/views/emojiPacks/components/RemoteEmojiPack.vue
+++ b/src/views/emojiPacks/components/RemoteEmojiPack.vue
@@ -36,11 +36,11 @@
diff --git a/src/views/emojiPacks/components/SingleEmojiEditor.vue b/src/views/emojiPacks/components/SingleEmojiEditor.vue
index d2237e82..998a3d79 100644
--- a/src/views/emojiPacks/components/SingleEmojiEditor.vue
+++ b/src/views/emojiPacks/components/SingleEmojiEditor.vue
@@ -54,7 +54,7 @@ export default {
type: String,
required: true
},
- name: {
+ shortcode: {
type: String,
required: true
},
@@ -69,7 +69,7 @@ export default {
},
data() {
return {
- newName: null,
+ newShortcode: null,
newFile: null,
copyToLocalPackName: null,
copyPopoverVisible: false,
@@ -80,14 +80,14 @@ export default {
computed: {
emojiName: {
get() {
- // Return a modified name if it was modified, otherwise return the old name
- return this.newName !== null ? this.newName : this.name
+ // Return a modified shortcode if it was modified, otherwise return the old shortcode
+ return this.newShortcode !== null ? this.newShortcode : this.shortcode
},
- set(val) { this.newName = val }
+ set(val) { this.newShortcode = val }
},
emojiFile: {
get() {
- // Return a modified name if it was modified, otherwise return the old name
+ // Return a modified file name if it was modified, otherwise return the old file name
return this.newFile !== null ? this.newFile : this.file
},
set(val) { this.newFile = val }
@@ -110,7 +110,7 @@ export default {
try {
this.$store.dispatch('UpdateEmojiFile', {
packName: this.packName,
- shortcode: this.name,
+ shortcode: this.shortcode,
newShortcode: this.emojiName,
newFilename: this.emojiFile,
force: true
@@ -118,7 +118,7 @@ export default {
} catch (e) {
return
}
- this.newName = null
+ this.newShortcode = null
this.newFile = null
this.$store.dispatch('ReloadEmoji')
@@ -131,9 +131,9 @@ export default {
}).then(() => {
this.$store.dispatch('DeleteEmojiFile', {
packName: this.packName,
- shortcode: this.name
+ shortcode: this.shortcode
}).then(() => {
- this.newName = null
+ this.newShortcode = null
this.newFile = null
this.$store.dispatch('ReloadEmoji')
@@ -145,7 +145,7 @@ export default {
this.$store.dispatch('AddNewEmojiFile', {
packName: this.copyToLocalPackName,
file: this.addressOfEmojiInPack(this.host, this.packName, this.file),
- shortcode: this.copyToShortcode.trim() !== '' ? this.copyToShortcode.trim() : this.name,
+ shortcode: this.copyToShortcode.trim() !== '' ? this.copyToShortcode.trim() : this.shortcode,
filename: this.copyToFilename.trim() !== '' ? this.copyToFilename.trim() : this.file
})
} catch (e) {
From cea667e0e330959a81ccbff4a863823132065652 Mon Sep 17 00:00:00 2001
From: Angelina Filippova
Date: Tue, 31 Mar 2020 23:05:28 +0300
Subject: [PATCH 05/35] Fix displaing emoji from remote packs
---
src/views/emojiPacks/components/SingleEmojiEditor.vue | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/views/emojiPacks/components/SingleEmojiEditor.vue b/src/views/emojiPacks/components/SingleEmojiEditor.vue
index 998a3d79..a1d2383a 100644
--- a/src/views/emojiPacks/components/SingleEmojiEditor.vue
+++ b/src/views/emojiPacks/components/SingleEmojiEditor.vue
@@ -34,6 +34,7 @@
{{ $t('emoji.copy') }}
{{ $t('emoji.copyToLocalPack') }}
@@ -102,7 +103,7 @@ export default {
return this.$store.state.emojiPacks.localPacks
},
remoteInstance() {
- return this.$store.state.emojiPacks.remoteInstance
+ return new URL(this.$store.state.emojiPacks.remoteInstance).host
}
},
methods: {
@@ -167,6 +168,10 @@ export default {
.copy-popover {
width: 330px
}
+.copy-to-local-pack-button {
+ margin-top: 15px;
+ float: right;
+}
.emoji-buttons {
place-self: center;
min-width: 200px
From 7418324210d8739d65e5ddae6ae7d581bcedfc94 Mon Sep 17 00:00:00 2001
From: Angelina Filippova
Date: Wed, 1 Apr 2020 01:12:31 +0300
Subject: [PATCH 06/35] Make shortcode optional when emoji is uploaded
---
src/api/emojiPacks.js | 5 ++++-
src/views/emojiPacks/components/NewEmojiUploader.vue | 9 +++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/api/emojiPacks.js b/src/api/emojiPacks.js
index b45dfb11..e7b987da 100644
--- a/src/api/emojiPacks.js
+++ b/src/api/emojiPacks.js
@@ -87,7 +87,10 @@ export async function addNewEmojiFile(packName, file, shortcode, filename, host,
url: `/api/pleroma/emoji/packs/${packName}/files`,
method: 'post',
headers: authHeaders(token),
- data: { file, shortcode, filename: filename || null }
+ data: {
+ file,
+ shortcode: shortcode.trim() !== '' ? shortcode : null,
+ filename: filename.trim() !== '' ? filename : null }
})
}
diff --git a/src/views/emojiPacks/components/NewEmojiUploader.vue b/src/views/emojiPacks/components/NewEmojiUploader.vue
index 8e86f243..5229e566 100644
--- a/src/views/emojiPacks/components/NewEmojiUploader.vue
+++ b/src/views/emojiPacks/components/NewEmojiUploader.vue
@@ -1,7 +1,7 @@
-
+
@@ -9,7 +9,7 @@
- {{ $t('emoji.upload') }}
+ {{ $t('emoji.upload') }}
or
@@ -18,7 +18,7 @@
:multiple="false"
:show-file-list="false"
action="add">
-
{{ $t('emoji.clickToUpload') }}
+
{{ $t('emoji.clickToUpload') }}
@@ -46,9 +46,6 @@ export default {
},
isMobile() {
return this.$store.state.app.device === 'mobile'
- },
- shortcodePresent() {
- return this.shortcode.trim() === ''
}
},
methods: {
From ee20731a4e352718a6752ab07e3bbb5bb3247889 Mon Sep 17 00:00:00 2001
From: Angelina Filippova
Date: Wed, 1 Apr 2020 16:28:42 +0300
Subject: [PATCH 07/35] Fix link to remote emoji that was copied to local
instance
---
src/views/emojiPacks/components/SingleEmojiEditor.vue | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/views/emojiPacks/components/SingleEmojiEditor.vue b/src/views/emojiPacks/components/SingleEmojiEditor.vue
index a1d2383a..bb82a298 100644
--- a/src/views/emojiPacks/components/SingleEmojiEditor.vue
+++ b/src/views/emojiPacks/components/SingleEmojiEditor.vue
@@ -145,7 +145,7 @@ export default {
try {
this.$store.dispatch('AddNewEmojiFile', {
packName: this.copyToLocalPackName,
- file: this.addressOfEmojiInPack(this.host, this.packName, this.file),
+ file: this.addressOfEmojiInPack(this.remoteInstance, this.packName, this.file),
shortcode: this.copyToShortcode.trim() !== '' ? this.copyToShortcode.trim() : this.shortcode,
filename: this.copyToFilename.trim() !== '' ? this.copyToFilename.trim() : this.file
})
From 32432e1f6ea29bf7f47524ee825704e937d5304e Mon Sep 17 00:00:00 2001
From: Angelina Filippova
Date: Wed, 1 Apr 2020 16:37:08 +0300
Subject: [PATCH 08/35] Update emoji api functions
---
src/api/emojiPacks.js | 111 +++++++++++++++++++++++-------------------
1 file changed, 60 insertions(+), 51 deletions(-)
diff --git a/src/api/emojiPacks.js b/src/api/emojiPacks.js
index e7b987da..df61dd58 100644
--- a/src/api/emojiPacks.js
+++ b/src/api/emojiPacks.js
@@ -2,20 +2,71 @@ import request from '@/utils/request'
import { getToken } from '@/utils/auth'
import { baseName } from './utils'
-export async function deletePack(host, token, name) {
+export async function addNewEmojiFile(packName, file, shortcode, filename, host, token) {
return await request({
baseURL: baseName(host),
- url: `/api/pleroma/emoji/packs/${name}`,
+ url: `/api/pleroma/emoji/packs/${packName}/files`,
+ method: 'post',
+ headers: authHeaders(token),
+ data: {
+ file,
+ shortcode: shortcode.trim() !== '' ? shortcode : null,
+ filename: filename.trim() !== '' ? filename : null }
+ })
+}
+
+export function addressOfEmojiInPack(host, packName, name) {
+ return `${baseName(host)}/emoji/${packName}/${name}`
+}
+
+export async function createPack(host, token, packName) {
+ return await request({
+ baseURL: baseName(host),
+ url: `/api/pleroma/emoji/packs/${packName}`,
+ method: 'post',
+ headers: authHeaders(token)
+ })
+}
+
+export async function deleteEmojiFile(packName, shortcode, host, token) {
+ return await request({
+ baseURL: baseName(host),
+ url: `/api/pleroma/emoji/packs/${packName}/files`,
+ method: 'delete',
+ headers: authHeaders(token),
+ data: { shortcode }
+ })
+}
+
+export async function deletePack(host, token, packName) {
+ return await request({
+ baseURL: baseName(host),
+ url: `/api/pleroma/emoji/packs/${packName}`,
method: 'delete',
headers: authHeaders(token)
})
}
-export async function reloadEmoji(host, token) {
+export async function downloadFrom(host, instance, packName, as, token) {
+ if (as.trim() === '') {
+ as = null
+ }
+
return await request({
baseURL: baseName(host),
- url: '/api/pleroma/admin/reload_emoji',
+ url: '/api/pleroma/emoji/packs/download',
method: 'post',
+ headers: authHeaders(token),
+ data: { url: baseName(instance), name: packName, as },
+ timeout: 0
+ })
+}
+
+export async function fetchPack(packName, host, token) {
+ return await request({
+ baseURL: baseName(host),
+ url: `/api/pleroma/emoji/packs/${packName}`,
+ method: 'get',
headers: authHeaders(token)
})
}
@@ -29,15 +80,6 @@ export async function importFromFS(host, token) {
})
}
-export async function createPack(host, token, name) {
- return await request({
- baseURL: baseName(host),
- url: `/api/pleroma/emoji/packs/${name}`,
- method: 'post',
- headers: authHeaders(token)
- })
-}
-
export async function listPacks(host) {
return await request({
baseURL: baseName(host),
@@ -55,25 +97,19 @@ export async function listRemotePacks(host, token, instance) {
})
}
-export async function downloadFrom(host, instance, pack_name, as, token) {
- if (as.trim() === '') {
- as = null
- }
-
+export async function reloadEmoji(host, token) {
return await request({
baseURL: baseName(host),
- url: '/api/pleroma/emoji/packs/download',
+ url: '/api/pleroma/admin/reload_emoji',
method: 'post',
- headers: authHeaders(token),
- data: { url: baseName(instance), name: pack_name, as },
- timeout: 0
+ headers: authHeaders(token)
})
}
-export async function savePackMetadata(host, token, name, metadata) {
+export async function savePackMetadata(host, token, packName, metadata) {
return await request({
baseURL: baseName(host),
- url: `/api/pleroma/emoji/packs/${name}`,
+ url: `/api/pleroma/emoji/packs/${packName}`,
method: 'patch',
headers: authHeaders(token),
data: { metadata },
@@ -81,19 +117,6 @@ export async function savePackMetadata(host, token, name, metadata) {
})
}
-export async function addNewEmojiFile(packName, file, shortcode, filename, host, token) {
- return await request({
- baseURL: baseName(host),
- url: `/api/pleroma/emoji/packs/${packName}/files`,
- method: 'post',
- headers: authHeaders(token),
- data: {
- file,
- shortcode: shortcode.trim() !== '' ? shortcode : null,
- filename: filename.trim() !== '' ? filename : null }
- })
-}
-
export async function updateEmojiFile(packName, shortcode, newShortcode, newFilename, force, host, token) {
return await request({
baseURL: baseName(host),
@@ -104,18 +127,4 @@ export async function updateEmojiFile(packName, shortcode, newShortcode, newFile
})
}
-export async function deleteEmojiFile(packName, shortcode, host, token) {
- return await request({
- baseURL: baseName(host),
- url: `/api/pleroma/emoji/packs/${packName}/files`,
- method: 'delete',
- headers: authHeaders(token),
- data: { shortcode }
- })
-}
-
-export function addressOfEmojiInPack(host, packName, name) {
- return `${baseName(host)}/emoji/${packName}/${name}`
-}
-
const authHeaders = (token) => token ? { 'Authorization': `Bearer ${getToken()}` } : {}
From a2072165aacff75e06aad0fa435f7d2de92dc6bc Mon Sep 17 00:00:00 2001
From: Angelina Filippova
Date: Wed, 1 Apr 2020 18:51:17 +0300
Subject: [PATCH 09/35] Implement multipart request for uploading emojis
---
src/api/emojiPacks.js | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/api/emojiPacks.js b/src/api/emojiPacks.js
index df61dd58..61319cec 100644
--- a/src/api/emojiPacks.js
+++ b/src/api/emojiPacks.js
@@ -3,15 +3,21 @@ import { getToken } from '@/utils/auth'
import { baseName } from './utils'
export async function addNewEmojiFile(packName, file, shortcode, filename, host, token) {
+ const data = new FormData()
+ if (filename.trim() !== '') {
+ data.set('filename', filename)
+ }
+ if (shortcode.trim() !== '') {
+ data.set('shortcode', shortcode)
+ }
+ data.set('file', file)
+
return await request({
baseURL: baseName(host),
url: `/api/pleroma/emoji/packs/${packName}/files`,
method: 'post',
headers: authHeaders(token),
- data: {
- file,
- shortcode: shortcode.trim() !== '' ? shortcode : null,
- filename: filename.trim() !== '' ? filename : null }
+ data
})
}
From 96125402cd5b071aee16982de90d7c5549754c6b Mon Sep 17 00:00:00 2001
From: Mark Felder
Date: Wed, 29 Apr 2020 15:45:09 -0500
Subject: [PATCH 10/35] Document we are ending development cycle for 2.0.3
---
CHANGELOG.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index babde03d..d75c63d1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## Unreleased
+## [2.0.3] - 2020-04-29
+
### Added
- Link settings that enable registrations and invites
From 35a9ef2ca91e1b08d730047c5cfbfbd7428c78ef Mon Sep 17 00:00:00 2001
From: Angelina Filippova
Date: Sun, 3 May 2020 20:30:44 +0300
Subject: [PATCH 11/35] Add cofirm message dialog on clicking remove button
---
src/lang/en.js | 3 +-
src/views/settings/components/Inputs.vue | 35 ++++++++++++++++--------
2 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/src/lang/en.js b/src/lang/en.js
index 314672f8..2e504315 100644
--- a/src/lang/en.js
+++ b/src/lang/en.js
@@ -387,7 +387,8 @@ export default {
corsPlug: 'CORS plug config',
instanceReboot: 'Reboot Instance',
restartApp: 'You must restart the instance to apply settings',
- restartSuccess: 'Instance rebooted successfully!'
+ restartSuccess: 'Instance rebooted successfully!',
+ removeSettingConfirmation: 'Are you sure you want to remove this setting\'s value from the database?'
},
invites: {
inviteTokens: 'Invite tokens',
diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue
index 744276dc..c0d62c6d 100644
--- a/src/views/settings/components/Inputs.vue
+++ b/src/views/settings/components/Inputs.vue
@@ -296,17 +296,30 @@ export default {
{ group, key: parentKey, input: setting.key, value: valueForState })
},
async removeSetting() {
- const config = this.settingGroup.key
- ? [{ group: this.settingGroup.group, key: this.settingGroup.key, delete: true, subkeys: [this.setting.key] }]
- : [{ group: this.settingGroup.group, key: this.setting.key, delete: true }]
- try {
- await this.$store.dispatch('RemoveSetting', config)
- } catch (e) {
- return
- }
- this.$message({
- type: 'success',
- message: i18n.t('settings.successfullyRemoved')
+ this.$confirm(
+ this.$t('settings.removeSettingConfirmation'),
+ {
+ confirmButtonText: this.$t('users.ok'),
+ cancelButtonText: this.$t('users.cancel'),
+ type: 'warning'
+ }).then(async() => {
+ const config = this.settingGroup.key
+ ? [{ group: this.settingGroup.group, key: this.settingGroup.key, delete: true, subkeys: [this.setting.key] }]
+ : [{ group: this.settingGroup.group, key: this.setting.key, delete: true }]
+ try {
+ await this.$store.dispatch('RemoveSetting', config)
+ } catch (e) {
+ return
+ }
+ this.$message({
+ type: 'success',
+ message: i18n.t('settings.successfullyRemoved')
+ })
+ }).catch(() => {
+ this.$message({
+ type: 'info',
+ message: this.$t('users.canceled')
+ })
})
},
renderMultipleSelect(type) {
From cd5ebccc2fc7b0193cac9eba63ffc287dc11c024 Mon Sep 17 00:00:00 2001
From: Angelina Filippova
Date: Sun, 3 May 2020 20:35:53 +0300
Subject: [PATCH 12/35] Add confirmation message dialog for removing grouped
settings
---
src/views/settings/components/Setting.vue | 35 ++++++++++++++++-------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/src/views/settings/components/Setting.vue b/src/views/settings/components/Setting.vue
index 9794cc63..7bd28e09 100644
--- a/src/views/settings/components/Setting.vue
+++ b/src/views/settings/components/Setting.vue
@@ -130,17 +130,30 @@ export default {
return marked(desc)
},
async removeSetting(key) {
- const config = this.settingGroup.key
- ? [{ group: this.settingGroup.group, key: this.settingGroup.key, delete: true, subkeys: [key] }]
- : [{ group: this.settingGroup.group, key, delete: true }]
- try {
- await this.$store.dispatch('RemoveSetting', config)
- } catch (e) {
- return
- }
- this.$message({
- type: 'success',
- message: i18n.t('settings.successfullyRemoved')
+ this.$confirm(
+ this.$t('settings.removeSettingConfirmation'),
+ {
+ confirmButtonText: this.$t('users.ok'),
+ cancelButtonText: this.$t('users.cancel'),
+ type: 'warning'
+ }).then(async() => {
+ const config = this.settingGroup.key
+ ? [{ group: this.settingGroup.group, key: this.settingGroup.key, delete: true, subkeys: [key] }]
+ : [{ group: this.settingGroup.group, key, delete: true }]
+ try {
+ await this.$store.dispatch('RemoveSetting', config)
+ } catch (e) {
+ return
+ }
+ this.$message({
+ type: 'success',
+ message: i18n.t('settings.successfullyRemoved')
+ })
+ }).catch(() => {
+ this.$message({
+ type: 'info',
+ message: this.$t('users.canceled')
+ })
})
},
updateSetting(value, tab, input) {
From df178b640750e1ddb7815dc4c68667b34ab46789 Mon Sep 17 00:00:00 2001
From: Angelina Filippova
Date: Mon, 4 May 2020 01:33:57 +0300
Subject: [PATCH 13/35] Fix tabs header position when dialog window is open
---
src/views/settings/styles/main.scss | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/views/settings/styles/main.scss b/src/views/settings/styles/main.scss
index fde17499..abbd3d93 100644
--- a/src/views/settings/styles/main.scss
+++ b/src/views/settings/styles/main.scss
@@ -55,7 +55,7 @@
padding-right: 10px;
}
.el-tabs__header {
- z-index: 3000;
+ z-index: 2002;
}
.esshd-list {
margin: 0;
From 9c6acae0cf233715e53d80cb863fa3e274c1e2e2 Mon Sep 17 00:00:00 2001
From: Angelina Filippova
Date: Wed, 6 May 2020 19:38:02 +0300
Subject: [PATCH 14/35] Use boolean values if value equals 'true' or 'false'
---
src/store/modules/normalizers.js | 9 +++++++++
src/views/settings/components/Inputs.vue | 7 ++++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js
index 6eecebca..c146d60e 100644
--- a/src/store/modules/normalizers.js
+++ b/src/store/modules/normalizers.js
@@ -1,5 +1,14 @@
import _ from 'lodash'
+export const getBooleanValue = value => {
+ if (value === 'true') {
+ return true
+ } else if (value === 'false') {
+ return false
+ }
+ return value
+}
+
export const checkPartialUpdate = (settings, updatedSettings, description) => {
return Object.keys(updatedSettings).reduce((acc, group) => {
acc[group] = Object.keys(updatedSettings[group]).reduce((acc, key) => {
diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue
index c0d62c6d..a756037b 100644
--- a/src/views/settings/components/Inputs.vue
+++ b/src/views/settings/components/Inputs.vue
@@ -132,7 +132,7 @@ import {
RateLimitInput,
RegInvitesInput,
SelectInputWithReducedLabels } from './inputComponents'
-import { processNested } from '@/store/modules/normalizers'
+import { getBooleanValue, processNested } from '@/store/modules/normalizers'
import _ from 'lodash'
import marked from 'marked'
@@ -332,9 +332,10 @@ export default {
)
},
update(value, group, key, parents, input, type, nested) {
+ const updatedValue = getBooleanValue(value)
nested
- ? this.processNestedData(value, group, key, parents)
- : this.updateSetting(value, group, key, input, type)
+ ? this.processNestedData(updatedValue, group, key, parents)
+ : this.updateSetting(updatedValue, group, key, input, type)
},
updateSetting(value, group, key, input, type) {
this.$store.dispatch('UpdateSettings', { group, key, input, value, type })
From 4404e87e3d2354f48769cee28b44484e401ad981 Mon Sep 17 00:00:00 2001
From: Angelina Filippova
Date: Wed, 6 May 2020 20:06:30 +0300
Subject: [PATCH 15/35] Rename component for specific multiple select, remove
ability to create custom values in those selects
---
src/views/settings/components/Inputs.vue | 10 +++++-----
.../{MultipleSelect.vue => SpecificMultipleSelect.vue} | 6 +-----
src/views/settings/components/inputComponents/index.js | 2 +-
3 files changed, 7 insertions(+), 11 deletions(-)
rename src/views/settings/components/inputComponents/{MultipleSelect.vue => SpecificMultipleSelect.vue} (94%)
diff --git a/src/views/settings/components/Inputs.vue b/src/views/settings/components/Inputs.vue
index a756037b..4e45ddae 100644
--- a/src/views/settings/components/Inputs.vue
+++ b/src/views/settings/components/Inputs.vue
@@ -99,12 +99,12 @@
-
+
@@ -126,12 +126,12 @@ import {
EditableKeywordInput,
IconsInput,
MascotsInput,
- MultipleSelect,
ProxyUrlInput,
PruneInput,
RateLimitInput,
RegInvitesInput,
- SelectInputWithReducedLabels } from './inputComponents'
+ SelectInputWithReducedLabels,
+ SpecificMultipleSelect } from './inputComponents'
import { getBooleanValue, processNested } from '@/store/modules/normalizers'
import _ from 'lodash'
import marked from 'marked'
@@ -144,12 +144,12 @@ export default {
EditableKeywordInput,
IconsInput,
MascotsInput,
- MultipleSelect,
ProxyUrlInput,
PruneInput,
RateLimitInput,
RegInvitesInput,
- SelectInputWithReducedLabels
+ SelectInputWithReducedLabels,
+ SpecificMultipleSelect
},
props: {
customLabelWidth: {
diff --git a/src/views/settings/components/inputComponents/MultipleSelect.vue b/src/views/settings/components/inputComponents/SpecificMultipleSelect.vue
similarity index 94%
rename from src/views/settings/components/inputComponents/MultipleSelect.vue
rename to src/views/settings/components/inputComponents/SpecificMultipleSelect.vue
index 66b3aa75..25df11a7 100644
--- a/src/views/settings/components/inputComponents/MultipleSelect.vue
+++ b/src/views/settings/components/inputComponents/SpecificMultipleSelect.vue
@@ -5,8 +5,6 @@
:value="data.value"
:data-search="setting.key || setting.group"
multiple
- filterable
- allow-create
class="input"
@change="updateSetting($event, settingGroup.group, settingGroup.key, setting.key, setting.type)">
@@ -18,8 +16,6 @@
:value="data[setting.key]"
:data-search="setting.key || setting.group"
multiple
- filterable
- allow-create
class="input"
@change="updateSetting($event, settingGroup.group, settingGroup.key, setting.key, setting.type)">
@@ -31,7 +27,7 @@