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
|
|
|
*/
|
|
|
|
|
2018-10-19 15:17:02 +00:00
|
|
|
import { helper } from '@ember/component/helper';
|
|
|
|
import { get } from '@ember/object';
|
|
|
|
|
2022-09-15 08:43:17 +00:00
|
|
|
const _isLegacy = function (token) {
|
2018-11-06 18:08:10 +00:00
|
|
|
// Empty Rules take priority over a Legacy: true
|
|
|
|
// in order to make this decision
|
2018-11-02 14:44:36 +00:00
|
|
|
const rules = get(token, 'Rules');
|
2018-11-06 18:08:10 +00:00
|
|
|
if (rules != null) {
|
|
|
|
return rules.trim() !== '';
|
|
|
|
}
|
|
|
|
const legacy = get(token, 'Legacy');
|
|
|
|
if (typeof legacy !== 'undefined') {
|
|
|
|
return legacy;
|
|
|
|
}
|
|
|
|
return false;
|
2018-11-02 14:44:36 +00:00
|
|
|
};
|
2018-10-19 15:17:02 +00:00
|
|
|
export function isLegacy(params, hash) {
|
|
|
|
const token = params[0];
|
2018-11-02 14:44:36 +00:00
|
|
|
// is array like (RecordManager isn't an array)
|
|
|
|
if (typeof token.length !== 'undefined') {
|
2022-09-15 08:43:17 +00:00
|
|
|
return token.find(function (item) {
|
2018-11-02 14:44:36 +00:00
|
|
|
return _isLegacy(item);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return _isLegacy(token);
|
2018-10-19 15:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default helper(isLegacy);
|