Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] Alerts: Add shared components for Jobs #27982

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
import {Box, ErrorBoundary, Tabs} from '@dagster-io/ui-components';
import * as React from 'react';
import {useJobSidebarAlertsTabConfig} from 'shared/pipelines/useJobSidebarAlertsTabConfig.oss';

import {RightInfoPanelContent} from './GraphExplorer';
import {ExplorerPath} from './PipelinePathUtils';
import {SidebarContainerOverview} from './SidebarContainerOverview';
import {SidebarOp} from './SidebarOp';
import {TabDefinition, TabKey} from './types';
import {SidebarRootContainerFragment} from './types/SidebarContainerOverview.types';
import {OpNameOrPath} from '../ops/OpNameOrPath';
import {TypeExplorerContainer} from '../typeexplorer/TypeExplorerContainer';
import {TypeListContainer} from '../typeexplorer/TypeListContainer';
import {TabLink} from '../ui/TabLink';
import {RepoAddress} from '../workspace/types';

type TabKey = 'types' | 'info';

interface TabDefinition {
name: string;
key: TabKey;
content: () => React.ReactNode;
}

interface SidebarRootProps {
tab?: TabKey;
typeName?: string;
Expand Down Expand Up @@ -49,10 +42,10 @@ export const SidebarRoot = (props: SidebarRootProps) => {

const activeTab = tab || 'info';

const TabDefinitions: Array<TabDefinition> = [
const tabDefinitions: TabDefinition[] = [
{
name: 'Info',
key: 'info',
key: 'info' as const,
content: () =>
opHandleID ? (
<SidebarOp
Expand Down Expand Up @@ -83,7 +76,7 @@ export const SidebarRoot = (props: SidebarRootProps) => {
},
{
name: 'Types',
key: 'types',
key: 'types' as const,
content: () =>
typeName ? (
<TypeExplorerContainer
Expand All @@ -95,20 +88,21 @@ export const SidebarRoot = (props: SidebarRootProps) => {
<TypeListContainer repoAddress={repoAddress} explorerPath={explorerPath} />
),
},
];
useJobSidebarAlertsTabConfig({repoAddress, jobName: container.name}),
].filter((tab) => tab !== null);

return (
<>
<Box padding={{horizontal: 24}} border="bottom">
<Tabs selectedTabId={activeTab}>
{TabDefinitions.map(({name, key}) => (
{tabDefinitions.map(({name, key}) => (
<TabLink id={key} key={key} to={{search: `?tab=${key}`}} title={name} />
))}
</Tabs>
</Box>
<RightInfoPanelContent>
<ErrorBoundary region="tab" resetErrorOnChange={[activeTab, explorerPath]}>
{TabDefinitions.find((t) => t.key === activeTab)?.content()}
{tabDefinitions.find((t) => t.key === activeTab)?.content()}
</ErrorBoundary>
</RightInfoPanelContent>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {ReactNode} from 'react';

export type TabKey = 'types' | 'info' | 'alerts';

export interface TabDefinition {
name: string;
key: TabKey;
content: () => ReactNode;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {RepoAddress} from '../workspace/types';

export interface Config {
repoAddress?: RepoAddress;
jobName: string;
}

export const useJobSidebarAlertsTabConfig = (_: Config) => null;