import { Input, PageHeader as AntdPageHeader, Spin } from 'antd'; import React, { useContext, useState } from 'react'; import { useHistory, useRouteMatch } from 'react-router-dom'; import { useAPIClient, useRequest, useSchemaTemplateManager } from '..'; import { RemoteSchemaComponent, SchemaComponentContext } from '../schema-component'; const EditableTitle = (props) => { const [title, setTitle] = useState(props.title); const [visible, setVisible] = useState(false); const { refresh } = useSchemaTemplateManager(); const api = useAPIClient(); const { run } = useRequest( { resource: 'uiSchemaTemplates', action: 'update', params: { filterByTk: props.filterByTk, }, }, { manual: true, debounceWait: 500, onSuccess() { refresh(); }, }, ); return (
{visible ? ( { setVisible(false); }} onChange={(e) => { setTitle(e.target.value); run({ filterByTk: props.filterByTk, values: { name: e.target.value, }, }); }} /> ) : (
{ setVisible(true); }} > {title || 未命名}
)}
); }; export const BlockTemplateDetails = () => { const history = useHistory(); const match = useRouteMatch(); const key = match?.params?.key; const value = useContext(SchemaComponentContext); const { data, loading } = useRequest({ resource: 'uiSchemaTemplates', action: 'get', params: { filterByTk: key, }, }); if (loading) { return ; } return (
{ history.push('/admin/plugins/block-templates'); }} ghost={false} title={} />
); };