@kui-shell/plugin-tekton
Version:
Visualizations for Tekton Pipelines
82 lines • 3.52 kB
JavaScript
;
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 core_1 = require("@kui-shell/core");
const plugin_kubeui_1 = require("@kui-shell/plugin-kubeui");
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* () {
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',
content: raw,
contentType: 'yaml'
}
];
const badges = ['Tekton'];
if (!run) {
if (jsons.find(_ => _.kind === 'PipelineRun' || _.kind === 'TaskRun')) {
badges.push({
title: 'Runnable',
css: plugin_kubeui_1.TrafficLight.Green
});
}
else {
badges.push({
title: 'Not Runnable',
css: plugin_kubeui_1.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 ? path_1.basename(filepath) : jsons[0].metadata.name,
packageName: filepath && path_1.dirname(filepath),
prettyType: run ? 'PipelineRun' : 'Pipeline',
duration,
badges,
presentation: core_1.Presentation.FixedSize,
content,
model: jsons,
modes: tektonModes.concat(zoomToFitButtons(controller, { visibleWhenShowing: flow_1.default.mode }))
};
});
//# sourceMappingURL=flow.js.map