(props: { initialSearch?: string })
| 2511 | } |
| 2512 | |
| 2513 | const 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])}; |
nothing calls this directly
no test coverage detected