github.com/outbrain/consul@v1.4.5/ui-v2/app/helpers/token/is-legacy.js (about)

     1  import { helper } from '@ember/component/helper';
     2  import { get } from '@ember/object';
     3  
     4  const _isLegacy = function(token) {
     5    // Empty Rules take priority over a Legacy: true
     6    // in order to make this decision
     7    const rules = get(token, 'Rules');
     8    if (rules != null) {
     9      return rules.trim() !== '';
    10    }
    11    const legacy = get(token, 'Legacy');
    12    if (typeof legacy !== 'undefined') {
    13      return legacy;
    14    }
    15    return false;
    16  };
    17  export function isLegacy(params, hash) {
    18    const token = params[0];
    19    // is array like (RecordManager isn't an array)
    20    if (typeof token.length !== 'undefined') {
    21      return token.find(function(item) {
    22        return _isLegacy(item);
    23      });
    24    }
    25    return _isLegacy(token);
    26  }
    27  
    28  export default helper(isLegacy);