MCPcopy
hub / github.com/TanStack/query / MutationDetails

Function MutationDetails

packages/query-devtools/src/Devtools.tsx:2302–2466  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2300}
2301
2302const MutationDetails = () => {
2303 const theme = useTheme()
2304 const css = useQueryDevtoolsContext().shadowDOMTarget
2305 ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
2306 : goober.css
2307 const styles = createMemo(() => {
2308 return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
2309 })
2310
2311 const { colors } = tokens
2312 const t = (light: string, dark: string) => (theme() === 'dark' ? dark : light)
2313
2314 const isPaused = createSubscribeToMutationCacheBatcher((mutationCache) => {
2315 const mutations = mutationCache().getAll()
2316 const mutation = mutations.find(
2317 (m) => m.mutationId === selectedMutationId(),
2318 )
2319 if (!mutation) return false
2320 return mutation.state.isPaused
2321 })
2322
2323 const status = createSubscribeToMutationCacheBatcher((mutationCache) => {
2324 const mutations = mutationCache().getAll()
2325 const mutation = mutations.find(
2326 (m) => m.mutationId === selectedMutationId(),
2327 )
2328 if (!mutation) return 'idle'
2329 return mutation.state.status
2330 })
2331
2332 const color = createMemo(() =>
2333 getMutationStatusColor({
2334 isPaused: isPaused(),
2335 status: status(),
2336 }),
2337 )
2338
2339 const activeMutation = createSubscribeToMutationCacheBatcher(
2340 (mutationCache) =>
2341 mutationCache()
2342 .getAll()
2343 .find((mutation) => mutation.mutationId === selectedMutationId()),
2344 false,
2345 )
2346
2347 const getQueryStatusColors = () => {
2348 if (color() === 'gray') {
2349 return css`
2350 background-color: ${t(colors[color()][200], colors[color()][700])};
2351 color: ${t(colors[color()][700], colors[color()][300])};
2352 border-color: ${t(colors[color()][400], colors[color()][600])};
2353 `
2354 }
2355 return css`
2356 background-color: ${t(colors[color()][100], colors[color()][900])};
2357 color: ${t(colors[color()][700], colors[color()][300])};
2358 border-color: ${t(colors[color()][400], colors[color()][600])};
2359 `

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…