Skip to content

Commit

Permalink
Enhancement: Toggle add file button on single file field (#7315)
Browse files Browse the repository at this point in the history
  • Loading branch information
sc0ttkclark authored Aug 27, 2024
2 parents b4f492c + 35e9f52 commit 9171ecb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
9 changes: 6 additions & 3 deletions ui/js/dfv/src/fields/marionette-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ class MarionetteAdapter extends React.Component {
}

render() {
const { className } = this.props;

const { className, fieldConfig } = this.props;
const allowSingleFile = Number( fieldConfig?.file_limit ) === 1;
// Add an extra class so we're able to hide the `Add file` button,
// when an image or video is already being added into the field.
const wrapperClasses = `pods-marionette-adapter-wrapper ${ allowSingleFile ? 'pods-marionette-adapter-wrapper-single-file' : '' }`;
return (
<div className="pods-marionette-adapter-wrapper">
<div className={ wrapperClasses }>
<div
className={ className }
ref={ ( element ) => this.element = element }
Expand Down
Loading

0 comments on commit 9171ecb

Please sign in to comment.