Skip to content

Commit

Permalink
Merge pull request #210 from HubSpot/react
Browse files Browse the repository at this point in the history
BaragonUI -> React
  • Loading branch information
ssalinas authored Feb 28, 2017
2 parents b412c9b + b774826 commit 4fd6b87
Show file tree
Hide file tree
Showing 253 changed files with 10,391 additions and 2,954 deletions.
129 changes: 76 additions & 53 deletions BaragonService/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@
<groupId>com.hubspot</groupId>
<artifactId>BaragonData</artifactId>
</dependency>
<dependency>
<groupId>com.hubspot</groupId>
<artifactId>BaragonUI</artifactId>
<type>pom</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
Expand Down Expand Up @@ -200,59 +206,6 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<configuration>
<workingDirectory>../BaragonUI</workingDirectory>
</configuration>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v4.1.2</nodeVersion>
<npmVersion>2.14.16</npmVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-generated-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${project.build.directory}/generated-resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>build-docker-image</id>
Expand Down Expand Up @@ -305,5 +258,75 @@
</plugins>
</build>
</profile>
<profile>
<id>build-webui</id>
<activation>
<property>
<name>!skipBaragonWebUI</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-index.html-template</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/generated-resources/com/hubspot/baragon/service/views</outputDirectory>
<resources>
<resource>
<directory>../BaragonUI/app/assets/</directory>
<includes>
<include>index.mustache</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-ui</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/generated-resources/assets</outputDirectory>
<resources>
<resource>
<directory>../BaragonUI/dist</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-generated-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${project.build.directory}/generated-resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

This file was deleted.

10 changes: 10 additions & 0 deletions BaragonUI/.babelrc
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"
]
}
20 changes: 20 additions & 0 deletions BaragonUI/.eslintrc.json
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"]}]
}
}
3 changes: 3 additions & 0 deletions BaragonUI/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node
/dist
/target
61 changes: 61 additions & 0 deletions BaragonUI/app/actions/api/albs.es6
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
);
101 changes: 101 additions & 0 deletions BaragonUI/app/actions/api/auth.es6
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,
};
})();
Loading

0 comments on commit 4fd6b87

Please sign in to comment.