Skip to content

Commit f68f048

Browse files
committed
refactor: simplify AttestationFormData and QuestionFormData types, add base types for API
1 parent 127920f commit f68f048

File tree

4 files changed

+18
-20
lines changed

4 files changed

+18
-20
lines changed

src/proxy/actions/Action.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { processGitURLForNameAndOrg, processUrlPath } from '../routes/helper';
22
import { Step } from './Step';
3-
import { CommitData } from '../processors/types';
4-
import { AttestationFormData } from '../../ui/types';
3+
import { Attestation, CommitData } from '../processors/types';
54

65
/**
76
* Class representing a Push.
@@ -34,7 +33,7 @@ class Action {
3433
author?: string;
3534
user?: string;
3635
userEmail?: string;
37-
attestation?: AttestationFormData;
36+
attestation?: Attestation;
3837
lastStep?: Step;
3938
proxyGitPath?: string;
4039
newIdxFiles?: string[];

src/proxy/processors/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Question } from '../../config/generated/config';
12
import { Action } from '../actions';
23

34
export interface Processor {
@@ -9,6 +10,15 @@ export interface ProcessorMetadata {
910
displayName: string;
1011
}
1112

13+
export type Attestation = {
14+
reviewer: {
15+
username: string;
16+
gitAccount: string;
17+
};
18+
timestamp: string | Date;
19+
questions: Question[];
20+
};
21+
1222
export type CommitContent = {
1323
item: number;
1424
type: number;

src/ui/types.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Action } from '../proxy/actions';
22
import { Step } from '../proxy/actions/Step';
33
import { Repo } from '../db/types';
4+
import { Attestation } from '../proxy/processors/types';
5+
import { Question } from '../config/generated/config';
46

57
export interface PushActionView extends Action {
68
diff: Step;
@@ -12,24 +14,11 @@ export interface RepoView extends Repo {
1214
dateCreated?: string;
1315
}
1416

15-
export interface QuestionFormData {
16-
label: string;
17+
export interface QuestionFormData extends Question {
1718
checked: boolean;
18-
tooltip: {
19-
text: string;
20-
links?: {
21-
text: string;
22-
url: string;
23-
}[];
24-
};
2519
}
2620

27-
export interface AttestationFormData {
28-
reviewer: {
29-
username: string;
30-
gitAccount: string;
31-
};
32-
timestamp: string | Date;
21+
export interface AttestationFormData extends Attestation {
3322
questions: QuestionFormData[];
3423
}
3524

src/ui/views/PushDetails/PushDetails.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { getPush, authorisePush, rejectPush, cancelPush } from '../../services/g
2222
import { CheckCircle, Visibility, Cancel, Block } from '@material-ui/icons';
2323
import Snackbar from '@material-ui/core/Snackbar';
2424
import Tooltip from '@material-ui/core/Tooltip';
25-
import { PushActionView } from '../../types';
25+
import { AttestationFormData, PushActionView } from '../../types';
2626
import { trimPrefixRefsHeads, trimTrailingDotGit } from '../../../db/helper';
2727
import { generateEmailLink, getGitProvider } from '../../utils';
2828
import UserLink from '../../components/UserLink/UserLink';
@@ -233,7 +233,7 @@ const Dashboard: React.FC = () => {
233233

234234
{!push.autoApproved && (
235235
<AttestationView
236-
data={push.attestation}
236+
data={push.attestation as AttestationFormData}
237237
attestation={attestation}
238238
setAttestation={setAttestation}
239239
/>

0 commit comments

Comments
 (0)