Skip to content

Commit 45f876d

Browse files
committed
refactor: acpt option page user capabiliy
1 parent 547d53c commit 45f876d

File tree

5 files changed

+416
-346
lines changed

5 files changed

+416
-346
lines changed

frontend-dev/src/components/AllIntegrations/ACPT/ACPT.jsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function ACPT({ formFields, setFlow, flow, allIntegURL }) {
4040
acptLabels: [],
4141
utilities: {},
4242
icon: 'wordpress',
43+
capability: 'manage_options',
4344
module: '',
4445
cptFields,
4546
cptLabels,
@@ -73,13 +74,23 @@ function ACPT({ formFields, setFlow, flow, allIntegURL }) {
7374
}
7475

7576
if (
76-
(acptConf.module === 'create_cpt' || acptConf.module === 'create_option_page') &&
77+
['create_cpt', 'update_cpt', 'create_option_page', 'update_option_page'].includes(
78+
acptConf.module
79+
) &&
7780
!acptConf?.icon
7881
) {
7982
toast.error(__('Please select Icon', 'bit-integrations'))
8083
return
8184
}
8285

86+
if (
87+
['create_option_page', 'update_option_page'].includes(acptConf.module) &&
88+
!acptConf?.capability
89+
) {
90+
toast.error(__('Please select Capability', 'bit-integrations'))
91+
return
92+
}
93+
8394
acptConf.field_map.length > 0 && setStep(pageNo)
8495
}
8596

frontend-dev/src/components/AllIntegrations/ACPT/ACPTIntegLayout.jsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { checkIsPro, getProLabel } from '../../Utilities/ProUtilHelpers'
1010
import { generateMappedField, getAllGenerator } from './ACPTCommonFunc'
1111
import FieldMappingLayout from './FieldMappingLayout'
1212
import ACPTActions from './ACPTActions'
13-
import { cptIcons } from './staticData'
13+
import { cptIcons, optionPageCapabilities } from './staticData'
1414

1515
export default function ACPTIntegLayout({
1616
formFields,
@@ -133,6 +133,23 @@ export default function ACPTIntegLayout({
133133
</div>
134134
)}
135135

136+
{acptConf?.module &&
137+
['create_option_page', 'update_option_page'].includes(acptConf.module) &&
138+
!isLoading && (
139+
<div className="flx">
140+
<b className="wdt-200 d-in-b">{__('Select Capability:', 'bit-integrations')}</b>
141+
<MultiSelect
142+
title="Capability"
143+
defaultValue={acptConf?.capability}
144+
className="mt-2 w-5"
145+
onChange={val => setChanges(val, 'capability')}
146+
options={optionPageCapabilities}
147+
singleSelect
148+
closeOnSelect
149+
/>
150+
</div>
151+
)}
152+
136153
{acptConf.module && (
137154
<>
138155
{!isLoading && (

frontend-dev/src/components/AllIntegrations/ACPT/EditACPT.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,23 @@ function EditACPT({ allIntegURL }) {
3030
}
3131

3232
if (
33-
(acptConf.module === 'create_cpt' || acptConf.module === 'create_option_page') &&
33+
['create_cpt', 'update_cpt', 'create_option_page', 'update_option_page'].includes(
34+
acptConf.module
35+
) &&
3436
!acptConf?.icon
3537
) {
3638
toast.error(__('Please select Icon', 'bit-integrations'))
3739
return
3840
}
3941

42+
if (
43+
['create_option_page', 'update_option_page'].includes(acptConf.module) &&
44+
!acptConf?.capability
45+
) {
46+
toast.error(__('Please select Capability', 'bit-integrations'))
47+
return
48+
}
49+
4050
saveActionConf({
4151
flow,
4252
allIntegURL,

0 commit comments

Comments
 (0)