Skip to content

Commit

Permalink
Disallow rule create with no distributions; update imports (flipt-io#759
Browse files Browse the repository at this point in the history
)
  • Loading branch information
markphelps committed Mar 20, 2022
1 parent 549104c commit 8ca6e39
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
3 changes: 1 addition & 2 deletions ui/src/components/Flags/DebugConsole.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
</template>

<script>
import clone from "lodash/clone";
import isEmpty from "lodash/isEmpty";
import { clone, isEmpty } from "lodash";
import { v4 as uuidv4 } from "uuid";
import { Api } from "@/services/api";
Expand Down
4 changes: 1 addition & 3 deletions ui/src/components/Flags/Flag.vue
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,7 @@
</template>

<script>
import clone from "lodash/clone";
import cloneDeep from "lodash/cloneDeep";
import capitalize from "lodash/capitalize";
import { capitalize, clone, cloneDeep } from "lodash";
import { Api } from "@/services/api";
import notify from "@/mixins/notify";
Expand Down
25 changes: 17 additions & 8 deletions ui/src/components/Flags/Targeting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,16 @@
</template>

<script>
import clone from "lodash/clone";
import cloneDeep from "lodash/cloneDeep";
import capitalize from "lodash/capitalize";
import map from "lodash/map";
import find from "lodash/find";
import forEach from "lodash/forEach";
import {
capitalize,
clone,
cloneDeep,
find,
forEach,
isEmpty,
map,
} from "lodash";
import draggable from "vuedraggable";
import { Api } from "@/services/api";
Expand Down Expand Up @@ -341,7 +345,10 @@ export default {
return this.flag.variants && this.flag.variants.length > 0;
},
canAddRule() {
return this.isPresent(this.newRule.segmentKey);
return (
this.isPresent(this.newRule.segmentKey) &&
!isEmpty(this.newRule.distributions)
);
},
},
mounted() {
Expand Down Expand Up @@ -523,7 +530,9 @@ export default {
},
ruleTypeChanged(event) {
let val = event.target.value;
if (val === "rollout") {
if (val === "") {
this.newRule.distributions = [];
} else if (val === "rollout") {
let n = this.flag.variants.length;
let percentages = this.computePercentages(n);
let distributions = [];
Expand Down
5 changes: 1 addition & 4 deletions ui/src/components/Segments/Segment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,7 @@
</template>

<script>
import clone from "lodash/clone";
import cloneDeep from "lodash/cloneDeep";
import capitalize from "lodash/capitalize";
import merge from "lodash/merge";
import { capitalize, clone, cloneDeep, merge } from "lodash";
import { Api } from "@/services/api";
import notify from "@/mixins/notify";
Expand Down

0 comments on commit 8ca6e39

Please sign in to comment.