@unito/integration-debugger
Version:
The Unito Integration Debugger
85 lines (84 loc) • 6.02 kB
JavaScript
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const chalk_1 = __importDefault(require("chalk"));
const gradient = __importStar(require("gradient-string"));
const configuration_1 = require("../resources/configuration");
const store_1 = require("../store");
const styles_1 = require("../styles");
const Header = () => {
const window = (0, store_1.useWindowState)();
const profile = (0, store_1.useProfileState)();
const configuration = (0, store_1.useConfigurationState)();
const integration = (0, store_1.useIntegrationState)();
const credential = (0, store_1.useCredentialState)();
const status = (0, store_1.useStatusState)();
const labels = {
[store_1.Window.debugger]: [chalk_1.default.whiteBright('d'), chalk_1.default.yellow('ebugger')].join(''),
[store_1.Window.process]: [chalk_1.default.yellow('pr'), chalk_1.default.whiteBright('0'), chalk_1.default.yellow('cess')].join(''),
[store_1.Window.config]: [chalk_1.default.yellow('conf'), chalk_1.default.whiteBright('i'), chalk_1.default.yellow('g')].join(''),
[store_1.Window.help]: [chalk_1.default.whiteBright('h'), chalk_1.default.yellow('elp')].join(''),
[store_1.Window.quit]: [chalk_1.default.whiteBright('q'), chalk_1.default.yellow('uit')].join(''),
};
const effectiveLabels = {
debugger: window.current === store_1.Window.debugger ? chalk_1.default.bgMagenta(labels[store_1.Window.debugger]) : labels[store_1.Window.debugger],
process: window.current === store_1.Window.process ? chalk_1.default.bgMagenta(labels[store_1.Window.process]) : labels[store_1.Window.process],
config: window.current === store_1.Window.config ? chalk_1.default.bgMagenta(labels[store_1.Window.config]) : labels[store_1.Window.config],
help: window.current === store_1.Window.help ? chalk_1.default.bgMagenta(labels[store_1.Window.help]) : labels[store_1.Window.help],
quit: window.current === store_1.Window.quit ? chalk_1.default.bgMagenta(labels[store_1.Window.quit]) : labels[store_1.Window.quit],
};
const environmentLabel = [chalk_1.default.cyanBright(configuration.current.environment), (0, styles_1.statusIcon)(status.environment)].join(' ');
const apiKeyLabel = profile.current
? [chalk_1.default.cyanBright(profile.current.email), (0, styles_1.statusIcon)(status.apiKey)].join(' ')
: configuration.apiKey && configuration.environment !== configuration_1.Environment.None
? [chalk_1.default.cyanBright('signing'), (0, styles_1.statusIcon)(status.apiKey)].join(' ')
: chalk_1.default.gray('signed off');
const integrationLabel = integration.current
? [chalk_1.default.cyanBright(integration.current.name), (0, styles_1.statusIcon)(status.integration)].join(' ')
: configuration.environment === configuration_1.Environment.None && configuration.integrationUrl
? [chalk_1.default.cyanBright('custom'), (0, styles_1.statusIcon)(status.integration)].join(' ')
: chalk_1.default.gray('no integration');
const credentialLabel = credential.current
? [chalk_1.default.cyanBright(credential.current.id), (0, styles_1.statusIcon)(status.credential)].join(' ')
: configuration.environment === configuration_1.Environment.None && configuration.credentialPayload
? [chalk_1.default.cyanBright('custom'), (0, styles_1.statusIcon)(status.credential)].join(' ')
: chalk_1.default.gray('no credential');
return ((0, jsx_runtime_1.jsxs)("layout", { top: 0, left: 0, width: "100%", height: 3, border: styles_1.paneBorder, style: styles_1.unfocusablePane, children: [[gradient.cristal('integration debugger'), process.env.APP_VERSION].filter(text => Boolean(text)).join(' '), chalk_1.default.gray(' |'), (0, jsx_runtime_1.jsx)("button", { label: effectiveLabels[store_1.Window.debugger] }), (0, jsx_runtime_1.jsx)("button", { label: effectiveLabels[store_1.Window.process] }), (0, jsx_runtime_1.jsx)("button", { label: effectiveLabels[store_1.Window.config] }), (0, jsx_runtime_1.jsx)("button", { label: effectiveLabels[store_1.Window.help] }), (0, jsx_runtime_1.jsx)("button", { label: effectiveLabels[store_1.Window.quit] }), chalk_1.default.gray(' | '), environmentLabel, chalk_1.default.gray(' > '), apiKeyLabel, chalk_1.default.gray(' > '), integrationLabel, chalk_1.default.gray(' > '), credentialLabel] }));
};
exports.default = Header;
;