Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AiLab] pending delete spinner and show model list without freshly deleted model #40064

Merged
merged 1 commit into from Apr 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions apps/src/code-studio/components/ModelManagerDialog.jsx
Expand Up @@ -54,6 +54,7 @@ export default class ModelManagerDialog extends React.Component {
models: [],
isModelListPending: true,
isImportPending: false,
isDeletePending: false,
confirmDialogOpen: false,
deletionStatus: undefined
};
Expand Down Expand Up @@ -123,16 +124,19 @@ export default class ModelManagerDialog extends React.Component {
};

deleteModel = () => {
this.setState({isDeletePending: true});
$.ajax({
url: `/api/v1/ml_models/${this.state.selectedModel.id}`,
method: 'DELETE'
}).then(response => {
if (response.status === 'failure') {
this.setState({
deletionStatus: `Model with id ${response.id} could not be deleted.`
deletionStatus: `Model with id ${response.id} could not be deleted.`,
isDeletePending: false
});
} else {
this.setState({confirmDialogOpen: false});
this.setState({confirmDialogOpen: false, isDeletePending: false});
this.getModelList();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we show a spinner while isModelListPending is true as well? (If not, should we keep isDeletePendingastrue` until the model list reload completes?

(In theory we could avoid a fresh retrieval of models by just adjusting our local list, but I actually like the idea here of getting a fresh set of information.)

}
});
};
Expand Down Expand Up @@ -220,6 +224,8 @@ export default class ModelManagerDialog extends React.Component {
onClick={this.deleteModel}
icon={'trash'}
iconClassName={'fa-trash'}
pendingText={'Deleting...'}
isPending={this.state.isDeletePending}
/>
</div>
<p style={styles.message}>{this.state.deletionStatus}</p>
Expand Down