-
-
Notifications
You must be signed in to change notification settings - Fork 4k
/
release.tsx
72 lines (65 loc) · 2.38 KB
/
release.tsx
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 * as Sentry from '@sentry/react';
import ReleaseActions from 'app/actions/releaseActions';
import {Client} from 'app/api';
import ReleaseStore, {getReleaseStoreKey} from 'app/stores/releaseStore';
import {Deploy, Release} from 'app/types';
type ParamsGet = {
orgSlug: string;
projectSlug: string;
releaseVersion: string;
};
export function getProjectRelease(api: Client, params: ParamsGet) {
const {orgSlug, projectSlug, releaseVersion} = params;
const path = `/projects/${orgSlug}/${projectSlug}/releases/${encodeURIComponent(
releaseVersion
)}/`;
// HACK(leedongwei): Actions fired by the ActionCreators are queued to
// the back of the event loop, allowing another getRelease for the same
// release to be fired before the loading state is updated in store.
// This hack short-circuits that and update the state immediately.
ReleaseStore.state.releaseLoading[
getReleaseStoreKey(projectSlug, releaseVersion)
] = true;
ReleaseActions.loadRelease(orgSlug, projectSlug, releaseVersion);
return api
.requestPromise(path, {
method: 'GET',
})
.then((res: Release) => {
ReleaseActions.loadReleaseSuccess(projectSlug, releaseVersion, res);
})
.catch(err => {
ReleaseActions.loadReleaseError(projectSlug, releaseVersion, err);
Sentry.withScope(scope => {
scope.setLevel(Sentry.Severity.Warning);
scope.setFingerprint(['getRelease-action-creator']);
Sentry.captureException(err);
});
});
}
export function getReleaseDeploys(api: Client, params: ParamsGet) {
const {orgSlug, projectSlug, releaseVersion} = params;
const path = `/organizations/${orgSlug}/releases/${encodeURIComponent(
releaseVersion
)}/deploys/`;
// HACK(leedongwei): Same as above
ReleaseStore.state.deploysLoading[
getReleaseStoreKey(projectSlug, releaseVersion)
] = true;
ReleaseActions.loadDeploys(orgSlug, projectSlug, releaseVersion);
return api
.requestPromise(path, {
method: 'GET',
})
.then((res: Deploy[]) => {
ReleaseActions.loadDeploysSuccess(projectSlug, releaseVersion, res);
})
.catch(err => {
ReleaseActions.loadDeploysError(projectSlug, releaseVersion, err);
Sentry.withScope(scope => {
scope.setLevel(Sentry.Severity.Warning);
scope.setFingerprint(['getReleaseDeploys-action-creator']);
Sentry.captureException(err);
});
});
}