-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from HubSpot/react
BaragonUI -> React
- Loading branch information
Showing
253 changed files
with
10,391 additions
and
2,954 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
BaragonService/src/main/resources/com/hubspot/baragon/service/views/index.mustache
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"presets": ["es2015"], | ||
"plugins": [ | ||
"transform-runtime", | ||
"transform-react-jsx", | ||
"transform-object-rest-spread", | ||
"transform-class-properties", | ||
"react-hot-loader/babel" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"parserOptions": { | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"react" | ||
], | ||
"extends": "hubspot/experimental", | ||
"globals": { | ||
"$": true, | ||
"jQuery": true, | ||
"_": true, | ||
"config": true, | ||
"app": true, | ||
"Promise": true | ||
}, | ||
"rules": { | ||
"id-length": [2, {"min": 3, "exceptions": ["_", "id", "ui", "s3"]}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node | ||
/dist | ||
/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { buildApiAction, buildJsonApiAction } from './base'; | ||
|
||
export const FetchTargetGroups = buildApiAction( | ||
'FETCH_TARGET_GROUPS', | ||
{url: '/albs/target-groups'} | ||
); | ||
|
||
export const FetchTargetGroup = buildApiAction( | ||
'FETCH_TARGET_GROUP', | ||
(groupName, renderNotFoundIf404) => ({ | ||
url: `/albs/target-groups/${groupName}`, | ||
renderNotFoundIf404 | ||
}), | ||
(groupName) => groupName | ||
); | ||
|
||
export const FetchTargetGroupTargets = buildApiAction( | ||
'FETCH_TARGET_GROUP_TARGETS', | ||
(groupName) => ({ | ||
url: `/albs/target-groups/${groupName}/targets` | ||
}), | ||
(groupName) => groupName | ||
); | ||
|
||
export const ModifyTargetGroup = buildJsonApiAction( | ||
'MODIFY_TARGET_GROUP', | ||
'POST', | ||
(groupName, body) => ({ | ||
body, | ||
url: `/albs/target-groups/${groupName}`, | ||
}), | ||
); | ||
|
||
export const FetchLoadBalancers = buildApiAction( | ||
'FETCH_APPLICATION_LOAD_BALANCERS', | ||
{url: '/albs/load-balancers'} | ||
); | ||
|
||
export const FetchLoadBalancer = buildApiAction( | ||
'FETCH_APPLICATION_LOAD_BALANCER', | ||
(loadBalancerName) => ({ | ||
url: `/albs/load-balancers/${loadBalancerName}` | ||
}), | ||
(loadBalancerName) => loadBalancerName | ||
); | ||
|
||
export const FetchLoadBalancerListeners = buildApiAction( | ||
'FETCH_APPLICATION_LOAD_BALANCER_LISTENERS', | ||
(loadBalancerName) => ({ | ||
url: `/albs/load-balancers/${loadBalancerName}/listeners` | ||
}), | ||
(loadBalancerName) => loadBalancerName | ||
); | ||
|
||
export const FetchListenerRules = buildApiAction( | ||
'FETCH_LISTENER_RULES', | ||
(listenerArn) => ({ | ||
url: `/albs/listeners/rules/${listenerArn}` | ||
}), | ||
(listenerArn) => listenerArn | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import fetch from 'isomorphic-fetch'; | ||
import Messenger from 'messenger'; | ||
|
||
/* | ||
This specifically doesn't use `buildApiAction` because it needs to make a | ||
impure change when the fetch resolves. In particular, it needs to store the key | ||
that was given in local storage if it worked. It also modifies `window.config` | ||
for the logged in / not logged in state. | ||
*/ | ||
|
||
export const TestAuthKey = (function TestAuthKey() { | ||
const ACTION = 'TEST_AUTH_KEY'; | ||
const STARTED = 'TEST_AUTH_KEY_STARTED'; | ||
const ERROR = 'TEST_AUTH_KEY_ERROR'; | ||
const SUCCESS = 'TEST_AUTH_KEY_SUCCESS'; | ||
const CLEAR = 'TEST_AUTH_KEY_CLEAR'; | ||
|
||
function clear() { | ||
return {type: CLEAR}; | ||
} | ||
|
||
function started() { | ||
return {type: STARTED}; | ||
} | ||
|
||
function error(err, apiResponse) { | ||
const action = { | ||
type: ERROR, | ||
error: err, | ||
statusCode: apiResponse, | ||
}; | ||
|
||
if (apiResponse === 502) { | ||
Messenger().info({ | ||
message: 'Baragon is deploying; your request could not be handled. Things should resolve in a few seconds, so hang tight!' | ||
}); | ||
} else if (apiResponse === 403) { | ||
Messenger().error('Not a valid key!'); | ||
} | ||
|
||
return action; | ||
} | ||
|
||
function success(authKey, statusCode) { | ||
localStorage.setItem('baragonAuthKey', authKey); | ||
config.allowEdit = true; | ||
|
||
return {type: SUCCESS, data: authKey, statusCode}; | ||
} | ||
|
||
function clearData() { | ||
return (dispatch) => dispatch(clear()); | ||
} | ||
|
||
function trigger(authKey) { | ||
return (dispatch) => { | ||
dispatch(started()); | ||
|
||
return fetch(`${config.apiRoot}/auth/key/verify?authkey=${authKey}`) | ||
.then(response => { | ||
if (response.status === 204) { | ||
return dispatch(success(authKey, response.status)); | ||
} else { | ||
return dispatch(error(response, response.status)); | ||
} | ||
}); | ||
}; | ||
} | ||
|
||
return { | ||
ACTION, | ||
STARTED, | ||
ERROR, | ||
SUCCESS, | ||
CLEAR, | ||
clear, | ||
started, | ||
error, | ||
success, | ||
clearData, | ||
trigger, | ||
}; | ||
})(); | ||
|
||
|
||
export const DisableAuthKey = (function DisableAuthKey() { | ||
const ACTION = 'DISABLE_AUTH_KEY'; | ||
|
||
function trigger() { | ||
return (dispatch) => { | ||
config.allowEdit = false; | ||
localStorage.removeItem('baragonAuthKey'); | ||
return dispatch({type: ACTION}); | ||
}; | ||
} | ||
|
||
return { | ||
ACTION, | ||
trigger, | ||
}; | ||
})(); |
Oops, something went wrong.