Skip to content

Commit

Permalink
Show loading state on Dialog accept button and avoid close it on saving
Browse files Browse the repository at this point in the history
  • Loading branch information
RodriSanchez1 committed Jul 25, 2024
1 parent b36d319 commit 084181a
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import TextField from '@material-ui/core/TextField';
import CircularProgress from '@material-ui/core/CircularProgress';
import Slide from '@material-ui/core/Slide';
import DialogContentText from '@material-ui/core/DialogContentText';
import LoadingIcon from '../../UI/LoadingIcon';

import IconButton from '../../UI/IconButton';
import { TAB_INDEXES } from './CommunicatorDialog.constants';
Expand Down Expand Up @@ -73,6 +74,8 @@ class CommunicatorDialogBoardItem extends React.Component {
? props.board.description
: ''
};

this.handleDialogClose = this.handleDialogClose.bind(this);
}

openMenu(e) {
Expand Down Expand Up @@ -149,14 +152,14 @@ class CommunicatorDialogBoardItem extends React.Component {

async handleBoardCopy(board) {
this.setState({
openCopyBoard: false,
loading: true
});
try {
await this.props.copyBoard(board);
} catch (err) {
} finally {
this.setState({
openCopyBoard: false,
loading: false
});
}
Expand Down Expand Up @@ -839,7 +842,9 @@ class CommunicatorDialogBoardItem extends React.Component {
</Dialog>

<Dialog
onClose={this.handleDialogClose.bind(this)}
onClose={() => {
if (!this.state.loading) this.handleDialogClose();
}}
aria-labelledby="board-copy-dialog"
open={this.state.openCopyBoard}
>
Expand All @@ -858,6 +863,7 @@ class CommunicatorDialogBoardItem extends React.Component {
<Button
onClick={this.handleDialogClose.bind(this)}
color="primary"
disabled={this.state.loading}
>
{intl.formatMessage(messages.close)}
</Button>
Expand All @@ -868,8 +874,13 @@ class CommunicatorDialogBoardItem extends React.Component {
}}
variant="contained"
color="primary"
disabled={this.state.loading}
>
{intl.formatMessage(messages.accept)}
{this.state.loading ? (
<LoadingIcon />
) : (
intl.formatMessage(messages.accept)
)}
</Button>
</PremiumFeature>
</DialogActions>
Expand Down

0 comments on commit 084181a

Please sign in to comment.