From 068c9724e45fe801ecedbea491234d0b95695629 Mon Sep 17 00:00:00 2001 From: Edijs Date: Sun, 10 Mar 2019 16:58:12 -0700 Subject: [PATCH 1/3] Added new tab to display versions of BE/FE --- src/boot/after_store.js | 6 ++++++ src/components/settings/settings.js | 17 +++++++++++++++-- src/components/settings/settings.vue | 22 ++++++++++++++++++++++ src/i18n/en.json | 5 +++++ src/modules/instance.js | 6 +++++- src/services/version/version.service.js | 10 ++++++++++ 6 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 src/services/version/version.service.js diff --git a/src/boot/after_store.js b/src/boot/after_store.js index a8e2bf35..dfaf4d68 100644 --- a/src/boot/after_store.js +++ b/src/boot/after_store.js @@ -176,6 +176,12 @@ const afterStoreSetup = ({ store, i18n }) => { const suggestions = metadata.suggestions store.dispatch('setInstanceOption', { name: 'suggestionsEnabled', value: suggestions.enabled }) store.dispatch('setInstanceOption', { name: 'suggestionsWeb', value: suggestions.web }) + + const software = data.software + store.dispatch('setInstanceOption', { name: 'backendVersion', value: software.version }) + + const frontendVersion = window.___pleromafe_commit_hash + store.dispatch('setInstanceOption', { name: 'frontendVersion', value: frontendVersion }) }) } diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index 979457a5..d208ee5a 100644 --- a/src/components/settings/settings.js +++ b/src/components/settings/settings.js @@ -1,8 +1,10 @@ /* eslint-env browser */ +import { filter, trim } from 'lodash' + import TabSwitcher from '../tab_switcher/tab_switcher.js' import StyleSwitcher from '../style_switcher/style_switcher.vue' import InterfaceLanguageSwitcher from '../interface_language_switcher/interface_language_switcher.vue' -import { filter, trim } from 'lodash' +import { parseBackendVersionString, parseFrontendVersionString } from '../../services/version/version.service' const settings = { data () { @@ -78,7 +80,10 @@ const settings = { // Future spec, still not supported in Nightly 63 as of 08/2018 Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype, 'audioTracks'), playVideosInModal: user.playVideosInModal, - useContainFit: user.useContainFit + useContainFit: user.useContainFit, + + backendVersion: instance.backendVersion, + frontendVersion: instance.frontendVersion } }, components: { @@ -98,6 +103,14 @@ const settings = { }, instanceSpecificPanelPresent () { return this.$store.state.instance.showInstanceSpecificPanel } }, + methods: { + parseBackendVersion (versionString) { + return parseBackendVersionString(versionString) + }, + parseFrontendVersion (versionString) { + return parseFrontendVersionString(versionString) + } + }, watch: { hideAttachmentsLocal (value) { this.$store.dispatch('setOption', { name: 'hideAttachments', value }) diff --git a/src/components/settings/settings.vue b/src/components/settings/settings.vue index d2346747..3ca7bdc0 100644 --- a/src/components/settings/settings.vue +++ b/src/components/settings/settings.vue @@ -261,6 +261,28 @@ +
+
+
    +
  • +

    {{$t('settings.version.backend_version')}}

    +
      +
    • +
      +
    • +
    +
  • +
  • +

    {{$t('settings.version.frontend_version')}}

    +
      +
    • +
      +
    • +
    +
  • +
+
+
diff --git a/src/i18n/en.json b/src/i18n/en.json index 01fe2fba..1fe201a4 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -347,6 +347,11 @@ "checkbox": "I have skimmed over terms and conditions", "link": "a nice lil' link" } + }, + "version": { + "title": "Version", + "backend_version": "Backend Version", + "frontend_version": "Frontend Version" } }, "timeline": { diff --git a/src/modules/instance.js b/src/modules/instance.js index 24c52f9c..155aa2eb 100644 --- a/src/modules/instance.js +++ b/src/modules/instance.js @@ -48,7 +48,11 @@ const defaultState = { // Html stuff instanceSpecificPanelContent: '', - tos: '' + tos: '', + + // Version Information + backendVersion: '', + frontendVersion: '' } const instance = { diff --git a/src/services/version/version.service.js b/src/services/version/version.service.js new file mode 100644 index 00000000..6c5036c1 --- /dev/null +++ b/src/services/version/version.service.js @@ -0,0 +1,10 @@ + +export const parseBackendVersionString = versionString => { + const regex = /(-g)(\w+)$/i + const replacer = '$1$2' + return versionString.replace(regex, replacer) +} + +export const parseFrontendVersionString = versionString => { + return `#${versionString}` +} From 8952761370a9fc08a3f931940050ccbdd8df9767 Mon Sep 17 00:00:00 2001 From: Edijs Date: Sun, 10 Mar 2019 18:06:51 -0700 Subject: [PATCH 2/3] Version links to BE/FE --- src/components/settings/settings.js | 17 +++++++++-------- src/components/settings/settings.vue | 4 ++-- src/services/version/version.service.js | 12 ++++-------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index d208ee5a..3579f6db 100644 --- a/src/components/settings/settings.js +++ b/src/components/settings/settings.js @@ -4,7 +4,10 @@ import { filter, trim } from 'lodash' import TabSwitcher from '../tab_switcher/tab_switcher.js' import StyleSwitcher from '../style_switcher/style_switcher.vue' import InterfaceLanguageSwitcher from '../interface_language_switcher/interface_language_switcher.vue' -import { parseBackendVersionString, parseFrontendVersionString } from '../../services/version/version.service' +import { extractCommit } from '../../services/version/version.service' + +const pleromaFeCommitUrl = 'https://git.pleroma.social/pleroma/pleroma-fe/commit/' +const pleromaBeCommitUrl = 'https://git.pleroma.social/pleroma/pleroma/commit/' const settings = { data () { @@ -101,14 +104,12 @@ const settings = { postFormats () { return this.$store.state.instance.postFormats || [] }, - instanceSpecificPanelPresent () { return this.$store.state.instance.showInstanceSpecificPanel } - }, - methods: { - parseBackendVersion (versionString) { - return parseBackendVersionString(versionString) + instanceSpecificPanelPresent () { return this.$store.state.instance.showInstanceSpecificPanel }, + frontendVersionLink () { + return pleromaFeCommitUrl + this.$store.state.instance.frontendVersion }, - parseFrontendVersion (versionString) { - return parseFrontendVersionString(versionString) + backendVersionLink () { + return pleromaBeCommitUrl + extractCommit(this.$store.state.instance.backendVersion) } }, watch: { diff --git a/src/components/settings/settings.vue b/src/components/settings/settings.vue index 3ca7bdc0..17f1f1a1 100644 --- a/src/components/settings/settings.vue +++ b/src/components/settings/settings.vue @@ -268,7 +268,7 @@

{{$t('settings.version.backend_version')}}

@@ -276,7 +276,7 @@

{{$t('settings.version.frontend_version')}}

diff --git a/src/services/version/version.service.js b/src/services/version/version.service.js index 6c5036c1..a750b0dd 100644 --- a/src/services/version/version.service.js +++ b/src/services/version/version.service.js @@ -1,10 +1,6 @@ -export const parseBackendVersionString = versionString => { - const regex = /(-g)(\w+)$/i - const replacer = '$1$2' - return versionString.replace(regex, replacer) -} - -export const parseFrontendVersionString = versionString => { - return `#${versionString}` +export const extractCommit = versionString => { + const regex = /-g(\w+)$/i + const matches = versionString.match(regex) + return matches ? matches[1] : '' } From 9c60934786f0ca11d64550b1f290e1e8d63d8b9d Mon Sep 17 00:00:00 2001 From: Edijs Date: Sun, 10 Mar 2019 18:13:01 -0700 Subject: [PATCH 3/3] Code refactoring --- src/components/settings/settings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/settings/settings.js b/src/components/settings/settings.js index 3579f6db..b77c5197 100644 --- a/src/components/settings/settings.js +++ b/src/components/settings/settings.js @@ -106,10 +106,10 @@ const settings = { }, instanceSpecificPanelPresent () { return this.$store.state.instance.showInstanceSpecificPanel }, frontendVersionLink () { - return pleromaFeCommitUrl + this.$store.state.instance.frontendVersion + return pleromaFeCommitUrl + this.frontendVersion }, backendVersionLink () { - return pleromaBeCommitUrl + extractCommit(this.$store.state.instance.backendVersion) + return pleromaBeCommitUrl + extractCommit(this.backendVersion) } }, watch: {