pkdotson commented on a change in pull request #11206:
URL:
https://github.com/apache/incubator-superset/pull/11206#discussion_r511084662
##########
File path: superset-frontend/src/views/CRUD/hooks.ts
##########
@@ -348,5 +355,87 @@ export function useFavoriteStatus(
);
};
- return [favoriteStatusRef, fetchFaveStar, saveFaveStar] as const;
+ return [
+ favoriteStatusRef,
+ fetchFaveStar,
+ saveFaveStar,
+ favoriteStatus,
+ ] as const;
}
+
+export const useChartEditModal = (
+ setCharts: (charts: Array<Chart>) => void,
+ charts: Array<Chart>,
+) => {
+ const [
+ sliceCurrentlyEditing,
+ setSliceCurrentlyEditing,
+ ] = useState<Slice | null>(null);
+
+ function openChartEditModal(chart: Chart) {
+ setSliceCurrentlyEditing({
+ slice_id: chart.id,
+ slice_name: chart.slice_name,
+ description: chart.description,
+ cache_timeout: chart.cache_timeout,
+ });
+ }
+
+ function closeChartEditModal() {
+ setSliceCurrentlyEditing(null);
+ }
+
+ function handleChartUpdated(edits: Chart) {
+ // update the chart in our state with the edited info
+ const newCharts = charts.map((chart: Chart) =>
+ chart.id === edits.id ? { ...chart, ...edits } : chart,
+ );
+ setCharts(newCharts);
+ }
+
+ return {
+ sliceCurrentlyEditing,
+ handleChartUpdated,
+ openChartEditModal,
+ closeChartEditModal,
+ };
+};
+
+export const copyQueryLink = (
Review comment:
I'm going to right a follow up ticket for this for moving this into a
util folder
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]