UNPKG

@kui-shell/plugin-tekton

Version:
80 lines 3.31 kB
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()); }); }; import Debug from 'debug'; import { basename, dirname } from 'path'; import { Presentation } from '@kui-shell/core'; import { TrafficLight } from '@kui-shell/plugin-kubeui'; import runMode from '../model/modes/run'; import flowMode from '../model/modes/flow'; import tekton2graph from '../lib/tekton2graph'; const debug = Debug('plugins/tekton/view/flow'); export default (tab, jsons, run, raw = '', filepath) => __awaiter(void 0, void 0, void 0, function* () { const [graph] = yield Promise.all([ tekton2graph(jsons, filepath, run) ]); debug('graph', graph); const { graph2doms, injectCSS, zoomToFitButtons } = yield import('@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 = [ flowMode, runMode, { mode: 'Raw', content: raw, contentType: 'yaml' } ]; const badges = ['Tekton']; if (!run) { if (jsons.find(_ => _.kind === 'PipelineRun' || _.kind === 'TaskRun')) { badges.push({ title: 'Runnable', css: TrafficLight.Green }); } else { badges.push({ title: 'Not Runnable', css: TrafficLight.Yellow }); } } 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 ? basename(filepath) : jsons[0].metadata.name, packageName: filepath && dirname(filepath), prettyType: run ? 'PipelineRun' : 'Pipeline', duration, badges, presentation: Presentation.FixedSize, content, model: jsons, modes: tektonModes.concat(zoomToFitButtons(controller, { visibleWhenShowing: flowMode.mode })) }; }); //# sourceMappingURL=flow.js.map