({
runCommand,
}: {
runCommand: (command: string) => void;
})
| 57 | } |
| 58 | |
| 59 | const ShellHeader = ({ |
| 60 | runCommand, |
| 61 | }: { |
| 62 | runCommand: (command: string) => void; |
| 63 | }) => { |
| 64 | const { colors, shadows } = useTheme<MaterializeTheme>(); |
| 65 | const [shellState, setShellState] = useAtom(shellStateAtom); |
| 66 | const { |
| 67 | sessionParameters: { database, search_path: searchPath, cluster }, |
| 68 | } = shellState; |
| 69 | const { |
| 70 | data: schemas, |
| 71 | snapshotComplete: isSchemasSnapshotComplete, |
| 72 | isError: isSchemasError, |
| 73 | } = useAllSchemas({ includeSystemSchemas: false }); |
| 74 | |
| 75 | const { |
| 76 | data: clusters, |
| 77 | isError: isClustersError, |
| 78 | error: clustersSubscribeError, |
| 79 | snapshotComplete: isClustersSnapshotComplete, |
| 80 | } = useAllClusters(); |
| 81 | |
| 82 | if ( |
| 83 | isClustersError && |
| 84 | clustersSubscribeError && |
| 85 | clustersSubscribeError.code !== SUBSCRIBE_ERROR_CODE.CONNECTION_CLOSED |
| 86 | ) { |
| 87 | Sentry.captureException( |
| 88 | new Error( |
| 89 | `ClusterDropdown load errors: ${clustersSubscribeError.message} (${clustersSubscribeError.code})`, |
| 90 | ), |
| 91 | ); |
| 92 | } |
| 93 | const isSelectedClusterExtant = clusters.some((c) => c.name === cluster); |
| 94 | |
| 95 | const clusterOptions = useMemo(() => { |
| 96 | const allClusters = clusters |
| 97 | // Don't show system clusters in the dropdown |
| 98 | .filter(({ id }) => !isSystemId(id)) |
| 99 | .map((c) => ({ |
| 100 | name: c.name, |
| 101 | })); |
| 102 | |
| 103 | allClusters.sort((a, b) => a.name.localeCompare(b.name)); |
| 104 | return allClusters; |
| 105 | }, [clusters]); |
| 106 | |
| 107 | const selectedSchemaOption = useMemo(() => { |
| 108 | return getSelectedSchemaOption(searchPath, database, schemas); |
| 109 | }, [searchPath, database, schemas]); |
| 110 | |
| 111 | const schemaOptions = useMemo(() => { |
| 112 | if (schemas === undefined) { |
| 113 | return []; |
| 114 | } |
| 115 | |
| 116 | const newSchemaOptions = schemas.map(({ name, databaseName }) => ({ |
nothing calls this directly
no test coverage detected