Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use the external initial state implementation
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst authored and rullzer committed Oct 12, 2019
commit c2e882134526816e224bb408e42f4953f385c917
8 changes: 4 additions & 4 deletions apps/oauth2/js/oauth2.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/oauth2/js/oauth2.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/oauth2/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions apps/settings/js/vue-0.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-0.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/settings/js/vue-4.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-4.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions apps/settings/js/vue-5.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-5.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions apps/settings/js/vue-6.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-6.js.map

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions apps/settings/js/vue-settings-admin-security.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-admin-security.js.map

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions apps/settings/js/vue-settings-apps-users-management.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

96 changes: 48 additions & 48 deletions apps/settings/js/vue-settings-personal-security.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/settings/js/vue-settings-personal-security.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion apps/settings/src/main-admin-security.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { loadState } from '@nextcloud/initial-state'
import Vue from 'vue'

import AdminTwoFactor from './components/AdminTwoFactor.vue'
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions apps/settings/src/main-personal-security.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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')
10 changes: 5 additions & 5 deletions apps/twofactor_backupcodes/js/settings.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/twofactor_backupcodes/js/settings.js.map

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions apps/twofactor_backupcodes/src/settings.js
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
30 changes: 15 additions & 15 deletions apps/workflowengine/js/workflowengine.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/workflowengine/js/workflowengine.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion apps/workflowengine/src/helpers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}

Expand Down
11 changes: 6 additions & 5 deletions apps/workflowengine/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,31 @@ 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}`,
entity,
...event
}
})).flat(),
checks: OCP.InitialState.loadState('workflowengine', 'checks')
checks: loadState('workflowengine', 'checks')
},
mutations: {
addRule(state, rule) {
Expand Down
36 changes: 18 additions & 18 deletions core/js/dist/login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/login.js.map

Large diffs are not rendered by default.

115 changes: 47 additions & 68 deletions core/js/dist/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/main.js.map

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions core/js/dist/maintenance.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/js/dist/maintenance.js.map

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions core/src/OCP/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down
17 changes: 2 additions & 15 deletions core/src/OCP/initialstate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions core/src/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down