@@ -4,7 +4,7 @@ import isEqual from "lodash/isEqual";
4
4
import uniqueId from "lodash/uniqueId" ;
5
5
import { useCallback , useEffect , useRef } from "react" ;
6
6
7
- import { Box , Button , CommandBar , CommandItemProps } from "@axelor/ui" ;
7
+ import { Box , Button , CommandBar } from "@axelor/ui" ;
8
8
9
9
import { dialogs } from "@/components/dialogs" ;
10
10
import { openTab_internal as openTab } from "@/hooks/use-tabs" ;
@@ -30,6 +30,7 @@ export type EditorOptions = {
30
30
view ?: FormView ;
31
31
viewName ?: string ;
32
32
context ?: DataContext ;
33
+ canAttach ?: boolean ;
33
34
canSave ?: boolean ;
34
35
params ?: ActionView [ "params" ] ;
35
36
header ?: PopupProps [ "header" ] ;
@@ -101,6 +102,7 @@ export function useEditor() {
101
102
context,
102
103
readonly,
103
104
maximize,
105
+ canAttach = true ,
104
106
canSave = true ,
105
107
params,
106
108
header,
@@ -141,6 +143,7 @@ export function useEditor() {
141
143
footer : ( { close } ) => (
142
144
< Footer
143
145
footer = { footer }
146
+ canAttach = { canAttach && ( record ?. id ?? 0 ) > 0 }
144
147
hasOk = { canSave }
145
148
params = { tabParams }
146
149
onClose = { close }
@@ -154,13 +157,15 @@ export function useEditor() {
154
157
}
155
158
156
159
function Footer ( {
160
+ canAttach = true ,
157
161
hasOk = true ,
158
162
footer : FooterComp ,
159
163
params,
160
164
onClose,
161
165
onSave,
162
166
onSelect,
163
167
} : {
168
+ canAttach ?: boolean ;
164
169
hasOk ?: boolean ;
165
170
footer ?: EditorOptions [ "footer" ] ;
166
171
onClose : ( result : boolean ) => void ;
@@ -251,11 +256,11 @@ function Footer({
251
256
252
257
const { attachmentItem } = handler ;
253
258
254
- const commandItems = [ attachmentItem ] . filter ( Boolean ) as CommandItemProps [ ] ;
255
-
256
259
return (
257
260
< >
258
- { commandItems && < CommandBar items = { commandItems } iconOnly /> }
261
+ { canAttach && attachmentItem && (
262
+ < CommandBar items = { [ attachmentItem ] } iconOnly />
263
+ ) }
259
264
< Box d = "flex" flex = { 1 } justifyContent = "flex-end" g = { 2 } >
260
265
{ FooterComp && < FooterComp close = { onClose } /> }
261
266
< Box d = "flex" g = { 2 } >
0 commit comments