Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion src/components/DragAndDrop/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const propTypes = {
/** Guard for accepting drops in drop zone. Drag event is passed to this function as first parameter. This prop is necessary to be inlined to satisfy the linter */
shouldAcceptDrop: PropTypes.func,

/** Whether drag & drop should be disabled */
disabled: PropTypes.bool,

/** Rendered child component */
children: PropTypes.node.isRequired,
};
Expand All @@ -33,6 +36,7 @@ const defaultProps = {
}
return false;
},
disabled: false,
};

export default class DragAndDrop extends React.Component {
Expand All @@ -52,6 +56,32 @@ export default class DragAndDrop extends React.Component {
}

componentDidMount() {
if (this.props.disabled) {
return;
}
this.addEventListeners();
}

componentDidUpdate(prevProps) {
const isDisabled = this.props.disabled;
if (isDisabled === prevProps.disabled) {
return;
}
if (isDisabled) {
this.removeEventListeners();
} else {
this.addEventListeners();
}
}

componentWillUnmount() {
if (this.props.disabled) {
return;
}
this.removeEventListeners();
}

addEventListeners() {
this.dropZone = document.getElementById(this.props.dropZoneId);
this.dropZoneRect = this.calculateDropZoneClientReact();
document.addEventListener('dragover', this.dropZoneDragListener);
Expand All @@ -61,7 +91,7 @@ export default class DragAndDrop extends React.Component {
window.addEventListener('resize', this.throttledDragNDropWindowResizeListener);
}

componentWillUnmount() {
removeEventListeners() {
document.removeEventListener('dragover', this.dropZoneDragListener);
document.removeEventListener('dragenter', this.dropZoneDragListener);
document.removeEventListener('dragleave', this.dropZoneDragListener);
Expand Down
12 changes: 8 additions & 4 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,10 @@ class ReportScreen extends React.Component {
placeholder={(
<>
<ReportHeaderSkeletonView animate={animatePlaceholder} />
<ReportActionsSkeletonView animate={animatePlaceholder} containerHeight={this.state.skeletonViewContainerHeight} />
<View style={[styles.flex1, styles.justifyContentEnd, styles.overflowHidden]}>
<ReportActionsSkeletonView animate={animatePlaceholder} containerHeight={this.state.skeletonViewContainerHeight} />
<ReportFooter shouldDisableCompose isOffline={this.props.network.isOffline} />
</View>
</>
)}
>
Expand Down Expand Up @@ -312,9 +315,10 @@ class ReportScreen extends React.Component {
{/* Note: The report should be allowed to mount even if the initial report actions are not loaded. If we prevent rendering the report while they are loading then
we'll unnecessarily unmount the ReportActionsView which will clear the new marker lines initial state. */}
{(!this.isReportReadyForDisplay() || isLoadingInitialReportActions) && (
<ReportActionsSkeletonView
containerHeight={this.state.skeletonViewContainerHeight}
/>
<>
<ReportActionsSkeletonView containerHeight={this.state.skeletonViewContainerHeight} />
<ReportFooter shouldDisableCompose isOffline={this.props.network.isOffline} />
</>
)}
<PortalHost name={CONST.REPORT.DROP_HOST_NAME} />
</View>
Expand Down
20 changes: 12 additions & 8 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ const propTypes = {
isFocused: PropTypes.bool.isRequired,

/** Is the composer full size */
isComposerFullSize: PropTypes.bool.isRequired,
isComposerFullSize: PropTypes.bool,

/** Whether user interactions should be disabled */
disabled: PropTypes.bool,

// The NVP describing a user's block status
blockedFromConcierge: PropTypes.shape({
Expand Down Expand Up @@ -539,7 +542,7 @@ class ReportActionCompose extends React.Component {
{shouldShowReportRecipientLocalTime
&& <ParticipantLocalTime participant={reportRecipient} />}
<View style={[
(!isBlockedFromConcierge && (this.state.isFocused || this.state.isDraggingOver))
(!isBlockedFromConcierge && !this.props.disabled && (this.state.isFocused || this.state.isDraggingOver))
? styles.chatItemComposeBoxFocusedColor
: styles.chatItemComposeBoxColor,
styles.flexRow,
Expand Down Expand Up @@ -573,7 +576,7 @@ class ReportActionCompose extends React.Component {
// Keep focus on the composer when Collapse button is clicked.
onMouseDown={e => e.preventDefault()}
style={styles.composerSizeButton}
disabled={isBlockedFromConcierge}
disabled={isBlockedFromConcierge || this.props.disabled}
>
<Icon src={Expensicons.Collapse} />
</TouchableOpacity>
Expand All @@ -591,7 +594,7 @@ class ReportActionCompose extends React.Component {
// Keep focus on the composer when Expand button is clicked.
onMouseDown={e => e.preventDefault()}
style={styles.composerSizeButton}
disabled={isBlockedFromConcierge}
disabled={isBlockedFromConcierge || this.props.disabled}
>
<Icon src={Expensicons.Expand} />
</TouchableOpacity>
Expand All @@ -608,7 +611,7 @@ class ReportActionCompose extends React.Component {
this.setMenuVisibility(true);
}}
style={styles.chatItemAttachButton}
disabled={isBlockedFromConcierge}
disabled={isBlockedFromConcierge || this.props.disabled}
>
<Icon src={Expensicons.Plus} />
</TouchableOpacity>
Expand Down Expand Up @@ -654,6 +657,7 @@ class ReportActionCompose extends React.Component {

this.setState({isDraggingOver: false});
}}
disabled={this.props.disabled}
>
<Composer
autoFocus={!this.props.modal.isVisible && (this.shouldFocusInputOnScreenFocus || this.isEmptyChat())}
Expand All @@ -671,7 +675,7 @@ class ReportActionCompose extends React.Component {
onPasteFile={displayFileInModal}
shouldClear={this.state.textInputShouldClear}
onClear={() => this.setTextInputShouldClear(false)}
isDisabled={isComposeDisabled || isBlockedFromConcierge}
isDisabled={isComposeDisabled || isBlockedFromConcierge || this.props.disabled}
selection={this.state.selection}
onSelectionChange={this.onSelectionChange}
isFullComposerAvailable={this.state.isFullComposerAvailable}
Expand All @@ -686,7 +690,7 @@ class ReportActionCompose extends React.Component {
</AttachmentModal>
{canUseTouchScreen() && this.props.isMediumScreenWidth ? null : (
<EmojiPickerButton
isDisabled={isBlockedFromConcierge}
isDisabled={isBlockedFromConcierge || this.props.disabled}
onModalHide={() => this.focus(true)}
onEmojiSelected={this.addEmojiToTextBox}
/>
Expand All @@ -702,7 +706,7 @@ class ReportActionCompose extends React.Component {
// Keep focus on the composer when Send message is clicked.
// eslint-disable-next-line react/jsx-props-no-multi-spaces
onMouseDown={e => e.preventDefault()}
disabled={this.state.isCommentEmpty || isBlockedFromConcierge || hasExceededMaxCommentLength}
disabled={this.state.isCommentEmpty || isBlockedFromConcierge || this.props.disabled || hasExceededMaxCommentLength}
hitSlop={{
top: 3, right: 3, bottom: 3, left: 3,
}}
Expand Down
16 changes: 12 additions & 4 deletions src/pages/home/report/ReportFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ import reportPropTypes from '../../reportPropTypes';

const propTypes = {
/** Report object for the current report */
report: reportPropTypes.isRequired,
report: reportPropTypes,

/** Report actions for the current report */
reportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)).isRequired,
reportActions: PropTypes.objectOf(PropTypes.shape(reportActionPropTypes)),

/** Offline status */
isOffline: PropTypes.bool.isRequired,

/** Callback fired when the comment is submitted */
onSubmitComment: PropTypes.func.isRequired,
onSubmitComment: PropTypes.func,

/** Any errors associated with an attempt to create a chat */
// eslint-disable-next-line react/forbid-prop-types
Expand All @@ -42,13 +42,20 @@ const propTypes = {
/** Whether the composer input should be shown */
shouldShowComposeInput: PropTypes.bool,

/** Whether user interactions should be disabled */
shouldDisableCompose: PropTypes.bool,

...windowDimensionsPropTypes,
};

const defaultProps = {
shouldShowComposeInput: true,
report: {reportID: '0'},
reportActions: {},
onSubmitComment: () => {},
errors: {},
pendingAction: null,
shouldShowComposeInput: true,
shouldDisableCompose: false,
};

class ReportFooter extends React.Component {
Expand Down Expand Up @@ -99,6 +106,7 @@ class ReportFooter extends React.Component {
reportActions={this.props.reportActions}
report={this.props.report}
isComposerFullSize={this.props.isComposerFullSize}
disabled={this.props.shouldDisableCompose}
/>
</OfflineWithFeedback>
</SwipeableView>
Expand Down