-
Notifications
You must be signed in to change notification settings - Fork 1
Origin/fluent community #121
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
base: main
Are you sure you want to change the base?
Changes from all commits
cfbd072
18b6620
79b7607
4dcb26f
07ee587
48184b9
8314a39
8a1123e
6f658f8
6f98db2
ab96241
f5808ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* eslint-disable no-param-reassign */ | ||
|
||
import { useState } from 'react' | ||
import { useNavigate, useParams } 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' | ||
rahatyeasinemon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { saveActionConf } from '../IntegrationHelpers/IntegrationHelpers' | ||
import IntegrationStepThree from '../IntegrationHelpers/IntegrationStepThree' | ||
import { handleInput, checkMappedFields } from './FluentCommunityCommonFunc' | ||
import FluentCommunityIntegLayout from './FluentCommunityIntegLayout' | ||
|
||
function EditFluentCommunity({ allIntegURL }) { | ||
const navigate = useNavigate() | ||
const { id, formID } = useParams() | ||
|
||
const [fluentCommunityConf, setFluentCommunityConf] = useRecoilState($actionConf) | ||
const [flow, setFlow] = useRecoilState($newFlow) | ||
const formFields = useRecoilValue($formFields) | ||
const [isLoading, setIsLoading] = useState(false) | ||
const [loading, setLoading] = useState({}) | ||
const [snack, setSnackbar] = useState({ show: false }) | ||
const saveConfig = () => { | ||
if (!checkMappedFields(fluentCommunityConf)) { | ||
setSnackbar({ | ||
show: true, | ||
msg: __('Please map all required fields to continue.', 'bit-integrations') | ||
}) | ||
return | ||
} | ||
saveActionConf({ | ||
flow, | ||
setFlow, | ||
allIntegURL, | ||
conf: fluentCommunityConf, | ||
navigate, | ||
edit: 1, | ||
setIsLoading, | ||
setSnackbar | ||
}) | ||
} | ||
|
||
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={e => handleInput(e, fluentCommunityConf, setFluentCommunityConf)} | ||
name="name" | ||
value={fluentCommunityConf.name} | ||
type="text" | ||
placeholder={__('Integration Name...', 'bit-integrations')} | ||
/> | ||
</div> | ||
<br /> | ||
|
||
<SetEditIntegComponents entity={flow.triggered_entity} setSnackbar={setSnackbar} /> | ||
<FluentCommunityIntegLayout | ||
formID={formID} | ||
formFields={formFields} | ||
fluentCommunityConf={fluentCommunityConf} | ||
setFluentCommunityConf={setFluentCommunityConf} | ||
isLoading={isLoading} | ||
step={2} | ||
setIsLoading={setIsLoading} | ||
loading={loading} | ||
setLoading={setLoading} | ||
setSnackbar={setSnackbar} | ||
/> | ||
|
||
<IntegrationStepThree | ||
edit | ||
saveConfig={saveConfig} | ||
disabled={fluentCommunityConf.space_id === '' || fluentCommunityConf.field_map.length < 1} | ||
isLoading={isLoading} | ||
dataConf={fluentCommunityConf} | ||
setDataConf={setFluentCommunityConf} | ||
formFields={formFields} | ||
/> | ||
<br /> | ||
</div> | ||
) | ||
} | ||
|
||
export default EditFluentCommunity |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import { useState } from 'react' | ||
import 'react-multiple-select-dropdown-lite/dist/index.css' | ||
import { useNavigate, useParams } from 'react-router-dom' | ||
import BackIcn from '../../../Icons/BackIcn' | ||
import { __ } from '../../../Utils/i18nwrap' | ||
import SnackMsg from '../../Utilities/SnackMsg' | ||
import Steps from '../../Utilities/Steps' | ||
import { saveIntegConfig } from '../IntegrationHelpers/IntegrationHelpers' | ||
import IntegrationStepThree from '../IntegrationHelpers/IntegrationStepThree' | ||
import FluentCommunityAuthorization from './FluentCommunityAuthorization' | ||
import { checkMappedFields, refreshCommunityList } from './FluentCommunityCommonFunc' | ||
import FluentCommunityIntegLayout from './FluentCommunityIntegLayout' | ||
|
||
export default function FluentCommunity({ formFields, setFlow, flow, allIntegURL }) { | ||
const navigate = useNavigate() | ||
const { formID } = useParams() | ||
const [isLoading, setIsLoading] = useState(false) | ||
const [loading, setLoading] = useState({}) | ||
const [step, setStep] = useState(1) | ||
const [snack, setSnackbar] = useState({ show: false }) | ||
const [fluentCommunityConf, setFluentCommunityConf] = useState({ | ||
name: 'Fluent Community', | ||
type: 'Fluent Community', | ||
actionName: '', | ||
field_map: [{ formField: '', fluentCommunityField: '' }], | ||
actions: {} | ||
}) | ||
|
||
const nextPage = val => { | ||
setTimeout(() => { | ||
document.getElementById('btcd-settings-wrp').scrollTop = 0 | ||
}, 300) | ||
if (val === 3) { | ||
// All actions need field mapping validation | ||
if (!checkMappedFields(fluentCommunityConf)) { | ||
setSnackbar({ | ||
show: true, | ||
msg: __('Please map all required fields to continue.', 'bit-integrations') | ||
}) | ||
return | ||
} | ||
if (fluentCommunityConf?.actionName === 'add-user' && !fluentCommunityConf.list_id) { | ||
setSnackbar({ show: true, msg: __('Please select space to continue.', 'bit-integrations') }) | ||
rahatyeasinemon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return | ||
} | ||
if ( | ||
(fluentCommunityConf?.actionName === 'add-course' || | ||
fluentCommunityConf?.actionName === 'remove-course') && | ||
!fluentCommunityConf.course_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use ['add-course', 'remove-course'].includes(fluentCommunityConf?.actionName) |
||
) { | ||
setSnackbar({ show: true, msg: __('Please select course to continue.', 'bit-integrations') }) | ||
return | ||
} | ||
if ( | ||
fluentCommunityConf?.actionName === 'create-post' && | ||
(!fluentCommunityConf.post_space_id || !fluentCommunityConf.post_user_id) | ||
) { | ||
setSnackbar({ | ||
show: true, | ||
msg: __('Please select space and user to continue.', 'bit-integrations') | ||
}) | ||
return | ||
} | ||
if (fluentCommunityConf.name !== '' && fluentCommunityConf.field_map.length > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move those conditions to a separate common file that could be used from multiple files |
||
setStep(val) | ||
} | ||
} else { | ||
setStep(val) | ||
} | ||
} | ||
|
||
return ( | ||
<div> | ||
<SnackMsg snack={snack} setSnackbar={setSnackbar} /> | ||
<div className="txt-center mt-2"> | ||
<Steps step={3} active={step} /> | ||
</div> | ||
|
||
{/* STEP 1 */} | ||
<FluentCommunityAuthorization | ||
formID={formID} | ||
fluentCommunityConf={fluentCommunityConf} | ||
setFluentCommunityConf={setFluentCommunityConf} | ||
step={step} | ||
nextPage={nextPage} | ||
isLoading={isLoading} | ||
setIsLoading={setIsLoading} | ||
setSnackbar={setSnackbar} | ||
/> | ||
|
||
{/* STEP 2 */} | ||
<div | ||
className="btcd-stp-page" | ||
style={{ | ||
width: step === 2 && 900, | ||
height: step === 2 && 'auto', | ||
minHeight: step === 2 && `${200}px` | ||
}}> | ||
<FluentCommunityIntegLayout | ||
formID={formID} | ||
formFields={formFields} | ||
fluentCommunityConf={fluentCommunityConf} | ||
setFluentCommunityConf={setFluentCommunityConf} | ||
isLoading={isLoading} | ||
setIsLoading={setIsLoading} | ||
loading={loading} | ||
setLoading={setLoading} | ||
setSnackbar={setSnackbar} | ||
/> | ||
<br /> | ||
<br /> | ||
<br /> | ||
<button | ||
onClick={() => nextPage(3)} | ||
disabled={fluentCommunityConf.field_map.length < 1} | ||
className="btn f-right btcd-btn-lg purple sh-sm flx" | ||
type="button"> | ||
{__('Next', 'bit-integrations')} | ||
<BackIcn className="ml-1 rev-icn" /> | ||
</button> | ||
</div> | ||
|
||
{/* STEP 3 */} | ||
<IntegrationStepThree | ||
step={step} | ||
saveConfig={() => | ||
saveIntegConfig( | ||
flow, | ||
setFlow, | ||
allIntegURL, | ||
fluentCommunityConf, | ||
navigate, | ||
'', | ||
'', | ||
setIsLoading | ||
) | ||
} | ||
isLoading={isLoading} | ||
dataConf={fluentCommunityConf} | ||
setDataConf={setFluentCommunityConf} | ||
formFields={formFields} | ||
/> | ||
</div> | ||
) | ||
} |
Uh oh!
There was an error while loading. Please reload this page.