diff --git a/web/components/main-layout.tsx b/web/components/main-layout.tsx index 81bdeec21..37bac402c 100644 --- a/web/components/main-layout.tsx +++ b/web/components/main-layout.tsx @@ -182,6 +182,9 @@ export default function MainLayout(props) { Access Tokens + + External Actions + } title="Help"> Help diff --git a/web/pages/actions.tsx b/web/pages/actions.tsx new file mode 100644 index 000000000..6d18db02b --- /dev/null +++ b/web/pages/actions.tsx @@ -0,0 +1,276 @@ +// comment + +import React, { useState, useEffect, useContext } from 'react'; +import { Table, Space, Button, Modal, Checkbox, Input, Typography } from 'antd'; +import { ServerStatusContext } from '../utils/server-status-context'; +import { DeleteOutlined } from '@ant-design/icons'; +import isValidUrl from '../utils/urls'; +import FormStatusIndicator from '../components/config/form-status-indicator'; +import { + createInputStatus, + StatusState, + STATUS_ERROR, + STATUS_PROCESSING, + STATUS_SUCCESS, +} from '../utils/input-statuses'; + +import { + postConfigUpdateToAPI, + API_EXTERNAL_ACTIONS, + RESET_TIMEOUT, +} from '../utils/config-constants'; + +const { Title, Paragraph } = Typography; +let resetTimer = null; + +interface Props { + onCancel: () => void; + onOk: any; // todo: make better type + visible: boolean; +} + +function NewActionModal(props: Props) { + const { onOk, onCancel, visible } = props; + + const [actionUrl, setActionUrl] = useState(''); + const [actionTitle, setActionTitle] = useState(''); + const [actionDescription, setActionDescription] = useState(''); + const [actionIcon, setActionIcon] = useState(''); + const [actionColor, setActionColor] = useState(''); + const [openExternally, setOpenExternally] = useState(false); + + function save() { + onOk(actionUrl, actionTitle, actionDescription, actionIcon, actionColor, openExternally); + } + + const okButtonProps = { + disabled: !isValidUrl(actionUrl) || actionTitle === '', + }; + + const onOpenExternallyChanged = checkbox => { + setOpenExternally(checkbox.target.checked); + }; + + return ( + +
+

+ setActionUrl(input.currentTarget.value)} + /> +

+

+ setActionTitle(input.currentTarget.value)} + /> +

+ +

+ setActionDescription(input.currentTarget.value)} + /> +

+ +

+ setActionIcon(input.currentTarget.value)} + /> +

+ +

+ setActionColor(input.currentTarget.value)} + /> +

+ + + Open in a new tab instead of within your page. + +
+
+ ); +} + +export default function Actions() { + const serverStatusData = useContext(ServerStatusContext); + const { serverConfig, setFieldInConfigState } = serverStatusData || {}; + const { externalActions } = serverConfig; + const [actions, setActions] = useState([]); + const [isModalVisible, setIsModalVisible] = useState(false); + const [submitStatus, setSubmitStatus] = useState(null); + + const resetStates = () => { + setSubmitStatus(null); + resetTimer = null; + clearTimeout(resetTimer); + }; + + useEffect(() => { + setActions(externalActions || []); + }, [externalActions]); + + const columns = [ + { + title: '', + key: 'delete', + render: (text, record) => ( + +