open-nomad/ui/app/helpers/format-template-label.js
2023-04-10 15:36:59 +00:00

20 lines
498 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { helper } from '@ember/component/helper';
import { capitalize } from '@ember/string';
export default helper(function formatTemplateLabel([path]) {
// Removes the preceeding nomad/job-templates/default/
let label;
const delimiter = path.lastIndexOf('/');
if (delimiter !== -1) {
label = path.slice(delimiter + 1);
} else {
label = path;
}
return capitalize(label).split('-').join(' ');
});