Skip to content

Commit

Permalink
Disable Copy Link button while upload is in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
etoledom committed Nov 16, 2020
1 parent 53a2065 commit e777c4b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/block-library/src/file/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,19 @@ export class FileEdit extends Component {
);
}

getInspectorControls( { showDownloadButton, textLinkTarget } ) {
getInspectorControls(
{ showDownloadButton, textLinkTarget },
isUploadInProgress,
isUploadFailed
) {
const actionButtonStyle = this.props.getStylesFromColorScheme(
styles.actionButton,
styles.actionButtonDark
);

const isCopyUrlDisabled = isUploadFailed || isUploadInProgress;
const shouldStyleCopyUrlButton =
! isCopyUrlDisabled && ! this.state.isUrlCopied;
return (
<InspectorControls>
<PanelBody title={ __( 'File block settings' ) } />
Expand All @@ -197,13 +204,14 @@ export class FileEdit extends Component {
onChange={ this.onChangeDownloadButtonVisibility }
/>
<BottomSheet.Cell
disabled={ isCopyUrlDisabled }
label={
this.state.isUrlCopied
? __( 'Copied!' )
: __( 'Copy file URL' )
}
labelStyle={
this.state.isUrlCopied || actionButtonStyle
shouldStyleCopyUrlButton && actionButtonStyle
}
onPress={ this.onCopyURL }
/>
Expand Down Expand Up @@ -278,7 +286,11 @@ export class FileEdit extends Component {
{ isUploadInProgress ||
this.getToolbarEditButton( openMediaOptions ) }
{ getMediaOptions() }
{ this.getInspectorControls( attributes ) }
{ this.getInspectorControls(
attributes,
isUploadInProgress,
isUploadFailed
) }
<RichText
__unstableMobileNoFocusOnMount
onChange={ this.onChangeFileName }
Expand Down

0 comments on commit e777c4b

Please sign in to comment.