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
|
|
|
*/
|
|
|
|
|
2021-11-05 17:46:41 +00:00
|
|
|
import { helper } from '@ember/component/helper';
|
|
|
|
|
|
|
|
export default helper(function serviceCardPermissions([params] /*, hash*/) {
|
|
|
|
if (params.Datacenter === '') {
|
|
|
|
return 'empty';
|
|
|
|
} else {
|
|
|
|
const hasPermissions = params.Intention.HasPermissions;
|
|
|
|
const allowed = params.Intention.Allowed;
|
|
|
|
const notExplicitlyDefined = params.Source === 'specific-intention' && !params.TransparentProxy;
|
|
|
|
|
|
|
|
switch (true) {
|
|
|
|
case hasPermissions:
|
|
|
|
return 'allow';
|
|
|
|
case !allowed && !hasPermissions:
|
|
|
|
return 'deny';
|
|
|
|
case allowed && notExplicitlyDefined:
|
|
|
|
return 'not-defined';
|
|
|
|
default:
|
|
|
|
return 'allow';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|