Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow rule create with no distributions; update imports #759

Merged
merged 1 commit into from
Mar 20, 2022
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: 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