Skip to content
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
14 changes: 13 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
######################################
# Prepare yarn and go build in builder
######################################
FROM checkr/flagr-ci as builder
WORKDIR /go/src/github.com/checkr/flagr
ADD . .

# Build UI
# FLAGR_UI_POSSIBLE_ENTITY_TYPES is useful for limiting the choices of entity types
ARG FLAGR_UI_POSSIBLE_ENTITY_TYPES=null
ENV FLAGR_UI_POSSIBLE_ENTITY_TYPES ${FLAGR_UI_POSSIBLE_ENTITY_TYPES}
RUN cd ./browser/flagr-ui/ && yarn install && yarn run build
RUN make build

# Build Go server
RUN make build


######################################
# Copy from builder to alpine image
######################################
FROM alpine:3.6
RUN apk add --no-cache libc6-compat ca-certificates curl
WORKDIR /go/src/github.com/checkr/flagr
Expand Down
7 changes: 6 additions & 1 deletion browser/flagr-ui/config/prod.env.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
module.exports = {
NODE_ENV: '"production"',
API_URL: '"/api/v1"'
API_URL: '"/api/v1"',

// ',' separated string
// For example
// FLAGR_UI_POSSIBLE_ENTITY_TYPES=report_int_id,account_int_id
FLAGR_UI_POSSIBLE_ENTITY_TYPES: process.env.FLAGR_UI_POSSIBLE_ENTITY_TYPES
}
26 changes: 20 additions & 6 deletions browser/flagr-ui/src/components/Flag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
v-model="flag.entityType"
size="mini"
filterable
allow-create
:allow-create="allowCreateEntityType"
default-first-option
placeholder="<null>">
<el-option
Expand Down Expand Up @@ -551,6 +551,7 @@ export default {
dialogEditDistributionOpen: false,
dialogCreateSegmentOpen: false,
entityTypes: [],
allowCreateEntityType: true,
flag: {
createdBy: '',
dataRecordsEnabled: false,
Expand Down Expand Up @@ -774,16 +775,29 @@ export default {
this.flag = flag
this.loaded = true
}, handleErr.bind(this))

Axios.get(`${API_URL}/flags/entity_types`).then(response => {
let arr = response.data.map(key => {
this.fetchEntityTypes()
},
fetchEntityTypes () {
function prepareEntityTypes (entityTypes) {
let arr = entityTypes.map(key => {
let label = key === '' ? '<null>' : key
return {'label': label, 'value': key}
})
if (response.data.indexOf('') === -1) {
if (entityTypes.indexOf('') === -1) {
arr.unshift({label: '<null>', value: ''})
}
this.entityTypes = arr
return arr
}

if (process.env.FLAGR_UI_POSSIBLE_ENTITY_TYPES) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FLAGR_UI_POSSIBLE_ENTITY_TYPES

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit different, I have to use process.env.FLAGR_UI_POSSIBLE_ENTITY_TYPES here, and also it also needs to be registered in browser/flagr-ui/config. What the compiler does is to do a string interpolation by using the env variables.

let entityTypes = process.env.FLAGR_UI_POSSIBLE_ENTITY_TYPES.split(',')
this.entityTypes = prepareEntityTypes(entityTypes)
this.allowCreateEntityType = false
return
}

Axios.get(`${API_URL}/flags/entity_types`).then(response => {
this.entityTypes = prepareEntityTypes(response.data)
}, handleErr.bind(this))
}
},
Expand Down