Sha256: 2079fc38c7191c5b927a3e6a4277d3796f9d5dc3bb17789b12556106d7a8063f

Contents?: true

Size: 1.8 KB

Versions: 2

Compression:

Stored size: 1.8 KB

Contents

import Component from "@ember/component";
import { computed } from "@ember/object";
import { buildHashString } from "client-app/lib/utilities";
import Preload from "client-app/lib/preload";

export default Component.extend({
  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", "currentEnv", "expanded.[]", function() {
    if (!this.isEnvArray) {
      return buildHashString(this.get("message.env"));
    } else {
      const expandableKeys = Preload.get("env_expandable_keys") || [];
      const expandedLists = {};
      expandableKeys.forEach(key => {
        if (
          Object.prototype.hasOwnProperty.call(this.currentEnv, key) &&
          !Array.isArray(this.currentEnv[key])
        ) {
          const list = [this.currentEnv[key]];
          this.message.env.forEach(env => {
            if (env[key] && list.indexOf(env[key]) === -1) {
              list.push(env[key]);
            }
          });
          expandedLists[key] = list;
        }
      });
      return buildHashString(
        this.currentEnv,
        false,
        this.expanded,
        expandedLists
      );
    }
  }),

  click(e) {
    const elem = e.target;
    const dataKey = elem.dataset.key;
    const expandableKeys = Preload.get("env_expandable_keys") || [];
    if (
      expandableKeys.indexOf(dataKey) !== -1 &&
      elem.classList.contains("expand-list")
    ) {
      e.preventDefault();
      if (!this.expanded) {
        this.set("expanded", [dataKey]);
      } else {
        this.expanded.pushObject(dataKey);
      }
    }
  }
});

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
logster-2.6.1 client-app/app/components/env-tab.js
logster-2.6.0 client-app/app/components/env-tab.js