@@ -12,7 +12,7 @@ export const DialogPreview = ({ docAndNode }: PreviewProps) => {
12
12
const text = docAndNode . doc . getText ( )
13
13
const dialog = safeJsonParse ( text ) ?? { }
14
14
const type = dialog . type ?. replace ( / ^ m i n e c r a f t : / , '' )
15
- const footerHeight = type === 'multi_action_input_form' ? 5 : 33
15
+ const footerHeight = ( type === 'dialog_list' || type == 'multi_action' || type == 'server_links' ) && dialog . exit_action == undefined ? 5 : 33
16
16
17
17
useEffect ( ( ) => {
18
18
function resizeHandler ( ) {
@@ -30,9 +30,10 @@ export const DialogPreview = ({ docAndNode }: PreviewProps) => {
30
30
< img src = "/images/dialog/background.webp" alt = "" draggable = { false } />
31
31
< div style = { 'top: 0; left: 0; width: 100%; height: 100%;' } >
32
32
< DialogTitle title = { dialog . title } />
33
- < div style = { `display: flex; flex-direction: column; gap: ${ px ( 10 ) } ; align-items: center; padding-right: ${ px ( 10 ) } /* MC-297972 */; overflow-y: auto; height: calc(100% - ${ px ( 33 + footerHeight ) } )` } >
33
+ < div style = { `display: flex; flex-direction: column; gap: ${ px ( 10 ) } ; align-items: center; overflow-y: auto; height: calc(100% - ${ px ( 33 + footerHeight ) } )` } >
34
34
< DialogBody body = { dialog . body } />
35
- < DialogContent dialog = { dialog } />
35
+ < DialogInputs inputs = { dialog . inputs } />
36
+ < DialogActions dialog = { dialog } />
36
37
</ div >
37
38
< div style = { `bottom: 0; left: 0; width: 100%; height: ${ px ( footerHeight ) } ; display: flex; justify-content: center; align-items: center;` } >
38
39
< DialogFooter dialog = { dialog } />
@@ -43,7 +44,6 @@ export const DialogPreview = ({ docAndNode }: PreviewProps) => {
43
44
}
44
45
45
46
function DialogTitle ( { title } : { title : any } ) {
46
- // TODO: add warning button tooltip
47
47
return < div style = { `height: ${ px ( 33 ) } ; display: flex; gap: ${ px ( 10 ) } ; justify-content: center; align-items: center` } >
48
48
< TextComponent component = { title } />
49
49
< WithTooltip tooltip = "This is a custom screen. Click here to learn more." >
@@ -85,7 +85,13 @@ function DialogBody({ body }: { body: any }) {
85
85
</ >
86
86
}
87
87
88
- function DialogContent ( { dialog } : { dialog : any } ) {
88
+ function DialogInputs ( { inputs } : { inputs : any [ ] | undefined } ) {
89
+ return < >
90
+ { inputs ?. map ( ( i : any ) => < InputControl input = { i } /> ) }
91
+ </ >
92
+ }
93
+
94
+ function DialogActions ( { dialog } : { dialog : any } ) {
89
95
const type = dialog . type ?. replace ( / ^ m i n e c r a f t : / , '' )
90
96
91
97
if ( type === 'dialog_list' ) {
@@ -116,17 +122,6 @@ function DialogContent({ dialog }: { dialog: any }) {
116
122
</ ColumnsGrid >
117
123
}
118
124
119
- if ( type === 'multi_action_input_form' ) {
120
- return < >
121
- { dialog . inputs ?. map ( ( i : any ) => < InputControl input = { i } /> ) }
122
- < ColumnsGrid columns = { dialog . columns ?? 2 } >
123
- { dialog . actions ?. map ( ( a : any ) =>
124
- < Button label = { a . label } width = { a . width ?? 150 } tooltip = { a . tooltip } />
125
- ) ?? [ ] }
126
- </ ColumnsGrid >
127
- </ >
128
- }
129
-
130
125
if ( type === 'server_links' ) {
131
126
const links = [ 'Server link 1' , 'Server link 2' , 'Server link 3' ]
132
127
return < ColumnsGrid columns = { dialog . columns ?? 2 } >
@@ -136,12 +131,6 @@ function DialogContent({ dialog }: { dialog: any }) {
136
131
</ ColumnsGrid >
137
132
}
138
133
139
- if ( type === 'simple_input_form' ) {
140
- return < >
141
- { dialog . inputs ?. map ( ( i : any ) => < InputControl input = { i } /> ) }
142
- </ >
143
- }
144
-
145
134
return < > </ >
146
135
}
147
136
@@ -155,12 +144,8 @@ function DialogFooter({ dialog }: { dialog: any }) {
155
144
</ div >
156
145
}
157
146
158
- if ( type === 'dialog_list' ) {
159
- return < Button label = { { translate : dialog . on_cancel ? 'gui.cancel' : 'gui.back' } } width = { 200 } />
160
- }
161
-
162
- if ( type === 'multi_action' ) {
163
- return < Button label = { { translate : dialog . on_cancel ? 'gui.cancel' : 'gui.back' } } width = { 200 } />
147
+ if ( ( type === 'dialog_list' || type == 'multi_action' || type == 'server_links' ) && dialog . exit_action ) {
148
+ return < Button label = { dialog . exit_action . label } width = { 200 } />
164
149
}
165
150
166
151
if ( type === 'notice' ) {
@@ -169,16 +154,6 @@ function DialogFooter({ dialog }: { dialog: any }) {
169
154
</ div >
170
155
}
171
156
172
- if ( type === 'server_links' ) {
173
- return < Button label = { { translate : dialog . on_cancel ? 'gui.cancel' : 'gui.back' } } width = { 200 } />
174
- }
175
-
176
- if ( type === 'simple_input_form' ) {
177
- return < div style = { `display: flex; gap: ${ px ( 8 ) } ; justify-content: center;` } >
178
- < Button label = { dialog . action ?. label } width = { dialog . action ?. width ?? 150 } tooltip = { dialog . action ?. tooltip } />
179
- </ div >
180
- }
181
-
182
157
return < > </ >
183
158
}
184
159
0 commit comments