Skip to content

Commit 88977d4

Browse files
committed
refactor: remove duplicate interfaces
1 parent 4b2924b commit 88977d4

File tree

12 files changed

+69
-155
lines changed

12 files changed

+69
-155
lines changed

src/types/models.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface UserData {
99
admin?: boolean;
1010
}
1111

12-
export interface Commit {
12+
export interface CommitData {
1313
commitTs?: number;
1414
message: string;
1515
committer: string;
@@ -19,3 +19,31 @@ export interface Commit {
1919
authorEmail: string;
2020
commitTimestamp?: number;
2121
}
22+
23+
export interface PushData {
24+
id: string;
25+
repo: string;
26+
branch: string;
27+
commitFrom: string;
28+
commitTo: string;
29+
commitData: CommitData[];
30+
diff: {
31+
content: string;
32+
};
33+
canceled?: boolean;
34+
rejected?: boolean;
35+
authorised?: boolean;
36+
attestation?: AttestationData;
37+
autoApproved?: boolean;
38+
timestamp: string | Date;
39+
}
40+
41+
export interface Route {
42+
path: string;
43+
layout: string;
44+
name: string;
45+
rtlName?: string;
46+
component: React.ComponentType<any>;
47+
icon?: string | React.ComponentType<any>;
48+
visible?: boolean;
49+
}

src/ui/assets/jss/material-dashboard-react/layouts/adminStyle.ts

Lines changed: 0 additions & 43 deletions
This file was deleted.

src/ui/components/Navbars/Navbar.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,10 @@ import Hidden from '@material-ui/core/Hidden';
88
import Menu from '@material-ui/icons/Menu';
99
import DashboardNavbarLinks from './DashboardNavbarLinks';
1010
import styles from '../../assets/jss/material-dashboard-react/components/headerStyle';
11+
import { Route } from '../../../types/models';
1112

1213
const useStyles = makeStyles(styles as any);
1314

14-
interface Route {
15-
component: any;
16-
icon: any;
17-
layout: string;
18-
name: string;
19-
rtlName?: string;
20-
path: string;
21-
visible: boolean;
22-
}
23-
2415
interface HeaderProps {
2516
color?: 'primary' | 'info' | 'success' | 'warning' | 'danger';
2617
rtlActive?: boolean;

src/ui/components/Sidebar/Sidebar.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,10 @@ import ListItem from '@material-ui/core/ListItem';
99
import ListItemText from '@material-ui/core/ListItemText';
1010
import Icon from '@material-ui/core/Icon';
1111
import styles from '../../assets/jss/material-dashboard-react/components/sidebarStyle';
12+
import { Route } from '../../../types/models';
1213

1314
const useStyles = makeStyles(styles as any);
1415

15-
interface Route {
16-
path: string;
17-
layout: string;
18-
name: string;
19-
icon: string | React.ComponentType;
20-
visible?: boolean;
21-
rtlName?: string;
22-
component: React.ComponentType;
23-
}
24-
2516
interface SidebarProps {
2617
color: 'purple' | 'blue' | 'green' | 'orange' | 'red';
2718
logo: string;

src/ui/layouts/Dashboard.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,7 @@ import styles from '../assets/jss/material-dashboard-react/layouts/dashboardStyl
1111
import logo from '../assets/img/git-proxy.png';
1212
import { UserContext } from '../../context';
1313
import { getUser } from '../services/user';
14-
15-
interface RouteType {
16-
layout: string;
17-
path: string;
18-
component: React.ComponentType<any>;
19-
}
14+
import { Route as RouteType } from '../../types/models';
2015

2116
interface DashboardProps {
2217
[key: string]: any;

src/ui/views/OpenPushRequests/components/PushesTable.tsx

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,7 @@ import { getPushes } from '../../../services/git-push';
1515
import { KeyboardArrowRight } from '@material-ui/icons';
1616
import Search from '../../../components/Search/Search';
1717
import Pagination from '../../../components/Pagination/Pagination';
18-
19-
interface CommitData {
20-
commitTs?: number;
21-
commitTimestamp?: number;
22-
message: string;
23-
committer: string;
24-
author: string;
25-
authorEmail?: string;
26-
}
27-
28-
interface PushData {
29-
id: string;
30-
repo: string;
31-
branch: string;
32-
commitTo: string;
33-
commitData: CommitData[];
34-
}
18+
import { PushData } from '../../../../types/models';
3519

3620
interface PushesTableProps {
3721
[key: string]: any;

src/ui/views/PushDetails/PushDetails.tsx

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +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 { CommitData } from '../../../types/models';
26-
27-
interface Reviewer {
28-
username: string;
29-
gitAccount: string;
30-
}
31-
32-
interface AttestationData {
33-
reviewer: Reviewer;
34-
timestamp: string | Date;
35-
questions: Array<{ label: string; checked: boolean }>;
36-
}
37-
38-
interface PushData {
39-
id: string;
40-
repo: string;
41-
branch: string;
42-
commitFrom: string;
43-
commitTo: string;
44-
commitData: CommitData[];
45-
diff: {
46-
content: string;
47-
};
48-
canceled?: boolean;
49-
rejected?: boolean;
50-
authorised?: boolean;
51-
attestation?: AttestationData;
52-
autoApproved?: boolean;
53-
timestamp: string | Date;
54-
}
25+
import { PushData } from '../../../types/models';
5526

5627
const Dashboard: React.FC = () => {
5728
const { id } = useParams<{ id: string }>();
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
interface Question {
2+
label: string;
3+
checked: boolean;
4+
}
5+
6+
interface Reviewer {
7+
username: string;
8+
gitAccount: string;
9+
}
10+
11+
interface AttestationData {
12+
reviewer: Reviewer;
13+
timestamp: string | Date;
14+
questions: Question[];
15+
}
16+
17+
interface AttestationViewProps {
18+
attestation: boolean;
19+
setAttestation: (value: boolean) => void;
20+
data: AttestationData;
21+
}

src/ui/views/PushDetails/components/AttestationView.tsx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,6 @@ import { withStyles } from '@material-ui/core/styles';
1212
import { green } from '@material-ui/core/colors';
1313
import { getURLShortener } from '../../../services/config';
1414

15-
interface Question {
16-
label: string;
17-
checked: boolean;
18-
}
19-
20-
interface Reviewer {
21-
username: string;
22-
gitAccount: string;
23-
}
24-
25-
interface AttestationData {
26-
reviewer: Reviewer;
27-
timestamp: string | Date;
28-
questions: Question[];
29-
}
30-
31-
interface AttestationViewProps {
32-
attestation: boolean;
33-
setAttestation: (value: boolean) => void;
34-
data: AttestationData;
35-
}
36-
3715
const StyledFormControlLabel = withStyles({
3816
root: {
3917
color: 'white',

src/ui/views/RepoList/Components/RepoOverview.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@ import moment from 'moment';
88
import CodeActionButton from '../../../components/CustomButtons/CodeActionButton';
99
import { languageColors } from '../../../../constants/languageColors';
1010

11-
interface RepositoriesProps {
12-
data: {
13-
project: string;
14-
name: string;
15-
proxyURL: string;
16-
users?: {
17-
canPush?: string[];
18-
canAuthorise?: string[];
19-
};
20-
};
21-
}
22-
2311
interface GitHubRepository {
2412
description?: string;
2513
language?: string;

0 commit comments

Comments
 (0)