-
Notifications
You must be signed in to change notification settings - Fork 22
/
github.js
72 lines (61 loc) · 1.74 KB
/
github.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import githubAuth from '../../main/api/requestGithubToken';
import getRepos from '../../main/api/getRepos';
import importProjects from '../../main/api/importProjects';
import getIssuesForUser from '../../main/api/getIssuesForUser';
import { createAliasedAction } from 'electron-redux';
// Authenticate
export const AUTHENTICATE_GITHUB = 'AUTHENTICATE_GITHUB';
export const authenticateGithub = createAliasedAction(
AUTHENTICATE_GITHUB,
(username, password, twofa) => ({
type: AUTHENTICATE_GITHUB,
payload: githubAuth(username, password, twofa),
meta: {
username,
},
})
);
// Get repos
export const GET_GITHUB_REPOS = 'GET_GITHUB_REPOS';
export const TRACK_GITHUB_REPO = 'TRACK_GITHUB_REPO';
export const UNTRACK_GITHUB_REPO = 'UNTRACK_GITHUB_REPO';
export const getGithubRepos = createAliasedAction(
GET_GITHUB_REPOS,
(accessToken) => ({
type: GET_GITHUB_REPOS,
payload: getRepos(accessToken),
})
);
export function trackGithubRepo(id) {
return {
type: TRACK_GITHUB_REPO,
payload: {
id,
},
};
}
export function untrackGithubRepo(id) {
return {
type: UNTRACK_GITHUB_REPO,
payload: {
id,
},
};
}
// Import projects
export const IMPORT_GITHUB_PROJECTS = 'IMPORT_GITHUB_PROJECTS';
export const importGithubProjects = createAliasedAction(
IMPORT_GITHUB_PROJECTS,
(accessToken, repoFullName) => ({
type: IMPORT_GITHUB_PROJECTS,
payload: importProjects(accessToken, repoFullName),
})
);
// Get recent issues assigned to user
export const GET_GITHUB_ISSUES_ASSIGNED_TO_USER = 'GET_GITHUB_ISSUES_ASSIGNED_TO_USER';
export function getGithubIssuesAssignedToUser(accessToken) {
return {
type: GET_GITHUB_ISSUES_ASSIGNED_TO_USER,
payload: getIssuesForUser(accessToken),
};
}