client-app/app/components/env-tab.js in logster-2.4.2 vs client-app/app/components/env-tab.js in logster-2.5.0
- old
+ new
@@ -2,44 +2,44 @@
import { computed } from "@ember/object";
import { buildHashString } from "client-app/lib/utilities";
import Preload from "client-app/lib/preload";
export default Component.extend({
- current: 1,
-
didUpdateAttrs() {
- this.setProperties({
- current: 1,
- expanded: null
- });
+ this.set("expanded", null);
},
+ currentEnv: computed("isEnvArray", "currentEnvPosition", function() {
+ if (this.isEnvArray) {
+ return this.message.env[this.currentEnvPosition];
+ } else {
+ return this.message.env;
+ }
+ }),
+
isEnvArray: computed("message.env", function() {
return Array.isArray(this.get("message.env"));
}),
- html: computed("isEnvArray", "current", "expanded.[]", function() {
- if (!this.get("isEnvArray")) {
+ html: computed("isEnvArray", "currentEnv", "expanded.[]", function() {
+ if (!this.isEnvArray) {
return buildHashString(this.get("message.env"));
} else {
- const currentEnv = Em.$.extend(
- {},
- this.get("message.env")[this.get("current") - 1]
- );
+ const currentEnv = Em.$.extend({}, this.currentEnv);
const expandableKeys = Preload.get("env_expandable_keys") || [];
expandableKeys.forEach(key => {
if (currentEnv.hasOwnProperty(key) && !Array.isArray(currentEnv[key])) {
const list = [currentEnv[key]];
- this.get("message.env").forEach(env => {
+ this.message.env.forEach(env => {
if (env[key] && list.indexOf(env[key]) === -1) {
list.push(env[key]);
}
});
currentEnv[key] = list.length > 1 ? list : list[0];
}
});
- return buildHashString(currentEnv, false, this.get("expanded") || []);
+ return buildHashString(currentEnv, false, this.expanded || []);
}
}),
click(e) {
const $elem = Em.$(e.target);
@@ -48,33 +48,13 @@
if (
expandableKeys.indexOf(dataKey) !== -1 &&
$elem.hasClass("expand-list")
) {
e.preventDefault();
- if (!this.get("expanded")) {
+ if (!this.expanded) {
this.set("expanded", [dataKey]);
} else {
- this.get("expanded").pushObject(dataKey);
+ this.expanded.pushObject(dataKey);
}
- }
- },
-
- disableBackButtons: computed("current", function() {
- return this.get("current") === 1;
- }),
-
- disableForwardButtons: computed("current", "message.env.length", function() {
- return this.get("current") === this.get("message.env.length");
- }),
-
- actions: {
- takeStep(dir) {
- const amount = dir === "back" ? -1 : 1;
- this.set("current", this.get("current") + amount);
- },
-
- bigJump(dir) {
- const newCurrent = dir === "back" ? 1 : this.get("message.env.length");
- this.set("current", newCurrent);
}
}
});