Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert files related to redux from js to ts #462

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
61fa7eb
[MM-222] Convert reducer and action types file to typescript and remo…
raghavaggarwal2308 Feb 16, 2024
90db1a0
[MM-222] Converted select file to typescript and fixes some css warnings
raghavaggarwal2308 Feb 16, 2024
f7b3d14
[MM-222] Convert actions file to typescript
raghavaggarwal2308 Feb 16, 2024
9588241
[MM-222] Updated reducer, used reducer type for store and added more …
ayusht2810 Mar 26, 2024
58fb984
Merge branch 'master' of github.com:mattermost/mattermost-plugin-gitl…
ayusht2810 Mar 26, 2024
c765edd
[MM-222] Resolved conflicts from master
ayusht2810 Mar 26, 2024
950a339
[MM-222] Migrate a component to TS and minor review fixes
ayusht2810 Mar 28, 2024
7eaf225
[MM-222] Fix flaky test
ayusht2810 Mar 28, 2024
70f6986
Merge branch 'master' of github.com:mattermost/mattermost-plugin-gitl…
raghavaggarwal2308 Jun 25, 2024
ee206bc
[MM-520] Review fixes
raghavaggarwal2308 Jun 25, 2024
98b9f75
[MM-520] Fix ts error in index file
raghavaggarwal2308 Jun 25, 2024
e501324
Merge branch 'master' of github.com:mattermost/mattermost-plugin-gitl…
raghavaggarwal2308 Jul 3, 2024
a696754
[MM-542] Review fixes
raghavaggarwal2308 Jul 3, 2024
c8c2c38
MM-222: converted client file to TS
Kshitij-Katiyar Jul 8, 2024
ec3d6a0
[MM-222]: Added type to the client promises
Kshitij-Katiyar Jul 9, 2024
ce22b9a
[MM-222]: Added more types to the client.ts file
Kshitij-Katiyar Jul 9, 2024
e75b2c6
[MM-222]: updated function return type and added few types to client.ts
Kshitij-Katiyar Jul 10, 2024
7ac4b3b
[MM-222]: fixed linting issue
Kshitij-Katiyar Jul 10, 2024
35554b2
[MM-222]: resolved conflicts
Kshitij-Katiyar Jul 10, 2024
d1ebe67
[MM-222]: removed null type from client.ts API response
Kshitij-Katiyar Jul 10, 2024
64b28bc
[MM-222]: Added some additional types
Kshitij-Katiyar Jul 15, 2024
64b4385
Added lint types
Kshitij-Katiyar Jul 15, 2024
f7b2bf2
Merge branch 'master' of github.com:mattermost/mattermost-plugin-gitl…
raghavaggarwal2308 Jul 31, 2024
ff8d95d
[MM-656] Add types for redux funcs related to create issue and attach…
raghavaggarwal2308 Aug 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 24 additions & 19 deletions webapp/src/client/client.js → webapp/src/client/client.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
import {Client4} from 'mattermost-redux/client';
import {ClientError} from 'mattermost-redux/client/client4';

import {Item, TooltipData} from 'src/types/gitlab_items';
import {APIError, ConnectedData, GitlabUsersData, LHSData, SubscriptionData} from 'src/types';

export default class Client {
setServerRoute = (url) => {
private url = '';

setServerRoute(url: string): void {
this.url = `${url}/api/v1`;
}

getConnected = async (reminder = false) => {
async getConnected(reminder: boolean): Promise<ConnectedData> {
return this.doGet(`${this.url}/connected?reminder=` + reminder);
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
};
}

getPrsDetails = async (prList) => {
async getPrsDetails(prList: any): Promise<Item | APIError> {
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
return this.doPost(`${this.url}/prdetails`, prList);
}

getLHSData= async () => {
async getLHSData(): Promise<LHSData | APIError> {
return this.doGet(`${this.url}/lhs-data`);
}

getGitlabUser = async (userID) => {
async getGitlabUser(userID: string): Promise<GitlabUsersData> {
return this.doPost(`${this.url}/user`, {user_id: userID});
};
}

getIssue = async (owner, repo, issueNumber) => {
async getIssue(owner: string, repo: string, issueNumber: string): Promise<TooltipData | null> {
return this.doGet(`${this.url}/issue?owner=${owner}&repo=${repo}&number=${issueNumber}`);
}

getPullRequest = async (owner, repo, prNumber) => {
async getPullRequest(owner: string, repo: string, prNumber: string): Promise<TooltipData | null> {
Kshitij-Katiyar marked this conversation as resolved.
Show resolved Hide resolved
return this.doGet(`${this.url}/mergerequest?owner=${owner}&repo=${repo}&number=${prNumber}`);
}

getChannelSubscriptions = async (channelID) => {
async getChannelSubscriptions(channelID: string): Promise<SubscriptionData> {
return this.doGet(`${this.url}/channel/${channelID}/subscriptions`);
};
}

doGet = async (url, body, headers = {}) => {
private async doGet(url: string, body?: any, headers: Record<string, any> = {}): Promise<any> {
headers['X-Timezone-Offset'] = new Date().getTimezoneOffset();

const options = {
Expand All @@ -55,9 +60,9 @@ export default class Client {
status_code: response.status,
url,
});
};
}

doPost = async (url, body, headers = {}) => {
private async doPost(url: string, body: any, headers: Record<string, any> = {}): Promise<any> {
headers['X-Timezone-Offset'] = new Date().getTimezoneOffset();

const options = {
Expand All @@ -79,9 +84,9 @@ export default class Client {
status_code: response.status,
url,
});
};
}

doDelete = async (url, body, headers = {}) => {
private async doDelete(url: string, body?: any, headers: Record<string, any> = {}): Promise<any> {
headers['X-Timezone-Offset'] = new Date().getTimezoneOffset();

const options = {
Expand All @@ -102,9 +107,9 @@ export default class Client {
status_code: response.status,
url,
});
};
}

doPut = async (url, body, headers = {}) => {
private async doPut(url: string, body: any, headers: Record<string, any> = {}): Promise<any> {
headers['X-Timezone-Offset'] = new Date().getTimezoneOffset();

const options = {
Expand All @@ -126,5 +131,5 @@ export default class Client {
status_code: response.status,
url,
});
};
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ClientClass from './client.js';
import ClientClass from './client';

const Client = new ClientClass();

Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/user_attribute/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ function mapDispatchToProps(dispatch: Dispatch<AnyAction>) {
export default connect(
mapStateToProps,
mapDispatchToProps,
)(UserAttribute as React.ComponentType<UserAttributeStateProps & UserAttributeDispatchProps>);
)(UserAttribute);
58 changes: 31 additions & 27 deletions webapp/src/components/user_attribute/user_attribute.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,40 @@
import React, {PureComponent} from 'react';
import React, {useEffect, CSSProperties} from 'react';

import type {UserAttributeProps} from '.';

export default class UserAttribute extends PureComponent<UserAttributeProps> {
componentDidMount() {
this.props.actions.getGitlabUser(this.props.id);
}

render() {
const username = this.props.username;
const baseURL = this.props.gitlabURL;
interface UserAttributeProps {
id: string;
username?: string;
gitlabURL?: string;
actions: {
getGitlabUser: (id: string) => void;
};
}

if (!username || !baseURL) {
return null;
}
const UserAttribute = ({id, username, gitlabURL, actions}: UserAttributeProps) => {
useEffect(() => {
actions.getGitlabUser(id);
}, [id, actions]);

return (
<div style={style.container}>
<a
href={baseURL + '/' + username}
target='_blank'
rel='noopener noreferrer'
>
<i className='fa fa-gitlab'/>{' ' + username}
</a>
</div>
);
if (!username || !gitlabURL) {
return null;
}
}

const style = {
return (
<div style={style.container}>
<a
href={`${gitlabURL}/${username}`}
target='_blank'
rel='noopener noreferrer'
>
<i className='fa fa-gitlab'/>{' ' + username}
</a>
</div>
);
};

const style: {container: CSSProperties} = {
container: {
margin: '5px 0',
},
};

export default UserAttribute;
1 change: 1 addition & 0 deletions webapp/src/types/gitlab_items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export interface GitlabItemsProps {
}

export interface TooltipData {
owner: string;
state: string;
type: string;
repo: string;
Expand Down
Loading