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

Function MutationRow

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

Source from the content-addressed store, hash-verified

1704}
1705
1706const MutationRow: Component<{ mutation: Mutation }> = (props) => {
1707 const { selectedMutationId, setSelectedMutationId } = useDevtoolsState()
1708
1709 const theme = useTheme()
1710 const css = useQueryDevtoolsContext().shadowDOMTarget
1711 ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
1712 : goober.css
1713 const styles = createMemo(() => {
1714 return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
1715 })
1716
1717 const { colors, alpha } = tokens
1718 const t = (light: string, dark: string) => (theme() === 'dark' ? dark : light)
1719
1720 const mutationState = createSubscribeToMutationCacheBatcher(
1721 () => props.mutation.state,
1722 )
1723
1724 const isPaused = createSubscribeToMutationCacheBatcher(
1725 () => props.mutation.state.isPaused,
1726 )
1727
1728 const status = createSubscribeToMutationCacheBatcher(
1729 () => props.mutation.state.status,
1730 )
1731
1732 const color = createMemo(() =>
1733 getMutationStatusColor({
1734 isPaused: isPaused(),
1735 status: status(),
1736 }),
1737 )
1738
1739 const getObserverCountColorStyles = () => {
1740 if (color() === 'gray') {
1741 return css`
1742 background-color: ${t(colors[color()][200], colors[color()][700])};
1743 color: ${t(colors[color()][700], colors[color()][300])};
1744 `
1745 }
1746
1747 return css`
1748 background-color: ${t(
1749 colors[color()][200] + alpha[80],
1750 colors[color()][900],
1751 )};
1752 color: ${t(colors[color()][800], colors[color()][300])};
1753 `
1754 }
1755
1756 return (
1757 <Show when={mutationState()}>
1758 <button
1759 onClick={() => {
1760 setSelectedMutationId(
1761 props.mutation.mutationId === selectedMutationId()
1762 ? null
1763 : props.mutation.mutationId,

Callers

nothing calls this directly

Calls 8

useDevtoolsStateFunction · 0.90
useThemeFunction · 0.90
useQueryDevtoolsContextFunction · 0.90
getMutationStatusColorFunction · 0.90
darkStylesFunction · 0.70
lightStylesFunction · 0.70

Tested by

no test coverage detected