-
Couldn't load subscription status.
- Fork 1
Feat/fabman-action #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Md-Abed-Hossen
wants to merge
17
commits into
main
Choose a base branch
from
feat/fabman-action
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Feat/fabman-action #116
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c1cdff8
feat: fabman actions
Md-Abed-Hossen 323205f
chore: update logo and update functionality
Md-Abed-Hossen cddd55f
Merge branch 'main' into feat/fabman-action
Md-Abed-Hossen 8cbe987
chore: update logics
Md-Abed-Hossen 4761d43
chore: integration name set
Md-Abed-Hossen 0d56df3
chore: update functionality
Md-Abed-Hossen 270b5fd
Merge branch 'main' into feat/fabman-action
Md-Abed-Hossen 9d309a1
Merge branch 'main' into feat/fabman-action
Md-Abed-Hossen a71c57e
chore: update member function
Md-Abed-Hossen e4b0bfc
chore: update member button fix
Md-Abed-Hossen 8d68b43
Revert "chore: update member button fix"
Md-Abed-Hossen 760a9f5
chore: update
Md-Abed-Hossen cbec046
chore: udpate respone
Md-Abed-Hossen 45a9750
chore: update
Md-Abed-Hossen 9f3728b
chore: update
Md-Abed-Hossen 0dbf4e5
chore: formatting
Md-Abed-Hossen 2631a51
Merge branch 'main' into feat/fabman-action
Md-Abed-Hossen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
frontend-dev/src/components/AllIntegrations/Fabman/EditFabman.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| /* eslint-disable no-unused-vars */ | ||
| /* eslint-disable no-param-reassign */ | ||
|
|
||
| import { useState, useEffect } from 'react' | ||
| import { useNavigate } from 'react-router-dom' | ||
| import { useRecoilState, useRecoilValue } from 'recoil' | ||
| import { $actionConf, $formFields, $newFlow } from '../../../GlobalStates' | ||
| import { __ } from '../../../Utils/i18nwrap' | ||
| import SnackMsg from '../../Utilities/SnackMsg' | ||
| import EditFormInteg from '../EditFormInteg' | ||
| import SetEditIntegComponents from '../IntegrationHelpers/SetEditIntegComponents' | ||
| import EditWebhookInteg from '../EditWebhookInteg' | ||
| import { saveActionConf } from '../IntegrationHelpers/IntegrationHelpers' | ||
| import IntegrationStepThree from '../IntegrationHelpers/IntegrationStepThree' | ||
| import { checkMappedFields, handleInput, isConfigInvalid } from './FabmanCommonFunc' | ||
| import FabmanIntegLayout from './FabmanIntegLayout' | ||
| import { checkValidEmail } from '../../../Utils/Helpers' | ||
|
|
||
| function EditFabman({ allIntegURL }) { | ||
| const navigate = useNavigate() | ||
| const [flow, setFlow] = useRecoilState($newFlow) | ||
| const [fabmanConf, setFabmanConf] = useRecoilState($actionConf) | ||
| const [loading, setLoading] = useState({ | ||
| list: false, | ||
| field: false, | ||
| auth: false | ||
| }) | ||
| const [snack, setSnackbar] = useState({ show: false }) | ||
| const formField = useRecoilValue($formFields) | ||
|
|
||
| const [localName, setLocalName] = useState(fabmanConf.name || '') | ||
|
|
||
| const getEmailMappingRow = () => { | ||
| const rows = Array.isArray(fabmanConf?.field_map) ? fabmanConf.field_map : [] | ||
| return rows.find(r => r?.fabmanFormField === 'emailAddress') | ||
| } | ||
|
|
||
| const isEmailMappingInvalid = () => { | ||
| const emailRow = getEmailMappingRow() | ||
| if (!emailRow) return true | ||
| if (emailRow.formField === 'custom') { | ||
| const customValue = (emailRow.customValue || '').trim() | ||
| return !customValue || !checkValidEmail(customValue) | ||
| } | ||
| // Non-custom: a form field is selected. Consider valid if: | ||
| // - field type is email, OR | ||
| // - type is missing/unknown, OR | ||
| // - field name/label includes "email" | ||
| const selectedField = (formField || []).find(f => f.name === emailRow.formField) | ||
|
|
||
| if (!selectedField) return false | ||
|
|
||
| const hasEmailType = selectedField.type && String(selectedField.type).toLowerCase() === 'email' | ||
| const looksLikeEmailField = | ||
| /email/i.test(selectedField.name || '') || /email/i.test(selectedField.label || '') | ||
| return !(hasEmailType || !selectedField.type || looksLikeEmailField) | ||
| } | ||
|
|
||
| const saveConfig = () => { | ||
| if (!fabmanConf.actionName) { | ||
| setSnackbar({ show: true, msg: __('Please select an action', 'bit-integrations') }) | ||
| return | ||
| } | ||
|
|
||
| if (['update_member', 'delete_member'].includes(fabmanConf.actionName)) { | ||
| if (!checkMappedFields(fabmanConf)) { | ||
| setSnackbar({ show: true, msg: __('Please map mandatory fields', 'bit-integrations') }) | ||
| return | ||
| } | ||
|
|
||
| if (isEmailMappingInvalid()) { | ||
| setSnackbar({ show: true, msg: __('Please map a valid email address', 'bit-integrations') }) | ||
| return | ||
| } | ||
|
|
||
| saveActionConf({ | ||
| flow, | ||
| allIntegURL, | ||
| conf: fabmanConf, | ||
| navigate, | ||
| edit: 1, | ||
| setLoading, | ||
| setSnackbar | ||
| }) | ||
| return | ||
| } | ||
|
|
||
| if (!checkMappedFields(fabmanConf)) { | ||
| setSnackbar({ show: true, msg: __('Please map mandatory fields', 'bit-integrations') }) | ||
| return | ||
| } | ||
|
|
||
| const requiresWorkspaceSelection = | ||
| fabmanConf.actionName === 'update_spaces' || fabmanConf.actionName === 'delete_spaces' | ||
|
|
||
| if (requiresWorkspaceSelection && !fabmanConf.selectedWorkspace) { | ||
| setSnackbar({ show: true, msg: __('Please select a workspace', 'bit-integrations') }) | ||
| return | ||
| } | ||
|
|
||
| saveActionConf({ | ||
| flow, | ||
| allIntegURL, | ||
| conf: fabmanConf, | ||
| navigate, | ||
| edit: 1, | ||
| setLoading, | ||
| setSnackbar | ||
| }) | ||
| } | ||
|
|
||
| const handleNameChange = e => { | ||
| setLocalName(e.target.value) | ||
| setFabmanConf(prev => ({ ...prev, name: e.target.value })) | ||
| } | ||
|
|
||
| return ( | ||
| <div style={{ width: 900 }}> | ||
| <SnackMsg snack={snack} setSnackbar={setSnackbar} /> | ||
| <div className="flx mt-3"> | ||
| <b className="wdt-200 d-in-b">{__('Integration Name:', 'bit-integrations')}</b> | ||
| <input | ||
| className="btcd-paper-inp w-5" | ||
| onChange={handleNameChange} | ||
| name="name" | ||
| value={localName} | ||
| type="text" | ||
| placeholder={__('Integration Name...', 'bit-integrations')} | ||
| /> | ||
| </div> | ||
| <br /> | ||
| <SetEditIntegComponents entity={flow.triggered_entity} setSnackbar={setSnackbar} /> | ||
| <FabmanIntegLayout | ||
| formID={flow.triggered_entity_id} | ||
| formFields={formField} | ||
| handleInput={e => handleInput(e, fabmanConf, setFabmanConf, setLoading, setSnackbar)} | ||
| fabmanConf={fabmanConf} | ||
| setFabmanConf={setFabmanConf} | ||
| loading={loading} | ||
| setLoading={setLoading} | ||
| setSnackbar={setSnackbar} | ||
| /> | ||
| <IntegrationStepThree | ||
| edit | ||
| saveConfig={saveConfig} | ||
| disabled={isConfigInvalid(fabmanConf, formField)} | ||
| isLoading={loading.list || loading.field || loading.auth} | ||
| dataConf={fabmanConf} | ||
| setDataConf={setFabmanConf} | ||
| formFields={formField} | ||
| /> | ||
| <br /> | ||
| </div> | ||
| ) | ||
| } | ||
|
|
||
| export default EditFabman | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use !hasEmailType || selectedField.type || !looksLikeEmailField