import { View, Text, StyleSheet, ScrollView } from "react-native";
import { Mutation } from "@tanstack/react-query";
import { useSafeAreaInsets } from "@react-buoy/shared-ui";
import Explorer from "./query-browser/Explorer";
import MutationDetails from "./query-browser/MutationDetails";
import ActionButton from "./query-browser/ActionButton";
import { useMutationActionButtons } from "../hooks/useMutationActionButtons";
import { macOSColors } from "@react-buoy/shared-ui";
import { DataViewer } from "@react-buoy/shared-ui/dataViewer";
interface MutationEditorModeProps {
selectedMutation: Mutation;
isFloatingMode: boolean;
}
/**
* Mutation-focused editing experience mirroring the query editor layout. Provides mutation detail
* panels, data inspector, and action buttons for the selected mutation entry.
*/
export function MutationEditorMode({
selectedMutation,
isFloatingMode,
}: MutationEditorModeProps) {
const insets = useSafeAreaInsets({ minBottom: 16 });
const actionButtons = useMutationActionButtons(selectedMutation);
return (
<>
{/* Data Explorer Section */}
{/* Mutation Details Section */}
{/* Mutation Explorer Section - Non-editable viewer */}
Mutation Explorer
{/* Action Footer with Safe Area */}
{actionButtons.map((action, index) => (
))}
>
);
}
function DataExplorer({
visible,
selectedMutation,
}: {
visible: boolean;
selectedMutation: Mutation;
}) {
if (!visible) return null;
return (
Data Editor
);
}
function DataEmptyState({
visible,
selectedMutation,
}: {
visible: boolean;
selectedMutation: Mutation;
}) {
if (!visible) return null;
const getEmptyStateContent = () => {
if (selectedMutation.state.status === "pending") {
return {
title: "Pending...",
description: "The mutation is in progress.",
};
}
if (selectedMutation.state.status === "error") {
return {
title: "Mutation Error",
description:
selectedMutation.state.error?.message || "An error occurred.",
};
}
return {
title: "No Data Available",
description: "This mutation has no data.",
};
};
const { title, description } = getEmptyStateContent();
return (
{title}
{description}
);
}
const styles = StyleSheet.create({
explorerScrollContainer: {
flex: 1,
},
explorerScrollContent: {
paddingBottom: 16,
paddingHorizontal: 8,
flexGrow: 1,
},
section: {
marginBottom: 16,
},
emptyState: {
flex: 1,
justifyContent: "center",
alignItems: "center",
padding: 32,
},
emptyTitle: {
color: macOSColors.text.primary,
fontSize: 18,
fontWeight: "600",
marginBottom: 8,
textAlign: "center",
},
emptyDescription: {
color: macOSColors.text.secondary,
fontSize: 14,
textAlign: "center",
lineHeight: 20,
maxWidth: 280,
},
actionFooter: {
borderTopWidth: 1,
borderTopColor: macOSColors.border.default,
paddingVertical: 8,
paddingHorizontal: 12,
backgroundColor: macOSColors.background.base,
borderBottomLeftRadius: 14,
borderBottomRightRadius: 14,
},
actionsGrid: {
flexDirection: "row",
flexWrap: "wrap",
gap: 6,
justifyContent: "space-between",
},
// Mutation Explorer styled container matching QueryDetails
mutationExplorerContainer: {
minWidth: 200,
backgroundColor: macOSColors.background.card,
borderRadius: 6,
borderWidth: 1,
borderColor: macOSColors.semantic.info + "4D",
overflow: "hidden",
shadowColor: macOSColors.semantic.info,
shadowOffset: { width: 0, height: 0 },
shadowOpacity: 0.1,
shadowRadius: 6,
},
mutationExplorerHeader: {
backgroundColor: macOSColors.semantic.infoBackground,
paddingHorizontal: 12,
paddingVertical: 10,
fontWeight: "600",
fontSize: 12,
color: macOSColors.semantic.info,
borderBottomWidth: 1,
borderBottomColor: macOSColors.semantic.info + "33",
letterSpacing: 0.5,
textTransform: "uppercase",
fontFamily: "monospace",
},
mutationExplorerContent: {
padding: 8,
},
// Data section matching query editor theme for consistency
dataContainer: {
minWidth: 200,
backgroundColor: macOSColors.background.card,
borderRadius: 6,
borderWidth: 1,
borderColor: macOSColors.semantic.info + "4D",
overflow: "hidden",
shadowColor: macOSColors.semantic.info,
shadowOffset: { width: 0, height: 0 },
shadowOpacity: 0.1,
shadowRadius: 6,
},
dataHeader: {
backgroundColor: macOSColors.semantic.infoBackground,
paddingHorizontal: 12,
paddingVertical: 10,
fontWeight: "600",
fontSize: 12,
color: macOSColors.semantic.info,
borderBottomWidth: 1,
borderBottomColor: macOSColors.semantic.info + "33",
letterSpacing: 0.5,
textTransform: "uppercase",
fontFamily: "monospace",
},
dataContent: {
padding: 8,
},
});