MCPcopy Create free account
hub / github.com/TanStack/query / MutationDetails

Function MutationDetails

packages/query-devtools/src/Devtools.tsx:2513–2710  ·  view source on GitHub ↗
(props: { initialSearch?: string })

Source from the content-addressed store, hash-verified

2511}
2512
2513const MutationDetails = (props: { initialSearch?: string }) => {
2514 const { selectedMutationId } = useDevtoolsState()
2515
2516 const theme = useTheme()
2517 const css = useQueryDevtoolsContext().shadowDOMTarget
2518 ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
2519 : goober.css
2520 const styles = createMemo(() => {
2521 return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
2522 })
2523
2524 const { colors } = tokens
2525 const t = (light: string, dark: string) => (theme() === 'dark' ? dark : light)
2526
2527 const isPaused = createSubscribeToMutationCacheBatcher((mutationCache) => {
2528 const mutations = mutationCache().getAll()
2529 const mutation = mutations.find(
2530 (m) => m.mutationId === selectedMutationId(),
2531 )
2532 if (!mutation) return false
2533 return mutation.state.isPaused
2534 })
2535
2536 const status = createSubscribeToMutationCacheBatcher((mutationCache) => {
2537 const mutations = mutationCache().getAll()
2538 const mutation = mutations.find(
2539 (m) => m.mutationId === selectedMutationId(),
2540 )
2541 if (!mutation) return 'idle'
2542 return mutation.state.status
2543 })
2544
2545 const color = createMemo(() =>
2546 getMutationStatusColor({
2547 isPaused: isPaused(),
2548 status: status(),
2549 }),
2550 )
2551
2552 const activeMutation = createSubscribeToMutationCacheBatcher(
2553 (mutationCache) =>
2554 mutationCache()
2555 .getAll()
2556 .find((mutation) => mutation.mutationId === selectedMutationId()),
2557 false,
2558 )
2559
2560 const matchingSearch = (value: unknown) =>
2561 props.initialSearch && matchesData(value, props.initialSearch.toLowerCase())
2562 ? props.initialSearch
2563 : undefined
2564
2565 const getQueryStatusColors = () => {
2566 if (color() === 'gray') {
2567 return css`
2568 background-color: ${t(colors[color()][200], colors[color()][700])};
2569 color: ${t(colors[color()][700], colors[color()][300])};
2570 border-color: ${t(colors[color()][400], colors[color()][600])};

Callers

nothing calls this directly

Calls 12

useDevtoolsStateFunction · 0.90
useThemeFunction · 0.90
useQueryDevtoolsContextFunction · 0.90
getMutationStatusColorFunction · 0.90
displayValueFunction · 0.90
getQueryStatusColorsFunction · 0.85
matchingSearchFunction · 0.85
darkStylesFunction · 0.70
lightStylesFunction · 0.70
getAllMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected