2018-09-25 16:28:26 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import { alias } from '@ember/object/computed';
|
|
|
|
import Component from '@ember/component';
|
|
|
|
import { computed } from '@ember/object';
|
2018-08-16 17:48:24 +00:00
|
|
|
|
|
|
|
export default Component.extend({
|
2018-09-25 16:28:26 +00:00
|
|
|
namespaceService: service('namespace'),
|
|
|
|
currentNamespace: alias('namespaceService.path'),
|
2018-08-16 17:48:24 +00:00
|
|
|
|
|
|
|
tagName: '',
|
|
|
|
//public api
|
|
|
|
targetNamespace: null,
|
|
|
|
showLastSegment: false,
|
|
|
|
|
|
|
|
normalizedNamespace: computed('targetNamespace', function() {
|
|
|
|
let ns = this.get('targetNamespace');
|
2020-05-01 17:06:32 +00:00
|
|
|
return (ns || '').replace(/\.+/g, '/').replace(/☃/g, '.');
|
2018-08-16 17:48:24 +00:00
|
|
|
}),
|
|
|
|
|
|
|
|
namespaceDisplay: computed('normalizedNamespace', 'showLastSegment', function() {
|
|
|
|
let ns = this.get('normalizedNamespace');
|
|
|
|
let showLastSegment = this.get('showLastSegment');
|
|
|
|
let parts = ns.split('/');
|
|
|
|
if (ns === '') {
|
|
|
|
return 'root';
|
|
|
|
}
|
|
|
|
return showLastSegment ? parts[parts.length - 1] : ns;
|
|
|
|
}),
|
|
|
|
|
|
|
|
isCurrentNamespace: computed('targetNamespace', 'currentNamespace', function() {
|
|
|
|
return this.get('currentNamespace') === this.get('targetNamespace');
|
|
|
|
}),
|
|
|
|
});
|