@bdlite/domains 1.1.29 → 1.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/system-config/index.js +15 -0
- package/es/team/index.js +115 -0
- package/es/workspace/index.js +97 -0
- package/package.json +1 -1
|
@@ -70,6 +70,21 @@ export function storeSysConfig(systemConfig) {
|
|
|
70
70
|
publish(_systemConfig)
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* @function storePreload
|
|
75
|
+
* @param {?object} config
|
|
76
|
+
*/
|
|
77
|
+
export function storePreload(config) {
|
|
78
|
+
if (!config) return
|
|
79
|
+
const { title, favicon, loginLogo, copyright, eula, appRunning } = config
|
|
80
|
+
Object.assign(_systemConfig, {
|
|
81
|
+
favicon, loginLogo, app: appRunning,
|
|
82
|
+
title: title?.trim(), copyright: copyright?.trim(), useragreement: eula?.trim()
|
|
83
|
+
})
|
|
84
|
+
storage.appendObject(CHANNEL_NAME, _systemConfig)
|
|
85
|
+
publish(_systemConfig)
|
|
86
|
+
}
|
|
87
|
+
|
|
73
88
|
/**
|
|
74
89
|
* @function publishPreload
|
|
75
90
|
* @param {?object} config
|
package/es/team/index.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { isObject } from '@bdlite/strategy'
|
|
2
|
+
import storage from '@bdlite/helpers/es/storage'
|
|
3
|
+
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const DEFAULT_TEAM_STATUS = { hide: true }
|
|
7
|
+
export const DEFALUT_CURRENT_TEAM = { id: null, teamId: null, teamName: '' }
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
const KEY = 'team_data'
|
|
11
|
+
|
|
12
|
+
const { getData: getStateData, subscribe: subscribeState, publish: publishState } = createObservableKit(DEFAULT_TEAM_STATUS)
|
|
13
|
+
|
|
14
|
+
const { getData, subscribe, publish } = createObservableKit({ ...DEFALUT_CURRENT_TEAM })
|
|
15
|
+
const { subscribe: subscribeCache, publish: publishCache } = createObservableKit({ ...DEFALUT_CURRENT_TEAM })
|
|
16
|
+
|
|
17
|
+
let _isCleared = false
|
|
18
|
+
let _currentTeam = getData()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @function subscribeTeam
|
|
24
|
+
* @param {function | object} mountedFunOrConfig callback | { cache = false, ...config }
|
|
25
|
+
* @param {?function} unmountedFun
|
|
26
|
+
* @returns {function} unsubscribe
|
|
27
|
+
*/
|
|
28
|
+
export function subscribeTeam(mountedFunOrConfig, unmountedFun) {
|
|
29
|
+
if (isObject(mountedFunOrConfig)) {
|
|
30
|
+
const { cache = false, ...config } = mountedFunOrConfig
|
|
31
|
+
return cache ? subscribeCache(config, unmountedFun) : subscribe(config, unmountedFun)
|
|
32
|
+
}
|
|
33
|
+
return subscribe(mountedFunOrConfig, unmountedFun)
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @function publishTeam
|
|
39
|
+
* @param {?object} { cache = false, all = false }
|
|
40
|
+
*/
|
|
41
|
+
export function publishTeam({ cache = false, all = false } = {}) {
|
|
42
|
+
const team = getTeam()
|
|
43
|
+
|
|
44
|
+
if (all) {
|
|
45
|
+
publishCache(team)
|
|
46
|
+
publish(team)
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (cache) {
|
|
51
|
+
publishCache(team)
|
|
52
|
+
} else {
|
|
53
|
+
publish(team)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @function subscribeTeamStatus
|
|
59
|
+
* @param {function | object} mountedFunOrConfig
|
|
60
|
+
* @param {?function} unmountedFun
|
|
61
|
+
* @returns {function} unsubscribe
|
|
62
|
+
*/
|
|
63
|
+
export const subscribeTeamStatus = subscribeState
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @function publishTeamStatus
|
|
67
|
+
* @param {?object} nextState
|
|
68
|
+
*/
|
|
69
|
+
export function publishTeamStatus(nextState = {}) {
|
|
70
|
+
publishState({ ...getStateData(), ...nextState })
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @function showTeamSelector
|
|
75
|
+
* @param {?boolean} show
|
|
76
|
+
*/
|
|
77
|
+
export function showTeamSelector(show = true) {
|
|
78
|
+
publishTeamStatus({ hide: !show })
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
export function storeTeam(teamId = '', teamName = '', leaderName = '') {
|
|
84
|
+
const name = `${teamName}`
|
|
85
|
+
Object.assign(_currentTeam, { id: teamId, teamId, leaderName }, name ? { teamName: name } : {})
|
|
86
|
+
storage.appendObject(KEY, _currentTeam)
|
|
87
|
+
_isCleared = false
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function clearTeam({ stayStored = false } = {}) {
|
|
91
|
+
_currentTeam = { ...DEFALUT_CURRENT_TEAM }
|
|
92
|
+
_isCleared = true
|
|
93
|
+
|
|
94
|
+
if (!stayStored) {
|
|
95
|
+
storage.remove(KEY)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function getTeam() {
|
|
100
|
+
if (_currentTeam.teamId === null && !_isCleared) {
|
|
101
|
+
Object.assign(_currentTeam, storage.getObject(KEY))
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const { teamId, teamName = '', ...rest } = _currentTeam
|
|
105
|
+
|
|
106
|
+
if(teamId == 'null'){
|
|
107
|
+
return { teamId: '', teamName, ...rest }
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return { teamId, teamName, ...rest }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function getTeamId() {
|
|
114
|
+
return getTeam().teamId
|
|
115
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { isObject } from '@bdlite/strategy'
|
|
2
|
+
import storage from '@bdlite/helpers/es/storage'
|
|
3
|
+
import { createObservableKit } from '@bdlite/observable/es/create-observable-kit'
|
|
4
|
+
|
|
5
|
+
export const DEFALUT_CURRENT_PROJECT = { id: null, projectId: null, key: '', projectName: '' }
|
|
6
|
+
|
|
7
|
+
const KEY = 'project_data'
|
|
8
|
+
|
|
9
|
+
const { subscribe: cacheSubscribe, publish: cachePublish } = createObservableKit({ ...DEFALUT_CURRENT_PROJECT })
|
|
10
|
+
const { getData: getProjectData, subscribe, publish: projectPublish } = createObservableKit({ ...DEFALUT_CURRENT_PROJECT })
|
|
11
|
+
|
|
12
|
+
let _isCleared = false
|
|
13
|
+
let _currentProject = getProjectData()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @function subscribeProject
|
|
18
|
+
* @param {function | object} mountedFunOrConfig callback | { cache = false, ...config }
|
|
19
|
+
* @param {?function} unmountedFun
|
|
20
|
+
* @returns {function} unsubscribe
|
|
21
|
+
*/
|
|
22
|
+
export function subscribeProject(mountedFunOrConfig, unmountedFun) {
|
|
23
|
+
if (isObject(mountedFunOrConfig)) {
|
|
24
|
+
const { cache = false, ...config } = mountedFunOrConfig
|
|
25
|
+
return cache ? cacheSubscribe(config, unmountedFun) : subscribe(config, unmountedFun)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return subscribe(mountedFunOrConfig, unmountedFun)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @function publishProject
|
|
33
|
+
* @param {?object} { cache = false, all = false }
|
|
34
|
+
*/
|
|
35
|
+
export function publishProject({ cache = false, all = false } = {}) {
|
|
36
|
+
const project = getProject()
|
|
37
|
+
|
|
38
|
+
if (all) {
|
|
39
|
+
cachePublish(project)
|
|
40
|
+
projectPublish(project)
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (cache) {
|
|
45
|
+
cachePublish(project)
|
|
46
|
+
} else {
|
|
47
|
+
projectPublish(project)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
function isValidId(id) {
|
|
54
|
+
return id !== '' && id !== 'null'
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 项目/应用/工作空间
|
|
58
|
+
export function storeProject(projectId = '', rest) {
|
|
59
|
+
if (isObject(rest)) {
|
|
60
|
+
const { teamId, projectName, orgName = '', name = '', ..._rest } = rest
|
|
61
|
+
Object.assign(_currentProject, {
|
|
62
|
+
id: projectId,
|
|
63
|
+
projectId,
|
|
64
|
+
teamId, name, orgName,
|
|
65
|
+
projectName: projectName || name || orgName,
|
|
66
|
+
..._rest
|
|
67
|
+
})
|
|
68
|
+
} else {
|
|
69
|
+
Object.assign(_currentProject, { id: projectId, projectId })
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
storage.appendObject(KEY, _currentProject)
|
|
73
|
+
_isCleared = false
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function getProject() {
|
|
77
|
+
if (_currentProject.projectId !== null || _isCleared) return { ..._currentProject }
|
|
78
|
+
|
|
79
|
+
const { projectId = '', rest } = storage.getObject(KEY)
|
|
80
|
+
Object.assign(_currentProject, { ...rest })
|
|
81
|
+
isValidId(projectId) && Object.assign(_currentProject, { projectId })
|
|
82
|
+
return { ..._currentProject }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function getProjectId() {
|
|
86
|
+
return getProject().projectId;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
export function clearProjectData({ stayStored = false } = {}) {
|
|
91
|
+
_isCleared = true
|
|
92
|
+
_currentProject = { ...DEFALUT_CURRENT_PROJECT }
|
|
93
|
+
|
|
94
|
+
if (!stayStored) {
|
|
95
|
+
storage.remove(KEY)
|
|
96
|
+
}
|
|
97
|
+
}
|