Use the external initial state implementation

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2019-10-03 17:08:39 +02:00 committed by Roeland Jago Douma
parent 7f8ff16c76
commit c2e8821345
No known key found for this signature in database
GPG key ID: F941078878347C0C
37 changed files with 47 additions and 49 deletions

Binary file not shown.

Binary file not shown.

View file

@ -22,7 +22,7 @@
import Vue from 'vue'
import App from './App.vue'
import { loadState } from 'nextcloud-initial-state'
import { loadState } from '@nextcloud/initial-state'
Vue.prototype.t = t
Vue.prototype.OC = OC

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,3 +1,4 @@
import { loadState } from '@nextcloud/initial-state'
import Vue from 'vue'
import AdminTwoFactor from './components/AdminTwoFactor.vue'
@ -13,7 +14,7 @@ window.OC = window.OC || {}
window.OC.Settings = window.OC.Settings || {}
store.replaceState(
OCP.InitialState.loadState('settings', 'mandatory2FAState')
loadState('settings', 'mandatory2FAState')
)
const View = Vue.extend(AdminTwoFactor)

View file

@ -19,6 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { loadState } from '@nextcloud/initial-state'
import Vue from 'vue'
import VueClipboard from 'vue-clipboard2'
import VTooltip from 'v-tooltip'
@ -35,7 +36,7 @@ Vue.prototype.t = t
const View = Vue.extend(AuthTokenSection)
new View({
propsData: {
tokens: OCP.InitialState.loadState('settings', 'app_tokens'),
canCreateToken: OCP.InitialState.loadState('settings', 'can_create_app_token')
tokens: loadState('settings', 'app_tokens'),
canCreateToken: loadState('settings', 'can_create_app_token')
}
}).$mount('#security-authtokens')

View file

@ -1,13 +1,13 @@
import { loadState } from '@nextcloud/initial-state'
import Vue from 'vue'
import PersonalSettings from './views/PersonalSettings'
import store from './store'
Vue.prototype.t = t
const initialState = OCP.InitialState.loadState('twofactor_backupcodes', 'state')
store.replaceState(
initialState
)
const initialState = loadState('twofactor_backupcodes', 'state')
store.replaceState(initialState)
const View = Vue.extend(PersonalSettings)
new View({

View file

@ -20,8 +20,10 @@
*
*/
import { loadState } from '@nextcloud/initial-state'
const getApiUrl = (url) => {
const scopeValue = OCP.InitialState.loadState('workflowengine', 'scope') === 0 ? 'global' : 'user'
const scopeValue = loadState('workflowengine', 'scope') === 0 ? 'global' : 'user'
return OC.linkToOCS('apps/workflowengine/api/v1/workflows', 2) + scopeValue + url + '?format=json'
}

View file

@ -25,22 +25,23 @@ import Vuex from 'vuex'
import axios from '@nextcloud/axios'
import { getApiUrl } from './helpers/api'
import confirmPassword from 'nextcloud-password-confirmation'
import { loadState } from '@nextcloud/initial-state'
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
rules: [],
scope: OCP.InitialState.loadState('workflowengine', 'scope'),
operations: OCP.InitialState.loadState('workflowengine', 'operators'),
scope: loadState('workflowengine', 'scope'),
operations: loadState('workflowengine', 'operators'),
plugins: Vue.observable({
checks: {},
operators: {}
}),
entities: OCP.InitialState.loadState('workflowengine', 'entities'),
events: OCP.InitialState.loadState('workflowengine', 'entities')
entities: loadState('workflowengine', 'entities'),
events: loadState('workflowengine', 'entities')
.map((entity) => entity.events.map(event => {
return {
id: `${entity.id}::${event.eventName}`,
@ -48,7 +49,7 @@ const store = new Vuex.Store({
...event
}
})).flat(),
checks: OCP.InitialState.loadState('workflowengine', 'checks')
checks: loadState('workflowengine', 'checks')
},
mutations: {
addRule(state, rule) {

BIN
core/js/dist/login.js vendored

Binary file not shown.

Binary file not shown.

BIN
core/js/dist/main.js vendored

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -3,8 +3,8 @@
*/
import * as AppConfig from './appconfig'
import * as Comments from './comments'
import * as InitialState from './initialstate'
import Loader from './loader'
import { loadState } from '@nextcloud/initial-state'
import Collaboration from './collaboration'
import Toast from './toast'
import * as WhatsNew from './whatsnew'
@ -14,7 +14,12 @@ export default {
AppConfig,
Collaboration,
Comments,
InitialState,
InitialState: {
/**
* @deprecated 18.0.0 add https://www.npmjs.com/package/@nextcloud/initial-state to your app
*/
loadState
},
Loader,
Toast,
WhatsNew

View file

@ -24,19 +24,6 @@
* @namespace OCP.InitialState
*/
export function loadState(app, key) {
const elem = document.querySelector(`#initial-state-${app}-${key}`)
if (elem === null) {
const msg = `Could not find initial state ${key} of ${app}`
console.debug(msg)
throw new Error(msg)
}
import { loadState as load } from '@nextcloud/initial-state'
try {
return JSON.parse(atob(elem.value))
} catch (e) {
const msg = `Could not parse initial state ${key} of ${app}`
console.debug(msg)
throw new Error(msg)
}
}
export const loadState = load

View file

@ -19,8 +19,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import Vue from 'vue'
import { loadState } from '@nextcloud/initial-state'
import queryString from 'query-string'
import Vue from 'vue'
// eslint-disable-next-line no-unused-vars
import OC from './OC/index' // TODO: Not needed but L10n breaks if removed
@ -42,7 +43,7 @@ Vue.mixin(Nextcloud)
const fromStateOr = (key, orValue) => {
try {
return OCP.InitialState.loadState('core', key)
return loadState('core', key)
} catch (e) {
return orValue
}

30
package-lock.json generated
View file

@ -866,6 +866,21 @@
}
}
},
"@nextcloud/initial-state": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@nextcloud/initial-state/-/initial-state-0.2.0.tgz",
"integrity": "sha512-aFkEXxEchawyn1HWn/nStX25324/4+RcOHiHJ1gW/vVH6bPRW8suj9V1Rsi380mMRM7sjkICyeNPxOZ8f+WZrA==",
"requires": {
"core-js": "3.1.4"
},
"dependencies": {
"core-js": {
"version": "3.1.4",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.1.4.tgz",
"integrity": "sha512-YNZN8lt82XIMLnLirj9MhKDFZHalwzzrL9YLt6eb0T5D0EDl4IQ90IGkua8mHbnxNrkj1d8hbdizMc0Qmg1WnQ=="
}
}
},
"@nextcloud/paths": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/@nextcloud/paths/-/paths-0.2.0.tgz",
@ -6200,21 +6215,6 @@
"axios": "^0.19.0"
}
},
"nextcloud-initial-state": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/nextcloud-initial-state/-/nextcloud-initial-state-0.0.3.tgz",
"integrity": "sha512-sL0dKbOb63QwvkAfQdDC5AldshVwaY8B8tKpAci7UMmJV3M1KLxTBzQoY+CVy03/uqTvvFt3Brz/Bd2UNp3zsQ==",
"requires": {
"core-js": "^3.1.4"
},
"dependencies": {
"core-js": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.2.1.tgz",
"integrity": "sha512-Qa5XSVefSVPRxy2XfUC13WbvqkxhkwB3ve+pgCQveNgYzbM/UxZeu1dcOX/xr4UmfUd+muuvsaxilQzCyUurMw=="
}
}
},
"nextcloud-password-confirmation": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/nextcloud-password-confirmation/-/nextcloud-password-confirmation-0.4.2.tgz",

View file

@ -27,6 +27,7 @@
"@chenfengyuan/vue-qrcode": "^1.0.1",
"@nextcloud/axios": "^0.4.1",
"@nextcloud/event-bus": "^0.2.1",
"@nextcloud/initial-state": "^0.2.0",
"@nextcloud/paths": "^0.2.0",
"@nextcloud/router": "^0.1.0",
"autosize": "^4.0.2",
@ -48,7 +49,6 @@
"marked": "^0.7.0",
"moment": "^2.24.0",
"moment-timezone": "^0.5.26",
"nextcloud-initial-state": "0.0.3",
"nextcloud-password-confirmation": "^0.4.2",
"nextcloud-router": "0.0.9",
"nextcloud-vue": "^0.12.3",