Skip to content

Commit 4043579

Browse files
authored
feat(aci): add project badge to detail layout (#85699)
Adds the project badge to the WorkflowEngine `<Detail />` layout
1 parent 11be9da commit 4043579

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

static/app/components/workflowEngine/layout/detail.tsx

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
11
import styled from '@emotion/styled';
22

33
import {Flex} from 'sentry/components/container/flex';
4+
import ProjectBadge from 'sentry/components/idBadge/projectBadge';
45
import * as Layout from 'sentry/components/layouts/thirds';
56
import {useDocumentTitle} from 'sentry/components/sentryDocumentTitle';
67
import {ActionsFromContext} from 'sentry/components/workflowEngine/layout/actions';
78
import {BreadcrumbsFromContext} from 'sentry/components/workflowEngine/layout/breadcrumbs';
89
import {space} from 'sentry/styles/space';
10+
import type {AvatarProject} from 'sentry/types/project';
911

1012
export interface WorkflowEngineDetailLayoutProps {
1113
/**
1214
* The main content for this page
1315
* Expected to include `<DetailLayout.Main>` and `<DetailLayout.Sidebar>` components.
1416
*/
1517
children: React.ReactNode;
18+
project: AvatarProject;
1619
}
1720

1821
/**
1922
* Precomposed 67/33 layout for Automations / Monitors detail pages.
2023
*/
21-
function DetailLayout({children}: WorkflowEngineDetailLayoutProps) {
24+
function DetailLayout({children, project}: WorkflowEngineDetailLayoutProps) {
2225
const title = useDocumentTitle();
2326
return (
2427
<StyledPage>
2528
<Layout.Header>
2629
<Layout.HeaderContent>
2730
<BreadcrumbsFromContext />
2831
<Layout.Title>{title}</Layout.Title>
32+
<ProjectContainer>
33+
<ProjectBadge project={project} disableLink avatarSize={16} />
34+
</ProjectContainer>
2935
</Layout.HeaderContent>
3036
<ActionsFromContext />
3137
</Layout.Header>
@@ -34,6 +40,11 @@ function DetailLayout({children}: WorkflowEngineDetailLayoutProps) {
3440
);
3541
}
3642

43+
const ProjectContainer = styled('div')`
44+
margin-top: ${space(1)};
45+
font-size: ${p => p.theme.fontSizeMedium};
46+
`;
47+
3748
const StyledPage = styled(Layout.Page)`
3849
background: ${p => p.theme.background};
3950
`;

static/app/components/workflowEngine/layout/index.spec.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,19 @@ describe('Detail Layout component', function () {
3939
it('renders children and context values', function () {
4040
render(
4141
<Fixture>
42-
<DetailLayout>children-test-value</DetailLayout>
42+
<DetailLayout project={{slug: 'project-slug', platform: 'javascript-astro'}}>
43+
children-test-value
44+
</DetailLayout>
4345
</Fixture>
4446
);
4547

4648
expect(screen.getByText('children-test-value')).toBeInTheDocument();
4749
expect(screen.getByRole('button', {name: 'action-test-value'})).toBeInTheDocument();
4850
expect(screen.getByRole('link', {name: 'breadcrumb-test-value'})).toBeInTheDocument();
4951
expect(screen.getByRole('heading', {name: 'title-test-value'})).toBeInTheDocument();
52+
// displays project badge
53+
expect(screen.getByRole('img')).toBeInTheDocument();
54+
expect(screen.getByTestId('badge-display-name')).toHaveTextContent('project-slug');
5055
});
5156
});
5257

static/app/views/automations/detail.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function AutomationDetail() {
1717
<SentryDocumentTitle title={t('Automation')} noSuffix>
1818
<BreadcrumbsProvider crumb={{label: t('Automations'), to: '/automations'}}>
1919
<ActionsProvider actions={<Actions />}>
20-
<DetailLayout>
20+
<DetailLayout project={{slug: 'project-slug', platform: 'javascript-astro'}}>
2121
<DetailLayout.Main>main</DetailLayout.Main>
2222
<DetailLayout.Sidebar>sidebar</DetailLayout.Sidebar>
2323
</DetailLayout>

static/app/views/detectors/detail.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ export default function DetectorDetail() {
1414
useWorkflowEngineFeatureGate({redirect: true});
1515

1616
return (
17-
<SentryDocumentTitle title={t('Edit Monitor')} noSuffix>
17+
<SentryDocumentTitle title={t('Monitor')} noSuffix>
1818
<BreadcrumbsProvider crumb={{label: t('Monitors'), to: '/monitors'}}>
1919
<ActionsProvider actions={<Actions />}>
20-
<DetailLayout>
20+
<DetailLayout project={{slug: 'project-slug', platform: 'javascript-astro'}}>
2121
<DetailLayout.Main>main</DetailLayout.Main>
2222
<DetailLayout.Sidebar>sidebar</DetailLayout.Sidebar>
2323
</DetailLayout>

0 commit comments

Comments
 (0)