mirror of https://github.com/hashicorp/consul
ui: Native-ize class based helpers (#9337)
* Install ember-decorators/observes * Remove filter-predicate * Nativize `env` and inject env service * Nativize all other class based helperspull/9344/head
parent
9262c25fdf
commit
3be03029f6
@ -1,6 +1,11 @@
|
||||
import { helper } from '@ember/component/helper';
|
||||
import { env } from 'consul-ui/env';
|
||||
export default helper(function([name, def = ''], hash) {
|
||||
const val = env(name);
|
||||
return val != null ? val : def;
|
||||
});
|
||||
import Helper from '@ember/component/helper';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default class EnvHelper extends Helper {
|
||||
@service('env') env;
|
||||
|
||||
compute([name, def = ''], hash) {
|
||||
const val = this.env.var(name);
|
||||
return val != null ? val : def;
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
import Helper from '@ember/component/helper';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default Helper.extend({
|
||||
filter: service('filter'),
|
||||
compute([type, filters], hash) {
|
||||
return this.filter.predicate(type)(filters);
|
||||
},
|
||||
});
|
@ -1,9 +1,10 @@
|
||||
import Helper from '@ember/component/helper';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default Helper.extend({
|
||||
state: service('state'),
|
||||
export default class StateMatchesHelper extends Helper {
|
||||
@service('state') state;
|
||||
|
||||
compute([state, values], hash) {
|
||||
return this.state.matches(state, values);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
import Helper from '@ember/component/helper';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default Helper.extend({
|
||||
ticker: service('ticker'),
|
||||
compute: function([props, id], hash) {
|
||||
export default class TweenToHelper extends Helper {
|
||||
@service('ticker') ticker;
|
||||
|
||||
compute([props, id], hash) {
|
||||
return this.ticker.tweenTo(props, id);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
import Helper from '@ember/component/helper';
|
||||
import { inject as service } from '@ember/service';
|
||||
|
||||
export default Helper.extend({
|
||||
encoder: service('encoder'),
|
||||
export default class UriHelper extends Helper {
|
||||
@service('encoder') encoder;
|
||||
|
||||
compute(params, hash) {
|
||||
return this.encoder.uriJoin(params);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue