All files / app/assets/javascripts/feature_flags/components strategy_parameters.vue

100% Statements 10/10
100% Branches 4/4
100% Functions 3/3
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55  6x               6x 6x 6x 6x 6x   6x                                 30x         6x               153x                  
<script>
import {
  ROLLOUT_STRATEGY_ALL_USERS,
  ROLLOUT_STRATEGY_FLEXIBLE_ROLLOUT,
  ROLLOUT_STRATEGY_PERCENT_ROLLOUT,
  ROLLOUT_STRATEGY_USER_ID,
  ROLLOUT_STRATEGY_GITLAB_USER_LIST,
} from '../constants';
 
import Default from './strategies/default.vue';
import FlexibleRollout from './strategies/flexible_rollout.vue';
import GitlabUserList from './strategies/gitlab_user_list.vue';
import PercentRollout from './strategies/percent_rollout.vue';
import UsersWithId from './strategies/users_with_id.vue';
 
const STRATEGIES = Object.freeze({
  [ROLLOUT_STRATEGY_ALL_USERS]: Default,
  [ROLLOUT_STRATEGY_FLEXIBLE_ROLLOUT]: FlexibleRollout,
  [ROLLOUT_STRATEGY_PERCENT_ROLLOUT]: PercentRollout,
  [ROLLOUT_STRATEGY_USER_ID]: UsersWithId,
  [ROLLOUT_STRATEGY_GITLAB_USER_LIST]: GitlabUserList,
});
 
export default {
  props: {
    strategy: {
      type: Object,
      required: true,
    },
  },
  computed: {
    strategyComponent() {
      return STRATEGIES[this.strategy?.name];
    },
  },
  methods: {
    onChange(value) {
      this.$emit('change', {
        ...this.strategy,
        ...value,
      });
    },
  },
};
</script>
<template>
  <component
    :is="strategyComponent"
    v-if="strategyComponent"
    :strategy="strategy"
    v-bind="$attrs"
    @change="onChange"
  />
</template>