Skip to content

Commit af035b1

Browse files
ref(ts): Convert Settings Project item to Typescript (#21404)
1 parent de3a03e commit af035b1

File tree

2 files changed

+19
-18
lines changed

2 files changed

+19
-18
lines changed

src/sentry/static/sentry/app/components/projects/bookmarkStar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import {Client} from 'app/api';
1414

1515
type Props = {
1616
api: Client;
17+
organization: Organization;
18+
project: Project;
1719
/* used to override when under local state */
1820
isBookmarked?: boolean;
1921
className?: string;
20-
organization: Organization;
21-
project: Project;
2222
onToggle?: (isBookmarked: boolean) => void;
2323
};
2424

src/sentry/static/sentry/app/views/settings/components/settingsProjectItem.jsx renamed to src/sentry/static/sentry/app/views/settings/components/settingsProjectItem.tsx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,32 @@ import React from 'react';
44
import BookmarkStar from 'app/components/projects/bookmarkStar';
55
import Link from 'app/components/links/link';
66
import ProjectLabel from 'app/components/projectLabel';
7-
import SentryTypes from 'app/sentryTypes';
87
import space from 'app/styles/space';
8+
import {Project, Organization} from 'app/types';
99

10-
class ProjectItem extends React.Component {
11-
static propTypes = {
12-
project: SentryTypes.Project,
13-
organization: SentryTypes.Organization,
14-
};
10+
type Props = {
11+
project: Project;
12+
organization: Organization;
13+
};
1514

16-
constructor(props) {
17-
super(props);
18-
this.state = {
19-
isBookmarked: this.props.project.isBookmarked,
20-
};
21-
}
15+
type State = {
16+
isBookmarked: boolean;
17+
};
18+
19+
class ProjectItem extends React.Component<Props, State> {
20+
state = {
21+
isBookmarked: this.props.project.isBookmarked,
22+
};
2223

23-
handleToggleBookmark = isBookmarked => {
24+
handleToggleBookmark = (isBookmarked: State['isBookmarked']) => {
2425
this.setState({isBookmarked});
2526
};
2627

2728
render() {
2829
const {project, organization} = this.props;
2930

3031
return (
31-
<Container key={project.id}>
32+
<Wrapper>
3233
<BookmarkLink
3334
organization={organization}
3435
project={project}
@@ -38,12 +39,12 @@ class ProjectItem extends React.Component {
3839
<Link to={`/settings/${organization.slug}/projects/${project.slug}/`}>
3940
<ProjectLabel project={project} />
4041
</Link>
41-
</Container>
42+
</Wrapper>
4243
);
4344
}
4445
}
4546

46-
const Container = styled('div')`
47+
const Wrapper = styled('div')`
4748
display: flex;
4849
align-items: center;
4950
`;

0 commit comments

Comments
 (0)