From 522e782d9f05c90a975464ef4dae3c58fb6c4088 Mon Sep 17 00:00:00 2001 From: Ben Elferink Date: Tue, 22 Oct 2024 10:54:28 +0300 Subject: [PATCH 01/11] feat(frontend): added actions form, and fixed bugs: empty inputs, search bar --- .../action-custom-fields.tsx | 66 ++++++ .../main/actions/choose-action-body/index.tsx | 65 ++++++ .../choose-action-modal/action-options.ts | 37 +++- .../actions/choose-action-modal/index.tsx | 93 ++++---- .../webapp/hooks/actions/useActionFormData.ts | 21 ++ .../webapp/public/icons/common/notebook.svg | 3 + .../auto-complete-input/index.tsx | 201 ++++++++---------- .../button/DocsButton.tsx | 21 ++ .../reuseable-components/button/index.tsx | 36 ++-- .../checkbox-list/index.tsx | 54 ++--- frontend/webapp/reuseable-components/index.ts | 1 + .../reuseable-components/input-list/index.tsx | 123 +++++------ .../key-value-input-list/index.tsx | 153 ++++++------- .../reuseable-components/text/index.tsx | 48 ++--- 14 files changed, 517 insertions(+), 405 deletions(-) create mode 100644 frontend/webapp/containers/main/actions/choose-action-body/action-custom-fields.tsx create mode 100644 frontend/webapp/containers/main/actions/choose-action-body/index.tsx create mode 100644 frontend/webapp/hooks/actions/useActionFormData.ts create mode 100644 frontend/webapp/public/icons/common/notebook.svg create mode 100644 frontend/webapp/reuseable-components/button/DocsButton.tsx diff --git a/frontend/webapp/containers/main/actions/choose-action-body/action-custom-fields.tsx b/frontend/webapp/containers/main/actions/choose-action-body/action-custom-fields.tsx new file mode 100644 index 000000000..259a62233 --- /dev/null +++ b/frontend/webapp/containers/main/actions/choose-action-body/action-custom-fields.tsx @@ -0,0 +1,66 @@ +import styled from 'styled-components' +import { InputList, KeyValueInputsList, Text } from '@/reuseable-components' +import type { ActionsType } from '@/types' + +interface ActionCustomFieldsProps { + actionType?: ActionsType +} + +const FieldWrapper = styled.div` + width: 100%; + margin: 8px 0; +` + +const FieldTitle = styled(Text)` + margin-bottom: 12px; +` + +const ActionCustomFields: React.FC = ({ actionType }) => { + switch (actionType) { + case 'AddClusterInfo': + return ( + + Attributes to add + console.log(arr)} /> + + ) + + case 'DeleteAttribute': + return ( + + Attributes to delete + console.log(arr)} /> + + ) + + case 'RenameAttribute': + return ( + + Attributes to rename + console.log(arr)} /> + + ) + + case 'PiiMasking': + return ( + + Attributes to mask + console.log(arr)} /> + + ) + + case 'ErrorSampler': + return null + + case 'ProbabilisticSampler': + return null + + case 'LatencySampler': + return null + + default: + return null + } +} + +export default ActionCustomFields diff --git a/frontend/webapp/containers/main/actions/choose-action-body/index.tsx b/frontend/webapp/containers/main/actions/choose-action-body/index.tsx new file mode 100644 index 000000000..94e3fe6ab --- /dev/null +++ b/frontend/webapp/containers/main/actions/choose-action-body/index.tsx @@ -0,0 +1,65 @@ +import React, { Fragment } from 'react' +import styled from 'styled-components' +import { CheckboxList, DocsButton, Input, Text, TextArea } from '@/reuseable-components' +import { MONITORING_OPTIONS } from '@/components/setup/destination/utils' +import { useActionFormData } from '@/hooks/actions/useActionFormData' +import ActionCustomFields from './action-custom-fields' +import { type ActionOption } from '../choose-action-modal/action-options' + +const Description = styled(Text)` + color: ${({ theme }) => theme.text.grey}; + line-height: 150%; + display: flex; +` + +const FieldWrapper = styled.div` + width: 100%; + margin: 8px 0; +` + +const FieldTitle = styled(Text)` + margin-bottom: 12px; +` + +interface ChooseActionContentProps { + action: ActionOption +} + +const ChooseActionBody: React.FC = ({ action }) => { + const { actionName, setActionName, actionNotes, setActionNotes, exportedSignals, setExportedSignals } = useActionFormData() + + return ( + + + {action.docsDescription} + + + + + Monitoring + { + const found = MONITORING_OPTIONS.find((item) => item.id === id) + if (found) setExportedSignals((prev) => ({ ...prev, [found.type]: val })) + }} + /> + + + + Action name + setActionName(value)} /> + + + + + + Notes +