UNPKG

@doreamonjs/gate

Version:
79 lines (78 loc) 2.97 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (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 (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __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 react_1 = __importDefault(require("react")); const dva_1 = require("dva"); const antd_1 = require("antd"); const components_1 = require("@doreamonjs/components"); const terminal = __importStar(require("@doreamonjs/plugin-terminal")); const Log = (props) => { const drawerProps = { className: props.className, width: props.width || 800, title: props.title, placement: props.placement || 'right', visible: props.visible, onClose: props.onClose, // closable: false, maskClosable: false, }; const terminalProps = { url: props.url, once: props.once, onClose: undefined, }; const style = { backgroundColor: '#000', padding: 0, // ...props.style, }; // if placement is top or bottom, remove title if (props.placement === 'top' || props.placement === 'bottom') { // drawerProps.title = null; drawerProps.headerStyle = { display: 'none' }; // terminalProps.onClose = props.onClose; } return (react_1.default.createElement(antd_1.Drawer, { ...drawerProps, bodyStyle: style }, props.visible && (react_1.default.createElement(components_1.Terminal, { ...terminalProps, key: String(Math.random()) })))); }; const mapState = (states) => { const state = states[terminal.NAMESPACE]; const loading = states.loading; const { nextEffect } = state; const btnLoading = loading.effects[nextEffect]; return { loading: btnLoading, visible: state.visible, // attributes: state.attributes, // values: state.datasets.values, ...state.attributes, ...state.datasets.values, }; }; const mapActions = (dispatch) => ({ onClose: () => dispatch({ type: `${terminal.NAMESPACE}/close` }), }); exports.default = dva_1.connect(mapState, mapActions)(Log);