How to use cozy-flags - 10 common examples

To help you get started, we’ve selected a few cozy-flags examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cozy / cozy.github.io / en / cozy-banks / src / ducks / balance / Balance.jsx View on Github external
return (
        
          
          
          
        
      )
    }

    const { triggers: triggersCollection } = this.props
    const accounts = this.getAllAccounts()
    const triggers = triggersCollection.data

    if (
      accounts.length === 0 ||
      flag('balance.no-account') ||
      flag('balance.account-loading')
    ) {
      let konnectorInfos = triggers
        .map(x => x.attributes)
        .filter(isBankTrigger)
        .map(t => ({
          konnector: get(t, 'message.konnector'),
          account: get(t, 'message.account'),
          status: get(t, 'current_state.status')
        }))

      if (flag('balance.account-loading')) {
        // eslint-disable-next-line no-console
        console.log('konnectorInfos', konnectorInfos)

        if (konnectorInfos.length === 0) {
github cozy / cozy.github.io / en / cozy-banks / src / ducks / groups / helpers.js View on Github external
virtualReimbursements: group => {
    const balance = getGroupBalance(group)
    if (flag('demo') || flag('balance.reimbursements-top-position')) {
      // Must be first if we have reimbursements waiting
      return balance > 0 ? -1 : 2
    } else {
      return 2
    }
  }
}
github cozy / cozy.github.io / en / cozy-banks / src / targets / services / onOperationOrBillCreate.js View on Github external
const setFlagsFromSettings = settings => {
  // The flag is needed to use local model when getting a transaction category ID
  flag('local-model-override', settings.community.localModelOverride.enabled)

  flag(
    'late-health-reimbursement-limit',
    settings.notifications.lateHealthReimbursement.value
  )
}
github cozy / cozy.github.io / en / cozy-banks / src / main.jsx View on Github external
const root = document.querySelector('[role=application]')
  const data = root.dataset
  lang =
    __TARGET__ === 'mobile' && navigator && navigator.language
      ? navigator.language.slice(0, 2)
      : data.cozyLocale || 'en'

  setupD3Locale(lang)

  history = setupHistory()

  client = await getClient(persistedState)
  store = configureStore(client, persistedState)
  client.registerPlugin(CleanupStoreClientPlugin, { store })
  client.registerPlugin(PinPlugin)
  client.registerPlugin(flag.plugin)
  client.registerPlugin(StartupChecksPlugin, {
    launchTriggers: [
      {
        slug: 'banks',
        name: 'autogroups',
        type: '@event',
        policy: 'never-executed'
      }
    ],

    // Delay startup checks to lessen the load at page startup
    delay: 5000
  })

  client.setStore(store)
github cozy / cozy.github.io / en / cozy-banks / src / utils / flag.js View on Github external
/** Reset flags, keeping only those set to a truthy value */
const garbageCollectFlags = () => {
  const trueFlags = flag
    .list()
    .map(name => [name, flag(name)])
    .filter(x => x[1])
  flag.reset()
  for (const [flagName, flagValue] of trueFlags) {
    flag(flagName, flagValue)
  }
}

garbageCollectFlags()

if (__DEVELOPMENT__ && flag('switcher') === null) {
  flag('switcher', true)
}

const demoFqdns = [
  'stephaniedurand.cozy.rocks',
  'isabelledurand.cozy.rocks',
  'genevievedurand.cozy.rocks',
  'isabelledurand.mycozy.cloud'
]

const locationMatchesFqdn = (location, fqdn) => {
  const splitted = fqdn.split('.')
  const slug = splitted[0]
  const domain = splitted.slice(1).join('.')
  const rx = new RegExp(slug + '.*' + domain.replace('.', '\\.'))
  return rx.exec(location)
github cozy / cozy.github.io / en / cozy-banks / src / ducks / account / helpers.spec.js View on Github external
it('should contain a others expenses virtual account', () => {
    flag.mockReturnValue(true)
    const virtualAccounts = buildVirtualAccounts(mockTransactions)
    const othersExpenseAccount = virtualAccounts.find(
      a => a._id === 'others_reimbursements'
    )
    expect(othersExpenseAccount).toBeDefined()
  })
github cozy / cozy.github.io / en / cozy-banks / src / ducks / balance / BalanceHeader.jsx View on Github external
transactions
}) => {
  const { t } = useI18n()
  const titlePaddedClass = isMobile ? 'u-p-0' : 'u-pb-0'
  const subtitle = subtitleParams
    ? t('BalanceHistory.checked_accounts', subtitleParams)
    : t('BalanceHistory.all_accounts')

  return (
    <header>
      {isMobile &amp;&amp; (
        
          {t('Balance.title')}
        
      )}
      {flag('banks.search') ?  : null}
      
      {accounts &amp;&amp; (
        
          
        
      )}
      
    </header>
github cozy / cozy.github.io / en / cozy-banks / src / ducks / transactions / TransactionPageErrors / TransactionPageErrors.jsx View on Github external
export const TransactionPageErrors = props =&gt; {
  const errors = getTransactionPageErrors(props)
  const count = errors.length
  const Wrapper = count &gt; 1 ? Carrousel : React.Fragment
  const wrapperProps =
    count &gt; 1
      ? {
          className: 'u-bg-chablis'
        }
      : null

  if (flag('demo')) {
    return null
  }

  return (
    
      {errors.map((error, i) =&gt; {
        const Component = TransactionPageErrors.errorTypeToComponent[error.type]
        if (!Component) {
          throw new Error(`No component available for error ${error.type}`)
        }
        return (
github cozy / cozy.github.io / en / cozy-banks / src / ducks / transactions / TransactionRow.jsx View on Github external
isExtraLarge,
      showCategoryChoice,
      filteringOnAccount,
      onRef,
      showRecurrence
    } = this.props

    const categoryId = getCategoryId(transaction)
    const categoryName = getCategoryName(categoryId)
    const categoryTitle = t(`Data.subcategories.${categoryName}`)

    const account = transaction.account.data
    const recurrence = transaction.recurrence
      ? transaction.recurrence.data
      : null
    const trRest = flag('show-transactions-ids') ? { id: transaction._id } : {}

    const applicationDate = getApplicationDate(transaction)
    return (
      
        
          
            <img title="{categoryTitle}">
              
            
            
              
                
                {!filteringOnAccount &amp;&amp; }
github cozy / cozy.github.io / en / cozy-banks / src / ducks / groups / helpers.js View on Github external
export const getGroupLabel = (group, t) => {
  if (group.virtual) {
    return (
      t(`Data.accountTypes.${group.label}`, { _: 'other' }) +
      (flag('debug-groups') ? ' (virtual)' : '')
    )
  } else if (isAutoGroup(group) && !isFormerAutoGroup(group)) {
    return (
      t(`Data.accountTypes.${group.accountType}`) +
      (flag('debug-groups') ? ' (auto)' : '')
    )
  } else {
    return group.label
  }
}

cozy-flags

Flag library used in Cozy

MIT
Latest version published 2 months ago

Package Health Score

73 / 100
Full package analysis