-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c468b8
commit 8a40649
Showing
3 changed files
with
80 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
client/app/pages/queries/utils/deleteQueryVisualization.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { clone, extend, filter } from "lodash"; | ||
import { Visualization } from "@/services/visualization"; | ||
import notification from "@/services/notification"; | ||
|
||
export default function deleteQueryVisualization(query, visualization) { | ||
return Visualization.delete({ id: visualization.id }) | ||
.$promise.then(() => { | ||
const filteredVisualizations = filter(query.visualizations, v => v.id !== visualization.id); | ||
return Promise.resolve(extend(clone(query), { visualizations: filteredVisualizations })); | ||
}) | ||
.catch(() => { | ||
notification.error("Error deleting visualization.", "Maybe it's used in a dashboard?"); | ||
return Promise.reject(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters