Sha256: 0856ea3619f705acae7aeb05a0eb52285d95c3c9b26b90f2d956efeb6f4b42e1

Contents?: true

Size: 1.86 KB

Versions: 14

Compression:

Stored size: 1.86 KB

Contents

import classic from "ember-classic-decorator";
import { computed } from "@ember/object";
import Component from "@ember/component";
import { buildHashString, clone } from "client-app/lib/utilities";
import Preload from "client-app/lib/preload";
import { htmlSafe } from "@ember/template";

@classic
export default class EnvTab extends Component {
  @computed("currentEnvPosition", "isEnvArray", "message.env")
  get currentEnv() {
    if (this.isEnvArray) {
      return this.message.env[this.currentEnvPosition];
    } else {
      return this.message.env;
    }
  }

  @computed("message.env")
  get isEnvArray() {
    return Array.isArray(this.message.env);
  }

  @computed("currentEnv", "expanded.[]", "isEnvArray", "message.env")
  get html() {
    if (!this.isEnvArray) {
      return htmlSafe(buildHashString(this.message.env));
    }

    const currentEnv = clone(this.currentEnv);
    const expandableKeys = Preload.get("env_expandable_keys") || [];

    for (const key of expandableKeys) {
      if (
        Object.prototype.hasOwnProperty.call(currentEnv, key) &&
        !Array.isArray(currentEnv[key])
      ) {
        const list = [currentEnv[key]];
        for (const env of this.message.env) {
          if (env[key] && !list.includes(env[key])) {
            list.push(env[key]);
          }
        }
        currentEnv[key] = list.length > 1 ? list : list[0];
      }
    }

    return htmlSafe(buildHashString(currentEnv, false, this.expanded || []));
  }

  click(e) {
    const elem = e.target;
    const dataKey = elem.dataset.key;
    const expandableKeys = Preload.get("env_expandable_keys") || [];

    if (
      expandableKeys.includes(dataKey) &&
      elem.classList.contains("expand-list")
    ) {
      e.preventDefault();
      if (this.expanded) {
        this.expanded.pushObject(dataKey);
      } else {
        this.set("expanded", [dataKey]);
      }
    }
  }
}

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
logster-2.20.0 client-app/app/components/env-tab.js
logster-2.19.1 client-app/app/components/env-tab.js
logster-2.19.0 client-app/app/components/env-tab.js
logster-2.18.1 client-app/app/components/env-tab.js
logster-2.18.0 client-app/app/components/env-tab.js
logster-2.17.1 client-app/app/components/env-tab.js
logster-2.17.0 client-app/app/components/env-tab.js
logster-2.16.0 client-app/app/components/env-tab.js
logster-2.15.0 client-app/app/components/env-tab.js
logster-2.14.0 client-app/app/components/env-tab.js
logster-2.13.1 client-app/app/components/env-tab.js
logster-2.13.0 client-app/app/components/env-tab.js
logster-2.12.2 client-app/app/components/env-tab.js
logster-2.12.1 client-app/app/components/env-tab.js