|
@@ -5,7 +5,7 @@ import appFactory from '../appFactory.js'
|
5
|
5
|
|
6
|
6
|
export class OpenContentApp extends React.Component {
|
7
|
7
|
openContentApp = () => {
|
8
|
|
- const { idWorkspace, appOpened, user, workspaceContent, contentType, renderApp, match } = this.props
|
|
8
|
+ const { idWorkspace, appOpenedType, user, workspaceContent, contentType, renderApp, match } = this.props
|
9
|
9
|
|
10
|
10
|
if (isNaN(idWorkspace)) return
|
11
|
11
|
|
|
@@ -20,18 +20,21 @@ export class OpenContentApp extends React.Component {
|
20
|
20
|
|
21
|
21
|
console.log('contentToOpen', contentToOpen)
|
22
|
22
|
|
23
|
|
- if (!appOpened) {
|
|
23
|
+ if (appOpenedType === contentToOpen.type) { // app already open
|
|
24
|
+ GLOBAL_dispatchEvent({
|
|
25
|
+ type: `${contentToOpen.type}_reloadContent`, // handled by html-documents:src/container/HtmlDocument.jsx
|
|
26
|
+ data: contentToOpen
|
|
27
|
+ })
|
|
28
|
+ } else { // open another app
|
|
29
|
+ // if another app is already visible, hide it
|
|
30
|
+ if (appOpenedType !== false) GLOBAL_dispatchEvent(`${appOpenedType}_hideApp`)
|
|
31
|
+ // open app
|
24
|
32
|
renderApp(
|
25
|
33
|
contentType.find(ct => ct.slug === contentToOpen.type),
|
26
|
34
|
user,
|
27
|
35
|
contentToOpen
|
28
|
36
|
)
|
29
|
|
- this.props.updateAppOpened(true)
|
30
|
|
- } else {
|
31
|
|
- GLOBAL_dispatchEvent({
|
32
|
|
- type: 'html-documents_reloadContent', // handled by html-documents:src/container/HtmlDocument.jsx
|
33
|
|
- data: contentToOpen
|
34
|
|
- })
|
|
37
|
+ this.props.updateAppOpenedType(contentToOpen.type)
|
35
|
38
|
}
|
36
|
39
|
}
|
37
|
40
|
}
|