@@ -61,6 +66,8 @@ const EmbeddedWorkflowEntryPoint = (props) => {
hasIconOnly
onClick={() => {
setSelectedValue({});
+ // Ensure the input change is triggered to update form state
+ input.onChange(null);
}}
/>
diff --git a/app/javascript/components/service-dialog-form/data.js b/app/javascript/components/service-dialog-form/data.js
new file mode 100644
index 00000000000..d198ef15d24
--- /dev/null
+++ b/app/javascript/components/service-dialog-form/data.js
@@ -0,0 +1,71 @@
+import React from 'react';
+import {
+ CheckboxChecked32, RadioButtonChecked32, Time32, StringText32, TextSmallCaps32, CaretDown32, Tag32, Calendar32,
+} from '@carbon/icons-react';
+import { formattedCatalogPayload } from './helper';
+
+export const dragItems = {
+ COMPONENT: 'component',
+ SECTION: 'section',
+ FIELD: 'field',
+ TAB: 'tab',
+};
+
+/** Data needed to render the dynamic components on the left hand side of the form. */
+export const dynamicComponents = [
+ { id: 1, title: 'Text Box', icon:
},
+ { id: 2, title: 'Text Area', icon:
},
+ { id: 3, title: 'Check Box', icon:
},
+ { id: 4, title: 'Dropdown', icon:
},
+ { id: 5, title: 'Radio Button', icon:
},
+ { id: 6, title: 'Datepicker', icon:
},
+ { id: 7, title: 'Timepicker', icon:
},
+ { id: 8, title: 'Tag Control', icon:
},
+];
+
+/** Function which returns the default data for a section under a tab. */
+export const defaultSectionContents = (tabId, sectionId) => ({
+ tabId,
+ sectionId,
+ title: 'New Section',
+ fields: [],
+ order: 0,
+});
+
+/** Function which returns the default data for a tab with default section. */
+export const defaultTabContents = (tabId) => ({
+ tabId,
+ name: tabId === 0 ? __('New Tab') : __(`New Tab ${tabId}`),
+ sections: [defaultSectionContents(tabId, 0)],
+});
+
+/** Function to create a dummy tab for creating new tabs. */
+export const createNewTab = () => ({
+ tabId: 'new',
+ name: 'Create Tab',
+ sections: [],
+});
+
+export const tagControlCategories = async() => {
+ try {
+ const { resources } = await API.get('/api/categories?expand=resources&attributes=id,name,description,single_value,children');
+
+ return resources;
+ } catch (error) {
+ console.error('Error fetching categories:', error);
+ return [];
+ }
+};
+
+// data has formfields and list (as of now); no dialog related general info - this is needed
+export const saveServiceDialog = (data) => {
+ const payload = formattedCatalogPayload(data);
+
+ API.post('/api/service_dialogs', payload, {
+ skipErrors: [400],
+ }).then(() => {
+ window.location.href = '/miq_ae_customization/explorer';
+ }).catch((error) => {
+ console.error('Error saving dialog:', error);
+ });
+};
diff --git a/app/javascript/components/service-dialog-form/dynamic-component-chooser.jsx b/app/javascript/components/service-dialog-form/dynamic-component-chooser.jsx
new file mode 100644
index 00000000000..39deb0a7d55
--- /dev/null
+++ b/app/javascript/components/service-dialog-form/dynamic-component-chooser.jsx
@@ -0,0 +1,34 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { dragItems } from './data';
+
+/** Component to render the components list vertically on left side.
+ * Components can be used to drag and drop into the tab Contents */
+const DynamicComponentChooser = ({ list, onDragStartComponent }) => (
+
+ {
+ list.map((item, index) => (
+
onDragStartComponent(event, dragItems.COMPONENT)}
+ key={index.toString()}
+ >
+
+ {item.icon}
+ {item.title}
+
+
+ ))
+ }
+
+);
+
+DynamicComponentChooser.propTypes = {
+ list: PropTypes.arrayOf(PropTypes.any).isRequired,
+ onDragStartComponent: PropTypes.func.isRequired,
+};
+
+export default DynamicComponentChooser;
diff --git a/app/javascript/components/service-dialog-form/dynamic-field-actions.jsx b/app/javascript/components/service-dialog-form/dynamic-field-actions.jsx
new file mode 100644
index 00000000000..9d383b99af0
--- /dev/null
+++ b/app/javascript/components/service-dialog-form/dynamic-field-actions.jsx
@@ -0,0 +1,117 @@
+import React, { useState } from 'react';
+import PropTypes from 'prop-types';
+import { Button } from 'carbon-components-react';
+import { Close16, Edit16 } from '@carbon/icons-react';
+import { SD_ACTIONS, SD_PROP_SHAPES } from './helper';
+import EditFieldModal from './edit-field-modal';
+
+/** Component to render a Field. */
+const DynamicFieldActions = ({
+ componentId, fieldProps, updateFieldProps, dynamicFieldAction, fieldConfiguration, dynamicToggleAction, setCategoryData, onValueChange,
+}) => {
+ const [state, setState] = useState({ showModal: false });
+ const { showModal } = state;
+
+ const toggleModal = (show = false) => setState((state) => ({ ...state, showModal: show }));
+ // const onModalApply = () => setState((state) => ({ ...state, showModal: false }));
+ const onModalApply = (formValues, event) => {
+ setState((prevState) => ({ ...prevState, ...formValues }));
+ toggleModal(false);
+ dynamicFieldAction(event, formValues);
+ };
+
+ const onDynamicSwitchToggle = (isDynamic) => {
+ setState((prevState) => ({ ...prevState, dynamic: isDynamic }));
+ dynamicToggleAction(isDynamic);
+ };
+
+ const onTimePickerChange = (dateTime) => {
+ setState((prevState) => ({ ...prevState, value: dateTime }));
+ onValueChange(dateTime);
+ };
+
+ const onAutomationTypeChange = (val) => {
+ setState((prevState) => ({ ...prevState, automationType: val }));
+ onValueChange(val);
+ };
+
+ const renderEditButton = () => (
+