open-consul/ui-v2/app/helpers/policy/datacenters.js
John Cowen 52a62f2b8d UI: New ACLs (#4789)
UI to accompany the new ACLs APIs
2018-10-19 08:45:05 -07:00

17 lines
497 B
JavaScript

import { helper } from '@ember/component/helper';
import { get } from '@ember/object';
/**
* Datacenters can be an array of datacenters.
* Anything that isn't an array means 'All', even an empty array.
*/
export function datacenters(params, hash = {}) {
const datacenters = get(params[0], 'Datacenters');
if (!Array.isArray(datacenters) || datacenters.length === 0) {
return [hash['global'] || 'All'];
}
return get(params[0], 'Datacenters');
}
export default helper(datacenters);