Skip to content

Commit e40ef15

Browse files
authored
Merge pull request #351 from mapbox/add-status-modal
Add status modal
2 parents 8e71c5e + 2074d37 commit e40ef15

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "osmcha-frontend",
3-
"version": "0.56.1",
3+
"version": "0.56.2",
44
"license": "ISC",
55
"engines": {
66
"node": ">=7.0"

src/config/constants.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export const overpassBase = '//overpass.maptime.in/api/interpreter';
66
export const osmBase = '//www.openstreetmap.org/api/0.6/';
77
export const mapboxAccessToken =
88
'pk.eyJ1Ijoib3BlbnN0cmVldG1hcCIsImEiOiJjam10OXpmc2YwMXI5M3BqeTRiMDBqMHVyIn0.LIcIDe3TZLSDdTWDoojzNg';
9+
export const statusUrl =
10+
'https://raw.githubusercontent.com/mapbox/osmcha-frontend/status/status.json';
911

1012
export const osmchaSocialTokenUrl = `${API_URL}/social-auth/`;
1113

src/network/status.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { statusUrl } from '../config/constants';
2+
import { handleErrors } from './aoi';
3+
4+
export function getStatus(input, type): Promise<*> {
5+
return fetch(`${statusUrl}`, {
6+
method: 'GET'
7+
})
8+
.then(handleErrors)
9+
.then(response => {
10+
return response.json();
11+
});
12+
}

src/store/auth_actions.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
fetchUserDetails,
1010
updateUserDetails
1111
} from '../network/auth';
12+
import { getStatus } from '../network/status';
1213
import { fetchChangeset } from '../network/changeset';
1314
import { fetchBlackList } from '../network/osmcha_blacklist';
1415
import { setItem, removeItem } from '../utils/safe_storage';
@@ -87,6 +88,7 @@ export function* watchAuth(): any {
8788
const userDetails = fromJS(yield call(fetchUserDetails, token));
8889
const whitelist = userDetails.get('whitelists');
8990
const blacklist = fromJS(yield call(fetchBlackList, token));
91+
const status = fromJS(yield call(getStatus));
9092
yield put(action(WHITELIST.define, { whitelist }));
9193
yield put(action(BLACKLIST.define, { blacklist }));
9294
yield put(action(AUTH.userDetails, { userDetails }));
@@ -104,6 +106,17 @@ export function* watchAuth(): any {
104106
})
105107
);
106108
}
109+
// show status notification
110+
if (status.get('status') !== 'success') {
111+
yield put(
112+
modal({
113+
title: 'Status alert',
114+
description: status.get('message'),
115+
kind: status.get('status'),
116+
autoDismiss: 20
117+
})
118+
);
119+
}
107120

108121
yield take(AUTH.logout);
109122
delayBy = DELAY;

0 commit comments

Comments
 (0)