Skip to content

Commit

Permalink
feat(aci): add project badge to detail layout (#85699)
Browse files Browse the repository at this point in the history
Adds the project badge to the WorkflowEngine `<Detail />` layout
  • Loading branch information
natemoo-re authored Feb 21, 2025
1 parent 11be9da commit 4043579
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
13 changes: 12 additions & 1 deletion static/app/components/workflowEngine/layout/detail.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
import styled from '@emotion/styled';

import {Flex} from 'sentry/components/container/flex';
import ProjectBadge from 'sentry/components/idBadge/projectBadge';
import * as Layout from 'sentry/components/layouts/thirds';
import {useDocumentTitle} from 'sentry/components/sentryDocumentTitle';
import {ActionsFromContext} from 'sentry/components/workflowEngine/layout/actions';
import {BreadcrumbsFromContext} from 'sentry/components/workflowEngine/layout/breadcrumbs';
import {space} from 'sentry/styles/space';
import type {AvatarProject} from 'sentry/types/project';

export interface WorkflowEngineDetailLayoutProps {
/**
* The main content for this page
* Expected to include `<DetailLayout.Main>` and `<DetailLayout.Sidebar>` components.
*/
children: React.ReactNode;
project: AvatarProject;
}

/**
* Precomposed 67/33 layout for Automations / Monitors detail pages.
*/
function DetailLayout({children}: WorkflowEngineDetailLayoutProps) {
function DetailLayout({children, project}: WorkflowEngineDetailLayoutProps) {
const title = useDocumentTitle();
return (
<StyledPage>
<Layout.Header>
<Layout.HeaderContent>
<BreadcrumbsFromContext />
<Layout.Title>{title}</Layout.Title>
<ProjectContainer>
<ProjectBadge project={project} disableLink avatarSize={16} />
</ProjectContainer>
</Layout.HeaderContent>
<ActionsFromContext />
</Layout.Header>
Expand All @@ -34,6 +40,11 @@ function DetailLayout({children}: WorkflowEngineDetailLayoutProps) {
);
}

const ProjectContainer = styled('div')`
margin-top: ${space(1)};
font-size: ${p => p.theme.fontSizeMedium};
`;

const StyledPage = styled(Layout.Page)`
background: ${p => p.theme.background};
`;
Expand Down
7 changes: 6 additions & 1 deletion static/app/components/workflowEngine/layout/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,19 @@ describe('Detail Layout component', function () {
it('renders children and context values', function () {
render(
<Fixture>
<DetailLayout>children-test-value</DetailLayout>
<DetailLayout project={{slug: 'project-slug', platform: 'javascript-astro'}}>
children-test-value
</DetailLayout>
</Fixture>
);

expect(screen.getByText('children-test-value')).toBeInTheDocument();
expect(screen.getByRole('button', {name: 'action-test-value'})).toBeInTheDocument();
expect(screen.getByRole('link', {name: 'breadcrumb-test-value'})).toBeInTheDocument();
expect(screen.getByRole('heading', {name: 'title-test-value'})).toBeInTheDocument();
// displays project badge
expect(screen.getByRole('img')).toBeInTheDocument();
expect(screen.getByTestId('badge-display-name')).toHaveTextContent('project-slug');
});
});

Expand Down
2 changes: 1 addition & 1 deletion static/app/views/automations/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function AutomationDetail() {
<SentryDocumentTitle title={t('Automation')} noSuffix>
<BreadcrumbsProvider crumb={{label: t('Automations'), to: '/automations'}}>
<ActionsProvider actions={<Actions />}>
<DetailLayout>
<DetailLayout project={{slug: 'project-slug', platform: 'javascript-astro'}}>
<DetailLayout.Main>main</DetailLayout.Main>
<DetailLayout.Sidebar>sidebar</DetailLayout.Sidebar>
</DetailLayout>
Expand Down
4 changes: 2 additions & 2 deletions static/app/views/detectors/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export default function DetectorDetail() {
useWorkflowEngineFeatureGate({redirect: true});

return (
<SentryDocumentTitle title={t('Edit Monitor')} noSuffix>
<SentryDocumentTitle title={t('Monitor')} noSuffix>
<BreadcrumbsProvider crumb={{label: t('Monitors'), to: '/monitors'}}>
<ActionsProvider actions={<Actions />}>
<DetailLayout>
<DetailLayout project={{slug: 'project-slug', platform: 'javascript-astro'}}>
<DetailLayout.Main>main</DetailLayout.Main>
<DetailLayout.Sidebar>sidebar</DetailLayout.Sidebar>
</DetailLayout>
Expand Down

0 comments on commit 4043579

Please sign in to comment.