From 7316e8e63286c6d34abe2d02f46904bc13b143a6 Mon Sep 17 00:00:00 2001 From: Phillip Wang Date: Fri, 13 Oct 2017 16:29:46 -0700 Subject: [PATCH] Add ability to delete constraints and also add indicator on flags collections page to show which flags are enabled or disabled --- browser/flagr-ui/src/components/Flag.vue | 37 +++++++++++++++++++---- browser/flagr-ui/src/components/Flags.vue | 24 +++++++++++++-- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/browser/flagr-ui/src/components/Flag.vue b/browser/flagr-ui/src/components/Flag.vue index 15a7610a..a01a3e4a 100644 --- a/browser/flagr-ui/src/components/Flag.vue +++ b/browser/flagr-ui/src/components/Flag.vue @@ -20,7 +20,7 @@ + > {{ variant.key }} @@ -138,10 +138,20 @@

Constraints ({{segment.constraints.length}})

    -
  1. - {{ constraint.property }} - {{ operatorValueToLabelMap[constraint.operator] }} - {{ constraint.value }} +
  2. +
    + {{ constraint.property }} + {{ operatorValueToLabelMap[constraint.operator] }} + {{ constraint.value }} +
    +
    + + + +
@@ -387,7 +397,7 @@ export default { }) }, createConstraint (segment) { - const flagId = this.$route.params.flagId + const {flagId} = this.$route.params postJson(`${API_URL}/flags/${flagId}/segments/${segment.id}/constraints`, segment.newConstraint) .then(constraint => { segment.constraints.push(constraint) @@ -395,6 +405,21 @@ export default { this.$message('You created a new constraint') }) }, + deleteConstraint (segment, constraint) { + const {flagId} = this.$route.params + + if (!confirm('Are you sure you want to delete this constraint?')) { + return + } + + fetch( + `${API_URL}/flags/${flagId}/segments/${segment.id}/constraints/${constraint.id}`, + {method: 'delete'} + ).then(() => { + const index = segment.constraints.findIndex(constraint => constraint.id === constraint.id) + segment.constraints.splice(index, 1) + }) + }, createSegment () { const flagId = this.$route.params.flagId postJson(`${API_URL}/flags/${flagId}/segments`, this.newSegment) diff --git a/browser/flagr-ui/src/components/Flags.vue b/browser/flagr-ui/src/components/Flags.vue index 1f73baa4..8e0868b5 100644 --- a/browser/flagr-ui/src/components/Flags.vue +++ b/browser/flagr-ui/src/components/Flags.vue @@ -23,11 +23,18 @@ ({{ flags.length }})
    -
  • +
  • - {{ flag.id }} {{ flag.description }} +
    + {{ flag.id }} {{ flag.description }} +
    +
    + +
@@ -145,6 +152,7 @@ export default { } .flag-link { display: inline-block; + box-sizing: border-box; padding: 8px 12px; font-size: 1.1em; width: 100%; @@ -155,6 +163,16 @@ export default { color: white; } } + .flag-enabled-icon { + display: inline-block; + width: 10px; + height: 10px; + border-radius: 5px; + background-color: #ff4949; + &.enabled { + background-color: #13ce66; + } + } } } }