Skip to content

Commit d158487

Browse files
committed
Add variant analysis header
1 parent 2e9c0c3 commit d158487

File tree

7 files changed

+206
-1
lines changed

7 files changed

+206
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export enum VariantAnalysisStatus {
2+
InProgress = 'inProgress',
3+
Succeeded = 'succeeded',
4+
Failed = 'failed',
5+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import React from 'react';
2+
3+
import { ComponentStory, ComponentMeta } from '@storybook/react';
4+
5+
import { VariantAnalysisContainer } from '../../view/variant-analysis/VariantAnalysisContainer';
6+
import { VariantAnalysisHeader } from '../../view/variant-analysis/VariantAnalysisHeader';
7+
import { VariantAnalysisStatus } from '../../remote-queries/shared/variant-analysis';
8+
9+
export default {
10+
title: 'Variant Analysis Header',
11+
component: VariantAnalysisHeader,
12+
decorators: [
13+
(Story) => (
14+
<VariantAnalysisContainer>
15+
<Story />
16+
</VariantAnalysisContainer>
17+
)
18+
],
19+
argTypes: {
20+
onOpenQueryClick: {
21+
action: 'open-query-clicked',
22+
table: {
23+
disable: true,
24+
},
25+
},
26+
onViewQueryClick: {
27+
action: 'view-query-clicked',
28+
table: {
29+
disable: true,
30+
},
31+
},
32+
onStopQueryClick: {
33+
action: 'stop-query-clicked',
34+
table: {
35+
disable: true,
36+
},
37+
},
38+
onCopyRepositoryListClick: {
39+
action: 'copy-repository-list-clicked',
40+
table: {
41+
disable: true,
42+
},
43+
},
44+
onExportResultsClick: {
45+
action: 'export-results-clicked',
46+
table: {
47+
disable: true,
48+
},
49+
},
50+
}
51+
} as ComponentMeta<typeof VariantAnalysisHeader>;
52+
53+
const Template: ComponentStory<typeof VariantAnalysisHeader> = (args) => (
54+
<VariantAnalysisHeader {...args} />
55+
);
56+
57+
export const InProgress = Template.bind({});
58+
InProgress.args = {
59+
queryName: 'Query name',
60+
queryFileName: 'example.ql',
61+
status: VariantAnalysisStatus.InProgress,
62+
};
63+
64+
export const Succeeded = Template.bind({});
65+
Succeeded.args = {
66+
...InProgress.args,
67+
status: VariantAnalysisStatus.Succeeded,
68+
};
69+
70+
export const Failed = Template.bind({});
71+
Failed.args = {
72+
...InProgress.args,
73+
status: VariantAnalysisStatus.Failed,
74+
};
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import styled from 'styled-components';
22

33
const ViewTitle = styled.h1`
4-
font-size: large;
4+
font-size: 2em;
55
margin-bottom: 0.5em;
66
font-weight: 500;
7+
8+
white-space: nowrap;
9+
overflow: hidden;
10+
text-overflow: ellipsis;
711
`;
812

913
export default ViewTitle;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import styled from 'styled-components';
2+
3+
export const LinkButton = styled.button`
4+
/* Remove button styling */
5+
background: none;
6+
padding: 0;
7+
font: inherit;
8+
cursor: pointer;
9+
outline: inherit;
10+
11+
text-decoration: none;
12+
padding-right: 1em;
13+
color: var(--vscode-textLink-foreground);
14+
border: 1px solid transparent;
15+
16+
&:hover, &:active {
17+
color: var(--vscode-textLink-activeForeground);
18+
text-decoration: underline;
19+
}
20+
21+
&:focus,
22+
&:focus-visible {
23+
border: 1px solid var(--vscode-focusBorder);
24+
}
25+
`;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import styled from 'styled-components';
2+
import { LinkButton } from './LinkButton';
3+
4+
export const LinkIconButton = styled(LinkButton)`
5+
svg {
6+
margin-right: 0.3em;
7+
}
8+
`;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import styled from 'styled-components';
2+
3+
export const VariantAnalysisContainer = styled.div`
4+
max-width: 55em;
5+
`;
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import * as React from 'react';
2+
import { VariantAnalysisStatus } from '../../remote-queries/shared/variant-analysis';
3+
import ViewTitle from '../remote-queries/ViewTitle';
4+
import { CodeSquareIcon, FileCodeIcon } from '@primer/octicons-react';
5+
import { LinkIconButton } from './LinkIconButton';
6+
import styled from 'styled-components';
7+
import { VSCodeButton } from '@vscode/webview-ui-toolkit/react';
8+
9+
type Props = {
10+
queryName: string;
11+
queryFileName: string;
12+
status: VariantAnalysisStatus;
13+
14+
onOpenQueryClick: () => void;
15+
onViewQueryClick: () => void;
16+
17+
onStopQueryClick: () => void;
18+
19+
onCopyRepositoryListClick: () => void;
20+
onExportResultsClick: () => void;
21+
};
22+
23+
const Wrapper = styled.div`
24+
display: flex;
25+
align-items: center;
26+
`;
27+
28+
const HeaderWrapper = styled.div`
29+
max-width: 100%;
30+
`;
31+
32+
const ActionsWrapper = styled.div`
33+
margin-left: auto;
34+
display: flex;
35+
gap: 1em;
36+
`;
37+
38+
const Button = styled(VSCodeButton)`
39+
white-space: nowrap;
40+
`;
41+
42+
export const VariantAnalysisHeader = ({
43+
queryName,
44+
queryFileName,
45+
status,
46+
onOpenQueryClick,
47+
onViewQueryClick,
48+
onStopQueryClick,
49+
onCopyRepositoryListClick,
50+
onExportResultsClick
51+
}: Props) => {
52+
return (
53+
<Wrapper>
54+
<HeaderWrapper>
55+
<ViewTitle>{queryName}</ViewTitle>
56+
<LinkIconButton onClick={onOpenQueryClick}>
57+
<FileCodeIcon size={16} />
58+
{queryFileName}
59+
</LinkIconButton>
60+
<LinkIconButton onClick={onViewQueryClick}>
61+
<CodeSquareIcon size={16} />
62+
View query
63+
</LinkIconButton>
64+
</HeaderWrapper>
65+
<ActionsWrapper>
66+
{status === VariantAnalysisStatus.InProgress && (
67+
<VSCodeButton appearance="secondary" onClick={onStopQueryClick}>
68+
Stop query
69+
</VSCodeButton>
70+
)}
71+
{status === VariantAnalysisStatus.Succeeded && (
72+
<>
73+
<Button appearance="secondary" onClick={onCopyRepositoryListClick}>
74+
Copy repository list
75+
</Button>
76+
<Button appearance="primary" onClick={onExportResultsClick}>
77+
Export results
78+
</Button>
79+
</>
80+
)}
81+
</ActionsWrapper>
82+
</Wrapper>
83+
);
84+
};

0 commit comments

Comments
 (0)