Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

Merge cadence #30

Merged
merged 5 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM node:8.17.0-jessie as builder

WORKDIR /usr/build
ENV NODE_ENV=production
ENV NPM_CONFIG_PRODUCTION=true

# Install app dependencies
COPY package*.json ./
Expand All @@ -16,7 +18,6 @@ RUN mkdir -p ./app/protobuf/src && mv protobuf/src ./app/protobuf
# Build final image
FROM node:8.17.0-jessie-slim
WORKDIR /usr/app
ENV NODE_ENV=production
COPY --from=builder ./usr/build/app ./
EXPOSE 8088
CMD [ "node", "server.js" ]
7 changes: 4 additions & 3 deletions .babelrc → babel.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
module.exports = {
"plugins": [
[
"module-resolver",
Expand All @@ -9,7 +9,8 @@
"~helpers": "./client/helpers"
}
}
]
],
["@babel/plugin-transform-regenerator"]
],
"presets": [
[
Expand All @@ -22,4 +23,4 @@
],
"@babel/preset-env"
]
}
};
86 changes: 69 additions & 17 deletions client/App.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,38 @@
<script>
import { version } from '../package.json';
import logo from './assets/logo.svg';
import { NotificationBar } from '~components';
import { NOTIFICATION_TIMEOUT, NOTIFICATION_TYPE_SUCCESS } from '~constants';
import { FeatureFlag, NotificationBar } from '~components';
import {
ENVIRONMENT_LIST,
NOTIFICATION_TIMEOUT,
NOTIFICATION_TYPE_SUCCESS,
} from '~constants';
import {
getEnvironment,
getEnvironmentList,
getEnvironmentLocation,
} from '~helpers';

export default {
components: {
NotificationBar,
'feature-flag': FeatureFlag,
'notification-bar': NotificationBar,
},
data() {
const { origin } = window.location;
const environmentList = ENVIRONMENT_LIST;

return {
environment: {
list: getEnvironmentList({
environmentList,
origin,
}),
value: getEnvironment({
environmentList,
origin,
}),
},
logo,
notification: {
message: '',
Expand Down Expand Up @@ -40,6 +63,19 @@ export default {
}
}
},
onEnvironmentSelectChange(environment) {
if (environment === this.environment.value) {
return;
}

const { pathname, search } = window.location;

window.location = getEnvironmentLocation({
environment,
pathname,
search,
});
},
onNotification({ message, type = NOTIFICATION_TYPE_SUCCESS }) {
this.notification.message = message;
this.notification.type = type;
Expand Down Expand Up @@ -71,7 +107,7 @@ export default {

<template>
<main @click="globalClick">
<NotificationBar
<notification-bar
:message="notification.message"
:onClose="onNotificationClose"
:show="notification.show"
Expand All @@ -82,28 +118,29 @@ export default {
<div v-html="logo"></div>
<span class="version">{{ version }}</span>
</a>

<feature-flag name="environment-select">
<v-select
class="environment-select"
:on-change="onEnvironmentSelectChange"
:options="environment.list"
:searchable="false"
:value="environment.value"
/>
</feature-flag>

<div class="namespace" v-if="$route.params.namespace">
<a
class="workflows"
:class="{
'router-link-active':
$route.path === `/namespaces/${$route.params.namespace}/workflows`,
$route.path ===
`/namespaces/${$route.params.namespace}/workflows`,
}"
:href="`/namespaces/${$route.params.namespace}/workflows`"
>
{{ $route.params.namespace }}
</a>
<a
class="config"
:class="{
'router-link-active':
$route.path === `/namespaces/${$route.params.namespace}/config`,
}"
:href="`/namespaces/${$route.params.namespace}/config`"
></a>
</div>
<div v-if="$route.name === 'workflow-list'">
Workflows
</div>
<div class="detail-view workflow-id" v-if="$route.params.workflowId">
<span>{{ $route.params.workflowId }}</span>
Expand Down Expand Up @@ -206,6 +243,21 @@ header.top-bar
bottom: 0;
}

.environment-select {
.dropdown-toggle {
border-color: transparent;
}

.open-indicator:before {
border-color: uber-blue;
}

.selected-tag {
color: white;
font-weight: bold;
}
}

body, main
height 100%
main
Expand Down Expand Up @@ -238,7 +290,7 @@ area-loader, section.loading
height size
border-radius size
left "calc(50% - %s)" % (size/2)
top "calc(25% - %s)" % (size/2)
top 300px;
border 3px solid uber-blue
border-bottom-color transparent
animation spin 800ms linear infinite
Expand Down
50 changes: 50 additions & 0 deletions client/components/button-fill.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<template>
<component
class="button-fill"
:href="href"
:is="tag"
:to="to"
@click="onClick"
>
{{ label }}
</component>
</template>

<script>
export default {
name: 'button-fill',
props: {
href: {
type: String,
},
label: {
type: String,
},
tag: {
type: String,
default: 'button',
},
to: {
type: Object,
},
},
methods: {
onClick(...args) {
this.$emit('click', ...args);
},
},
};
</script>

<style lang="stylus">
.button-fill {
cursor: pointer;
display: inline-block;
padding: 13px 21px;
transition: all 400ms ease;
font-weight: 600;
color: #fff !important;
background-color: #11939a;
white-space: nowrap;
}
</style>
20 changes: 20 additions & 0 deletions client/components/error-message.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div class="error-message-container" v-if="error">
<span class="error">
{{ error }}
</span>
</div>
</template>

<script>
export default {
name: 'error-message',
props: ['error'],
};
</script>

<style lang="stylus">
.error-message-container {
padding: 70px 0;
}
</style>
10 changes: 10 additions & 0 deletions client/components/feature-flag/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const isFlagEnabled = ({ flagHash = {}, name = '' }) =>
flagHash[name] || false;

export const mapFlagsToHash = (flagArray = []) => {
return flagArray.reduce((accumulator, { key = '', value = false }) => {
accumulator[key] = value;

return accumulator;
}, {});
};
38 changes: 38 additions & 0 deletions client/components/feature-flag/helpers.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { isFlagEnabled, mapFlagsToHash } from './helpers';

describe('feature-flag helpers', () => {
describe('isFlagEnabled', () => {
it('should return false when passed name = "workflow-terminate" and flagHash = {}.', () => {
const name = 'workflow-terminate';
const flagHash = {};
const output = isFlagEnabled({ flagHash, name });

expect(output).toEqual(false);
});

it('should return true when passed name = "workflow-terminate" and flagHash = { "workflow-terminate": true }.', () => {
const name = 'workflow-terminate';
const flagHash = { 'workflow-terminate': true };
const output = isFlagEnabled({ flagHash, name });

expect(output).toEqual(true);
});

it('should return false when passed name = "workflow-terminate" and flagHash = { "workflow-terminate": false }.', () => {
const name = 'workflow-terminate';
const flagHash = { 'workflow-terminate': false };
const output = isFlagEnabled({ flagHash, name });

expect(output).toEqual(false);
});
});

describe('mapFlagsToHash', () => {
it('should return { "workflow-terminate": true } when passed flagArray = [{ key: "workflow-terminate", value: true }].', () => {
const flagArray = [{ key: 'workflow-terminate', value: true }];
const output = mapFlagsToHash(flagArray);

expect(output).toEqual({ 'workflow-terminate': true });
});
});
});
25 changes: 25 additions & 0 deletions client/components/feature-flag/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<template>
<div class="feature-flag" v-if="isFlagEnabled">
<slot></slot>
</div>
</template>

<script>
import featureFlags from '../../feature-flags.json';
import { isFlagEnabled, mapFlagsToHash } from './helpers';

export default {
name: 'feature-flag',
props: ['name'],
computed: {
flagHash() {
return mapFlagsToHash(featureFlags);
},
isFlagEnabled() {
const { flagHash, name } = this;

return isFlagEnabled({ flagHash, name });
},
},
};
</script>
22 changes: 22 additions & 0 deletions client/components/flex-grid-item.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<div class="flex-grid-item" :style="{ maxWidth: width }">
<slot></slot>
</div>
</template>

<script>
export default {
name: 'flex-grid-item',
props: ['width'],
};
</script>

<style lang="stylus">
.flex-grid-item {
flex-grow: 1;
margin-right: 5px;
&:last-child {
margin-right: 0;
}
}
</style>
13 changes: 13 additions & 0 deletions client/components/flex-grid.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>
<div class="flex-grid">
<slot></slot>
</div>
</template>

<style lang="stylus">
.flex-grid {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
</style>
9 changes: 9 additions & 0 deletions client/components/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
export { default as BarLoader } from './bar-loader';
export { default as ButtonFill } from './button-fill';
export { default as Copy } from './copy';
export { default as DataViewer } from './data-viewer';
export { default as DetailList } from './detail-list';
export { default as DateRangePicker } from './date-range-picker';
export { default as NamespaceNavigation } from './namespace-navigation';
export { default as ErrorMessage } from './error-message';
export { default as FeatureFlag } from './feature-flag';
export { default as FlexGrid } from './flex-grid';
export { default as FlexGridItem } from './flex-grid-item';
export { default as LoadingMessage } from './loading-message';
export { default as LoadingSpinner } from './loading-spinner';
export { default as NavigationBar } from './navigation-bar';
export { default as NavigationLink } from './navigation-link';
export { default as NoResults } from './no-results';
export { default as NotificationBar } from './notification-bar';
export { default as TextInput } from './text-input';
Loading