/* * << * Davinci * == * Copyright (C) 2016 - 2017 EDP * == * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * >> */ import React, { useCallback } from 'react' import { Modal, Tabs, Form, Input, Select, TreeSelect, Radio, Checkbox } from 'antd' const FormItem = Form.Item const { TreeNode } = TreeSelect const RadioGroup = Radio.Group import { FormComponentProps } from 'antd/lib/form' import useDashboardTreeNodes from '../hooks/dashboardTreeNodes' import { IDashboardWithRole } from './types' import { DashboardTypes } from '../constants' import { IDashboardNode } from '../types' interface IDashboardConfigModalProps extends FormComponentProps { visible: boolean loading: boolean dashboard: IDashboardWithRole dashboardNodes: IDashboardNode[] onCancel: () => void onSave: (dashboard: IDashboardWithRole) => void } const DashboardConfigModal: React.FC = (props) => { const { visible, loading, dashboard, dashboardNodes, form, onCancel, onSave } = props const { id, type } = dashboard const { getFieldDecorator } = form const nameTitle = type === DashboardTypes.Dashboard ? '仪表板 ' : '文件夹' const modalTitle = `${id > 0 ? '修改' : '新增'} ${nameTitle}}` const save = useCallback(() => { form.validateFieldsAndScroll((err, values) => { if (err) { return } onSave(values) }) }, [onSave]) return (
{getFieldDecorator('name', { rules: [ { required: true, message: '名称不能为空' } ] })()} {getFieldDecorator('parentId', { rules: [{ required: true }] })( {useDashboardTreeNodes(dashboardNodes, true, true)} )} {getFieldDecorator('type', { rules: [{ required: true }] })( 文件夹 仪表板 )}
) } export default DashboardConfigModal