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

Function MutationRow

packages/query-devtools/src/Devtools.tsx:1483–1592  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

1481}
1482
1483const MutationRow: Component<{ mutation: Mutation }> = (props) => {
1484 const theme = useTheme()
1485 const css = useQueryDevtoolsContext().shadowDOMTarget
1486 ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
1487 : goober.css
1488 const styles = createMemo(() => {
1489 return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
1490 })
1491
1492 const { colors, alpha } = tokens
1493 const t = (light: string, dark: string) => (theme() === 'dark' ? dark : light)
1494
1495 const mutationState = createSubscribeToMutationCacheBatcher(
1496 (mutationCache) => {
1497 const mutations = mutationCache().getAll()
1498 const mutation = mutations.find(
1499 (m) => m.mutationId === props.mutation.mutationId,
1500 )
1501 return mutation?.state
1502 },
1503 )
1504
1505 const isPaused = createSubscribeToMutationCacheBatcher((mutationCache) => {
1506 const mutations = mutationCache().getAll()
1507 const mutation = mutations.find(
1508 (m) => m.mutationId === props.mutation.mutationId,
1509 )
1510 if (!mutation) return false
1511 return mutation.state.isPaused
1512 })
1513
1514 const status = createSubscribeToMutationCacheBatcher((mutationCache) => {
1515 const mutations = mutationCache().getAll()
1516 const mutation = mutations.find(
1517 (m) => m.mutationId === props.mutation.mutationId,
1518 )
1519 if (!mutation) return 'idle'
1520 return mutation.state.status
1521 })
1522
1523 const color = createMemo(() =>
1524 getMutationStatusColor({
1525 isPaused: isPaused(),
1526 status: status(),
1527 }),
1528 )
1529
1530 const getObserverCountColorStyles = () => {
1531 if (color() === 'gray') {
1532 return css`
1533 background-color: ${t(colors[color()][200], colors[color()][700])};
1534 color: ${t(colors[color()][700], colors[color()][300])};
1535 `
1536 }
1537
1538 return css`
1539 background-color: ${t(
1540 colors[color()][200] + alpha[80],

Callers

nothing calls this directly

Calls 9

useThemeFunction · 0.90
useQueryDevtoolsContextFunction · 0.90
getMutationStatusColorFunction · 0.90
darkStylesFunction · 0.70
lightStylesFunction · 0.70
getAllMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected