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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | 43x 43x 43x 97x 97x 97x 1x 97x 97x 97x 43x 43x 97x 583x 43x 43x 43x 43x 43x 43x 43x 43x | /* * Copyright 2021 Harness Inc. All rights reserved. * Use of this source code is governed by the PolyForm Shield 1.0.0 license * that can be found in the licenses directory at the root of this repository, also available at * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt. */ import { StringKeys, useStrings } from 'framework/strings' import SideNav from '@cf/components/SideNav/SideNav' import type { SidebarContext } from '@common/navigation/SidebarProvider' export type OperatorOption = { label: string value: string single?: boolean } export type IsSingleValued = (operatorValue: string) => boolean export const useOperators = ( i18nFn: (key: StringKeys) => string, keyMapper: (key: string) => StringKeys = x => x as StringKeys, extraOperators: OperatorOption[] = [] ): [OperatorOption[], IsSingleValued] => { const getString = i18nFn const base = [ { label: getString(keyMapper('startsWith')), value: 'starts_with', single: true }, { label: getString(keyMapper('endsWith')), value: 'ends_with', single: true }, { label: getString(keyMapper('contains')), value: 'contains', single: false }, { label: getString(keyMapper('equal')), value: 'equal', single: true }, { label: getString(keyMapper('equalSensitive')), value: 'equal_sensitive', single: true }, { label: getString(keyMapper('in')), value: 'in', single: false } ] const extra = extraOperators.map(({ label, value, single = false }) => { return { label: getString(keyMapper(label)), value, single } }) const opList = base.concat(extra) const isSingleValued: IsSingleValued = (operatorValue: string) => opList.find(op => op.value === operatorValue)?.single || false return [opList, isSingleValued] } const operatorStringMap: Record<string, StringKeys> = { and: 'cf.clause.operators.and', in: 'cf.clause.operators.in', startsWith: 'cf.clause.operators.startsWith', endsWith: 'cf.clause.operators.endsWith', match: 'cf.clause.operators.match', contains: 'cf.clause.operators.contains', equal: 'cf.clause.operators.equal', equalSensitive: 'cf.clause.operators.equalSensitive', matchSegment: 'cf.clause.operators.matchSegment' } export const useOperatorsFromYaml = (extraOperators: OperatorOption[] = []): [OperatorOption[], IsSingleValued] => { const { getString } = useStrings() return useOperators(getString, key => operatorStringMap[key], extraOperators) } export const extraOperatorReference: Record<string, Record<string, OperatorOption>> = { customRules: { matchSegment: { label: 'matchSegment', value: 'segmentMatch', single: false } } } export const extraOperators: Record<string, OperatorOption[]> = Object.entries(extraOperatorReference).reduce( (acc: Record<string, OperatorOption[]>, [key, value]: [string, Record<string, OperatorOption>]) => { acc[key] = Object.values(value) return acc }, {} as Record<string, OperatorOption[]> ) export const CFVariationColors = [ '#4065A0', '#65DEF2', '#E3B14F', '#42AB45', '#D9DAE5', '#00ADE4', '#f78383', '#e59c0b', '#7c8d9f', '#8c78ed', '#ff8f3f', '#ed61b5' ] export const CFSideNavProps: SidebarContext = { navComponent: SideNav, title: 'Feature Flags', icon: 'cf-main' } export const DEFAULT_FLAG_GIT_REPO_PATH = '/flags.yaml' export const PERCENTAGE_ROLLOUT_VALUE = 'Percentage Rollout' |