open-nomad/ui/app/controllers/variables/variable.js
2023-04-10 15:36:59 +00:00

26 lines
723 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import Controller from '@ember/controller';
export default class VariablesVariableController extends Controller {
get breadcrumbs() {
let crumbs = [];
let id = decodeURI(this.params.id.split('@').slice(0, -1).join('@')); // remove namespace
let namespace = this.params.id.split('@').slice(-1)[0];
id.split('/').reduce((m, n) => {
crumbs.push({
label: n,
args:
m + n === id // If the last crumb, link to the var itself
? [`variables.variable`, `${m + n}@${namespace}`]
: [`variables.path`, m + n],
});
return m + n + '/';
}, []);
return crumbs;
}
}