Skip to content

Commit c49ca26

Browse files
added onlyView option to media-manager single file
1 parent 7394e4f commit c49ca26

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

fixture/adminizerConfig.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,9 @@ const models: AdminpanelConfig["models"] = {
424424
options: {
425425
id: 'default',
426426
group: 'single-file',
427-
accept: ['application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document']
428-
}
427+
accept: ['application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
428+
onlyView: true
429+
},
429430
}
430431
},
431432
add: true,

src/assets/js/components/media-manager/media-manager.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ interface Props {
4646
group: string
4747
accept: string[]
4848
initTab?: string
49+
onlyView?: boolean
4950
}
5051
type: string
5152
onChange?: (media: Media[]) => void
@@ -227,7 +228,9 @@ const MediaManager = ({layout, config, type, onChange, value}: Props) => {
227228
items.length > 0 ? (
228229
<div className="flex flex-col gap-2">
229230
<div className="flex gap-2">
230-
<Button variant="destructive" onClick={(e) => {
231+
<Button variant="destructive"
232+
disabled={config.onlyView ?? false}
233+
onClick={(e) => {
231234
e.stopPropagation()
232235
e.preventDefault()
233236
setItems(prev => {

src/interfaces/adminpanelConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ export interface MediaManagerOptionsField {
450450
accept: string [],
451451
initTab?: 'tile-image' | 'table-video' | 'table-text' | 'table-application' | 'table-all' | 'tile-all'
452452
config?: Record<string, any>
453+
onlyView?: boolean
453454
}
454455

455456
interface RangeType {

0 commit comments

Comments
 (0)