MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / ShellHeader

Function ShellHeader

console/src/platform/shell/ShellHeader.tsx:59–253  ·  view source on GitHub ↗
({
  runCommand,
}: {
  runCommand: (command: string) => void;
})

Source from the content-addressed store, hash-verified

57}
58
59const 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 }) => ({

Callers

nothing calls this directly

Calls 10

useAllSchemasFunction · 0.90
useAllClustersFunction · 0.90
isSystemIdFunction · 0.90
getSelectedSchemaOptionFunction · 0.90
createNamespaceFunction · 0.90
quoteIdentifierFunction · 0.90
setTutorialVisibilityFunction · 0.85
sortMethod · 0.80
mapMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected