UNPKG

kui-shell

Version:

This is the monorepo for Kui, the hybrid command-line/GUI electron-based Kubernetes tool

90 lines 3.72 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const debug_1 = require("debug"); const path_1 = require("path"); const ui_1 = require("@kui-shell/core/api/ui"); const run_1 = require("../model/modes/run"); const flow_1 = require("../model/modes/flow"); const tekton2graph_1 = require("../lib/tekton2graph"); const debug = debug_1.default('plugins/tekton/view/flow'); exports.default = (tab, jsons, run, raw, filepath) => __awaiter(void 0, void 0, void 0, function* () { if (!raw) { const { safeDump } = yield Promise.resolve().then(() => require('js-yaml')); raw = safeDump(jsons); } const [graph] = yield Promise.all([ tekton2graph_1.default(jsons, filepath, run) ]); debug('graph', graph); const { graph2doms, injectCSS, zoomToFitButtons } = yield Promise.resolve().then(() => require('@kui-shell/plugin-wskflow')); injectCSS(); const content = document.createElement('div'); content.classList.add('padding-content'); content.style.flex = '1'; content.style.display = 'flex'; const { controller } = yield graph2doms(tab, graph, content, graph.runs, { layoutOptions: { 'elk.separateConnectedComponents': false, 'elk.spacing.nodeNode': 10, 'elk.padding': '[top=7.5,left=5,bottom=7.5,right=5]', hierarchyHandling: 'INCLUDE_CHILDREN' } }); debug('content', content); const tektonModes = [ flow_1.default, run_1.default, { mode: 'Raw', leaveBottomStripeAlone: true, direct: { type: 'custom', isEntity: true, contentType: 'yaml', content: raw } } ]; const badges = ['Tekton']; if (!run) { if (jsons.find(_ => _.kind === 'PipelineRun' || _.kind === 'TaskRun')) { badges.push({ title: 'Runnable', css: 'green-background' }); } else { badges.push({ title: 'Not Runnable', css: 'yellow-background' }); } } const startTime = run && run.status && run.status.startTime && new Date(run.status.startTime); const endTime = run && run.status && run.status.completionTime && new Date(run.status.completionTime); const duration = startTime && endTime && endTime.getTime() - startTime.getTime(); return { type: 'custom', isEntity: true, isFromFlowCommand: true, name: filepath ? path_1.basename(filepath) : jsons[0].metadata.name, packageName: filepath && path_1.dirname(filepath), prettyType: run ? 'PipelineRun' : 'Pipeline', duration, badges, presentation: ui_1.default.Presentation.FixedSize, content, model: jsons, modes: tektonModes.concat(zoomToFitButtons(controller, { visibleWhenShowing: flow_1.default.mode })) }; }); //# sourceMappingURL=flow.js.map