Skip to content

Commit adbaffe

Browse files
fix: Error handling for pinned items (#5115)
1 parent 33b7780 commit adbaffe

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/dashboards/components/dashboard_index/DashboardCard.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,15 @@ class DashboardCard extends PureComponent<Props> {
228228
)
229229
}
230230

231-
private handleDeleteDashboard = () => {
231+
private handleDeleteDashboard = async () => {
232232
const {id, name, onDeleteDashboard} = this.props
233233
onDeleteDashboard(id, name)
234-
deletePinnedItemByParam(id)
234+
try {
235+
await deletePinnedItemByParam(id)
236+
this.props.sendNotification(pinnedItemSuccess('task', 'deleted'))
237+
} catch (error) {
238+
this.props.sendNotification(pinnedItemFailure(error.message, 'delete'))
239+
}
235240
}
236241

237242
private handleClickDashboard = event => {

src/flows/components/header/MenuButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const MenuButton: FC<Props> = ({handleResetShare}) => {
6666
event('delete_notebook', {
6767
context: 'notebook',
6868
})
69-
deletePinnedItemByParam(flow.id)
69+
await deletePinnedItemByParam(flow.id)
7070
await deleteNotebook()
7171
setLoading(RemoteDataState.Done)
7272
history.push(`/orgs/${orgID}/${PROJECT_NAME_PLURAL.toLowerCase()}`)

src/tasks/components/TaskCard.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,13 @@ export class TaskCard extends PureComponent<
157157
}
158158
}
159159

160-
private handleOnDelete = task => {
160+
private handleOnDelete = async task => {
161161
this.props.onDelete(task)
162-
deletePinnedItemByParam(task.id)
162+
try {
163+
await deletePinnedItemByParam(task.id)
164+
} catch (error) {
165+
this.props.sendNotification(pinnedItemFailure(error.message, 'delete'))
166+
}
163167
}
164168
private get contextMenu(): JSX.Element {
165169
const {task, onClone, isPinned} = this.props

0 commit comments

Comments
 (0)