File tree 5 files changed +47
-24
lines changed
packages/app-headless-cms/src/admin
config/contentEntries/editor
views/contentEntries/ContentEntry/FullScreenContentEntry 5 files changed +47
-24
lines changed Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
import { Property , useIdGenerator } from "@webiny/react-properties" ;
3
- import { useModel } from "~/admin/hooks " ;
3
+ import { IsApplicableToCurrentModel } from "~/admin/config/IsApplicableToCurrentModel " ;
4
4
5
5
export interface BaseActionConfig < T extends string > {
6
6
name : string ;
@@ -27,28 +27,25 @@ export const BaseAction = ({
27
27
element,
28
28
$type
29
29
} : BaseActionProps ) => {
30
- const { model } = useModel ( ) ;
31
30
const getId = useIdGenerator ( "action" ) ;
32
31
33
- if ( modelIds . length > 0 && ! modelIds . includes ( model . modelId ) ) {
34
- return null ;
35
- }
36
-
37
32
const placeAfter = after !== undefined ? getId ( after ) : undefined ;
38
33
const placeBefore = before !== undefined ? getId ( before ) : undefined ;
39
34
40
35
return (
41
- < Property
42
- id = { getId ( name ) }
43
- name = { "actions" }
44
- remove = { remove }
45
- array = { true }
46
- before = { placeBefore }
47
- after = { placeAfter }
48
- >
49
- < Property id = { getId ( name , "name" ) } name = { "name" } value = { name } />
50
- < Property id = { getId ( name , "element" ) } name = { "element" } value = { element } />
51
- < Property id = { getId ( name , "$type" ) } name = { "$type" } value = { $type } />
52
- </ Property >
36
+ < IsApplicableToCurrentModel modelIds = { modelIds } >
37
+ < Property
38
+ id = { getId ( name ) }
39
+ name = { "actions" }
40
+ remove = { remove }
41
+ array = { true }
42
+ before = { placeBefore }
43
+ after = { placeAfter }
44
+ >
45
+ < Property id = { getId ( name , "name" ) } name = { "name" } value = { name } />
46
+ < Property id = { getId ( name , "element" ) } name = { "element" } value = { element } />
47
+ < Property id = { getId ( name , "$type" ) } name = { "$type" } value = { $type } />
48
+ </ Property >
49
+ </ IsApplicableToCurrentModel >
53
50
) ;
54
51
} ;
Original file line number Diff line number Diff line change @@ -2,15 +2,21 @@ import { useMemo } from "react";
2
2
import { createConfigurableComponent } from "@webiny/react-properties" ;
3
3
import { Actions , ActionsConfig } from "./Actions" ;
4
4
import { FieldElement } from "./FieldElement" ;
5
+ import { Width } from "./Width" ;
5
6
6
7
const base = createConfigurableComponent < ContentEntryEditorConfig > ( "ContentEntryEditorConfig" ) ;
7
8
8
- export const ContentEntryEditorConfig = Object . assign ( base . Config , { Actions, FieldElement } ) ;
9
+ export const ContentEntryEditorConfig = Object . assign ( base . Config , {
10
+ Actions,
11
+ FieldElement,
12
+ Width
13
+ } ) ;
9
14
10
15
export const ContentEntryEditorWithConfig = base . WithConfig ;
11
16
12
17
interface ContentEntryEditorConfig {
13
18
actions : ActionsConfig ;
19
+ width : string ;
14
20
}
15
21
16
22
export function useContentEntryEditorConfig ( ) {
@@ -23,7 +29,8 @@ export function useContentEntryEditorConfig() {
23
29
buttonActions : [ ...( actions . filter ( action => action . $type === "button-action" ) || [ ] ) ] ,
24
30
menuItemActions : [
25
31
...( actions . filter ( action => action . $type === "menu-item-action" ) || [ ] )
26
- ]
32
+ ] ,
33
+ width : config . width || "1020px"
27
34
} ) ,
28
35
[ config ]
29
36
) ;
Original file line number Diff line number Diff line change
1
+ import React from "react" ;
2
+ import { Property } from "@webiny/react-properties" ;
3
+ import { IsApplicableToCurrentModel } from "~/admin/config/IsApplicableToCurrentModel" ;
4
+
5
+ export interface WidthProps {
6
+ value : string ;
7
+ modelIds ?: string [ ] ;
8
+ }
9
+
10
+ export const Width = ( { value, modelIds = [ ] } : WidthProps ) => {
11
+ return (
12
+ < IsApplicableToCurrentModel modelIds = { modelIds } >
13
+ < Property id = { `contentEntryForm:width` } name = { "width" } value = { value } />
14
+ </ IsApplicableToCurrentModel >
15
+ ) ;
16
+ } ;
Original file line number Diff line number Diff line change @@ -106,9 +106,10 @@ export const FullScreenContentEntryContentFormWrapper = styled.div`
106
106
justify-content : center;
107
107
` ;
108
108
109
- export const FullScreenContentEntryContentFormInner = styled . div `
110
- flex-shrink : 1 ;
111
- flex-basis : 1020px ;
109
+ type FullScreenContentEntryContentFormInnerProps = { width : string } ;
110
+
111
+ export const FullScreenContentEntryContentFormInner = styled . div < FullScreenContentEntryContentFormInnerProps > `
112
+ width: ${ props => props . width } ;
112
113
` ;
113
114
114
115
export const FullScreenContentEntryContentFormInnerCss = css `
Original file line number Diff line number Diff line change @@ -16,11 +16,13 @@ import {
16
16
import { FullScreenContentEntryProvider } from "./useFullScreenContentEntry" ;
17
17
import { ContentEntryEditorConfig } from "~/ContentEntryEditorConfig" ;
18
18
import { cmsLegacyEntryEditor } from "~/utils/cmsLegacyEntryEditor" ;
19
+ import { useContentEntryEditorConfig } from "~/admin/config/contentEntries" ;
19
20
20
21
const { ContentEntry } = ContentEntryEditorConfig ;
21
22
22
23
const FullScreenContentEntryDecorator = ContentEntry . createDecorator ( Original => {
23
24
return function ContentEntry ( ) {
25
+ const { width } = useContentEntryEditorConfig ( ) ;
24
26
const { loading } = useContentEntry ( ) ;
25
27
const [ isRevisionListOpen , openRevisionList ] = useState < boolean > ( false ) ;
26
28
@@ -45,7 +47,7 @@ const FullScreenContentEntryDecorator = ContentEntry.createDecorator(Original =>
45
47
{ loading && < CircularProgress style = { { zIndex : 10 } } /> }
46
48
< FullScreenContentEntryContent >
47
49
< FullScreenContentEntryContentFormWrapper >
48
- < FullScreenContentEntryContentFormInner >
50
+ < FullScreenContentEntryContentFormInner width = { width } >
49
51
< Original />
50
52
</ FullScreenContentEntryContentFormInner >
51
53
</ FullScreenContentEntryContentFormWrapper >
You can’t perform that action at this time.
0 commit comments