2023-03-14 13:18:55 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
2023-03-14 13:18:55 +00:00
|
|
|
*/
|
|
|
|
|
2020-06-17 09:25:54 +00:00
|
|
|
import { helper } from '@ember/component/helper';
|
|
|
|
import { get } from '@ember/object';
|
2020-09-01 18:13:11 +00:00
|
|
|
import { MANAGEMENT_ID } from 'consul-ui/models/policy';
|
2020-06-17 09:25:54 +00:00
|
|
|
|
|
|
|
export default helper(function policyGroup([items] /*, hash*/) {
|
|
|
|
return items.reduce(
|
2022-09-15 08:43:17 +00:00
|
|
|
function (prev, item) {
|
2020-06-17 09:25:54 +00:00
|
|
|
let group;
|
|
|
|
switch (true) {
|
|
|
|
case get(item, 'ID') === MANAGEMENT_ID:
|
|
|
|
group = 'management';
|
|
|
|
break;
|
|
|
|
case get(item, 'template') !== '':
|
|
|
|
group = 'identities';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
group = 'policies';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
prev[group].push(item);
|
|
|
|
return prev;
|
|
|
|
},
|
|
|
|
{
|
|
|
|
management: [],
|
|
|
|
identities: [],
|
|
|
|
policies: [],
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|