2020-05-09 20:46:06 -07:00
|
|
|
import Modal from 'src/components/modal/modal.vue'
|
2020-05-26 13:58:55 -07:00
|
|
|
import PanelLoading from 'src/components/panel_loading/panel_loading.vue'
|
|
|
|
import AsyncComponentError from 'src/components/async_component_error/async_component_error.vue'
|
2020-05-25 06:11:05 -07:00
|
|
|
import getResettableAsyncComponent from 'src/services/resettable_async_component.js'
|
2021-03-08 09:53:30 -08:00
|
|
|
import Popover from '../popover/popover.vue'
|
|
|
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
|
|
|
import { cloneDeep } from 'lodash'
|
|
|
|
import {
|
|
|
|
newImporter,
|
|
|
|
newExporter
|
|
|
|
} from 'src/services/export_import/export_import.js'
|
|
|
|
import {
|
|
|
|
faTimes,
|
|
|
|
faFileUpload,
|
|
|
|
faFileDownload,
|
|
|
|
faChevronDown
|
|
|
|
} from '@fortawesome/free-solid-svg-icons'
|
|
|
|
import {
|
|
|
|
faWindowMinimize
|
|
|
|
} from '@fortawesome/free-regular-svg-icons'
|
|
|
|
|
|
|
|
library.add(
|
|
|
|
faTimes,
|
|
|
|
faWindowMinimize,
|
|
|
|
faFileUpload,
|
|
|
|
faFileDownload,
|
|
|
|
faChevronDown
|
|
|
|
)
|
2020-05-03 07:36:12 -07:00
|
|
|
|
|
|
|
const SettingsModal = {
|
2021-03-08 09:53:30 -08:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
dataImporter: newImporter({
|
|
|
|
validator: this.importValidator,
|
|
|
|
onImport: this.onImport,
|
|
|
|
onImportFailure: this.onImportFailure
|
|
|
|
}),
|
|
|
|
dataThemeExporter: newExporter({
|
|
|
|
filename: 'pleromafe_settings.full',
|
|
|
|
getExportedObject: () => this.generateExport(true)
|
|
|
|
}),
|
|
|
|
dataExporter: newExporter({
|
|
|
|
filename: 'pleromafe_settings',
|
|
|
|
getExportedObject: () => this.generateExport()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
2020-05-03 07:36:12 -07:00
|
|
|
components: {
|
|
|
|
Modal,
|
2021-03-08 09:53:30 -08:00
|
|
|
Popover,
|
2020-05-25 06:11:05 -07:00
|
|
|
SettingsModalContent: getResettableAsyncComponent(
|
|
|
|
() => import('./settings_modal_content.vue'),
|
|
|
|
{
|
2020-05-26 13:58:55 -07:00
|
|
|
loading: PanelLoading,
|
|
|
|
error: AsyncComponentError,
|
2020-05-25 06:32:32 -07:00
|
|
|
delay: 0
|
2020-05-25 06:11:05 -07:00
|
|
|
}
|
|
|
|
)
|
2020-05-03 07:36:12 -07:00
|
|
|
},
|
2020-05-26 13:58:55 -07:00
|
|
|
methods: {
|
|
|
|
closeModal () {
|
|
|
|
this.$store.dispatch('closeSettingsModal')
|
|
|
|
},
|
|
|
|
peekModal () {
|
|
|
|
this.$store.dispatch('togglePeekSettingsModal')
|
2021-03-08 09:53:30 -08:00
|
|
|
},
|
|
|
|
importValidator (data) {
|
|
|
|
return data._pleroma_settings_version[0] === 1
|
|
|
|
},
|
|
|
|
onImportFailure () {
|
|
|
|
this.$store.dispatch('pushGlobalNotice', { messageKey: 'settings.invalid_settings_imported', level: 'error' })
|
|
|
|
},
|
|
|
|
onImport (data) {
|
|
|
|
this.$store.dispatch('loadSettings', data)
|
|
|
|
},
|
|
|
|
restore () {
|
|
|
|
console.log(this.dataImporter)
|
|
|
|
this.dataImporter.importData()
|
|
|
|
},
|
|
|
|
backup () {
|
|
|
|
this.dataExporter.exportData()
|
|
|
|
},
|
|
|
|
backupWithTheme () {
|
|
|
|
this.dataThemeExporter.exportData()
|
|
|
|
},
|
|
|
|
generateExport (theme = false) {
|
|
|
|
const { config } = this.$store.state
|
|
|
|
let sample = config
|
|
|
|
if (!theme) {
|
|
|
|
const ignoreList = new Set([
|
|
|
|
'customTheme',
|
|
|
|
'customThemeSource',
|
|
|
|
'colors'
|
|
|
|
])
|
|
|
|
sample = Object.fromEntries(
|
|
|
|
Object
|
|
|
|
.entries(sample)
|
|
|
|
.filter(([key]) => !ignoreList.has(key))
|
|
|
|
)
|
|
|
|
}
|
|
|
|
const clone = cloneDeep(sample)
|
|
|
|
clone._pleroma_settings_version = [1, 0]
|
|
|
|
return clone
|
2020-05-26 13:58:55 -07:00
|
|
|
}
|
|
|
|
},
|
2020-05-03 07:36:12 -07:00
|
|
|
computed: {
|
2020-05-26 17:32:57 -07:00
|
|
|
currentSaveStateNotice () {
|
|
|
|
return this.$store.state.interface.settings.currentSaveStateNotice
|
|
|
|
},
|
2020-05-03 07:36:12 -07:00
|
|
|
modalActivated () {
|
|
|
|
return this.$store.state.interface.settingsModalState !== 'hidden'
|
2020-05-09 20:46:06 -07:00
|
|
|
},
|
2020-06-01 15:10:52 -07:00
|
|
|
modalOpenedOnce () {
|
|
|
|
return this.$store.state.interface.settingsModalLoaded
|
|
|
|
},
|
2020-05-09 20:46:06 -07:00
|
|
|
modalPeeked () {
|
|
|
|
return this.$store.state.interface.settingsModalState === 'minimized'
|
2020-05-03 07:36:12 -07:00
|
|
|
}
|
2020-05-24 17:43:55 -07:00
|
|
|
}
|
2020-05-03 07:36:12 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
export default SettingsModal
|