/* * << * 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, forwardRef, useImperativeHandle } from 'react' import { Form, message } from 'antd' import BaseForm from './BaseForm' import AuthForm from './AuthForm' import { copyTextToClipboard } from '../utils' import { TCopyType, Tmode } from '../types' import { IProjectRoles } from 'containers/Organizations/component/ProjectRole' import { IOrganizationMember } from 'containers/Organizations/types' import { FormComponentProps } from 'antd/lib/form' import styles from '../SharePanel.less' interface IConfigFormProps extends FormComponentProps { mode: Tmode shareUrl: string password: string loading: boolean projectRoles: IProjectRoles[] organizationMembers: IOrganizationMember[] onSetRoles: (roles: number[]) => void onSetViewers: (viewers: number[]) => void onGetToken: () => void } const ConfigForm: React.FC = ( { form, mode, shareUrl, loading, password, projectRoles, organizationMembers, onSetRoles, onSetViewers, onGetToken }, ref ) => { useImperativeHandle(ref, () => ({ form })) const copy = useCallback( (copytype: TCopyType) => () => { const text = copytype === 'link' ? shareUrl : `链接:${shareUrl} 口令:${password}` copyTextToClipboard( text, () => message.success('复制链接成功'), () => message.warning('复制链接失败,请稍后重试') ) }, [shareUrl, password] ) let content switch (mode) { case 'NORMAL': content = ( ) break case 'PASSWORD': content = ( ) break case 'AUTH': content = ( ) break } return
{content}
} export default Form.create()(forwardRef(ConfigForm))