diff --git a/src/components/eventing/EventingConfigure.jsx b/src/components/eventing/EventingConfigure.jsx index 3ab4fb96..75244312 100644 --- a/src/components/eventing/EventingConfigure.jsx +++ b/src/components/eventing/EventingConfigure.jsx @@ -1,42 +1,166 @@ import React from 'react' -import { AutoComplete, Button, Form, Checkbox } from 'antd'; +import { AutoComplete, Button, Form, Checkbox, Select, Input, DatePicker } from 'antd'; import ConditionalFormBlock from "../conditional-form-block/ConditionalFormBlock"; import FormItemLabel from "../form-item-label/FormItemLabel"; +import { useSelector } from 'react-redux'; +import { getTrackedCollections } from '../../operations/database'; +import { MinusCircleFilled, PlusOutlined } from '@ant-design/icons'; +const { Option } = AutoComplete; -const EventingConfigure = ({ initialValues, handleSubmit, dbList, loading }) => { +const EventingConfigure = ({ initialValues, handleSubmit, dbList, loading, onDeleteEventingLogs }) => { + const [form] = Form.useForm() + const state = useSelector(state => state) - const [form] = Form.useForm() - const handleSubmitClick = e => { - form.validateFields().then(values => { - handleSubmit(values) - }) - } + const handleTruncateEventLogs = () => { + form.validateFields(["truncateSince"]).then(values => { + values.truncateSince = values.truncateSince.unix() - if (!loading) { - form.setFieldsValue(initialValues) - } + onDeleteEventingLogs(values.truncateSince) + }) + } - return ( -
- - - Enable eventing module + const getCollections = (db) => getTrackedCollections(state, db) + + const handleSubmitClick = e => { + form.validateFields(["enabled", "dbAlias", "dbTables"]).then(values => { + values = Object.assign({}, initialValues, values) + + if (values.enabled) { + values.dbTablesInclusionMap = {} + if (values.dbTables.length === 0) { + values.dbTablesInclusionMap["*"] = "*"; + } + else { + values.dbTables.forEach(item => { + if (item) { + values.dbTablesInclusionMap[item.db] = item.col && item.col.length > 0 ? item.col : "*" + } + }) + } + } + + delete values["dbTables"] + handleSubmit(values) + }) + } + + if (!loading) { + const dbTables = []; + if (initialValues.enabled && (!initialValues.dbTablesInclusionMap || Object.keys(initialValues.dbTablesInclusionMap).length === 0)) { + dbTables.push({ db: "*", col: ["*"] }) + } + if (initialValues.enabled && initialValues.dbTablesInclusionMap) { + Object.keys(initialValues.dbTablesInclusionMap).forEach(db => { + dbTables.push({ db, col: initialValues.dbTablesInclusionMap[db] }) + }) + } + form.setFieldsValue({ ...initialValues, dbTables }) + } + + const isAddDatabaseDisabled = (fields) => { + if (Object.keys(fields).length === 0) { + return false; + } + return fields.dbTables.find(x => x.db === "*"); + } + + return ( + + + + Enable eventing module - - form.getFieldValue("enabled")}> - - - ({ value: db }))} /> - - - - + )} + + + ) + }} + + + + - - - ) +
+ form.getFieldValue("enabled")}> + + + + + + + + ) } export default EventingConfigure; \ No newline at end of file diff --git a/src/components/security-rules/configure-rule/ConfigureRule.jsx b/src/components/security-rules/configure-rule/ConfigureRule.jsx index a2974b73..a6f8c77c 100644 --- a/src/components/security-rules/configure-rule/ConfigureRule.jsx +++ b/src/components/security-rules/configure-rule/ConfigureRule.jsx @@ -339,7 +339,12 @@ const ConfigureRule = (props) => {