Skip to content

Commit 438ea71

Browse files
committed
refctor: acpt icons list
1 parent 850d01b commit 438ea71

File tree

6 files changed

+530
-149
lines changed

6 files changed

+530
-149
lines changed

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

Lines changed: 15 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ import IntegrationStepThree from '../IntegrationHelpers/IntegrationStepThree'
1212
import ACPTAuthorization from './ACPTAuthorization'
1313
import { checkMappedFields } from './ACPTCommonFunc'
1414
import ACPTIntegLayout from './ACPTIntegLayout'
15+
import {
16+
cptFields,
17+
cptLabels,
18+
modules,
19+
optionPageFields,
20+
taxonomyFields,
21+
taxonomyLabels
22+
} from './staticData'
1523

1624
function ACPT({ formFields, setFlow, flow, allIntegURL }) {
1725
const navigate = useNavigate()
@@ -31,6 +39,7 @@ function ACPT({ formFields, setFlow, flow, allIntegURL }) {
3139
acptFields: [],
3240
acptLabels: [],
3341
utilities: {},
42+
icon: 'dashboard',
3443
module: '',
3544
cptFields,
3645
cptLabels,
@@ -58,18 +67,16 @@ function ACPT({ formFields, setFlow, flow, allIntegURL }) {
5867
document.getElementById('btcd-settings-wrp').scrollTop = 0
5968
}, 300)
6069

61-
if (acptConf.module != 'update_license' && !checkMappedFields(acptConf)) {
70+
if (!checkMappedFields(acptConf)) {
6271
toast.error(__('Please map mandatory fields', 'bit-integrations'))
6372
return
6473
}
6574

66-
if (acptConf.module === 'create_license' && !acptConf?.selectedStatus) {
67-
toast.error(__('Please select Status', 'bit-integrations'))
68-
return
69-
}
70-
71-
if (acptConf.module === 'update_license' && !acptConf?.selectedLicense) {
72-
toast.error(__('Please select Status', 'bit-integrations'))
75+
if (
76+
(acptConf.module === 'create_cpt' || acptConf.module === 'create_option_page') &&
77+
!acptConf?.icon
78+
) {
79+
toast.error(__('Please select Icon', 'bit-integrations'))
7380
return
7481
}
7582

@@ -138,126 +145,3 @@ function ACPT({ formFields, setFlow, flow, allIntegURL }) {
138145
}
139146

140147
export default ACPT
141-
142-
const modules = [
143-
{ name: 'create_cpt', label: __('Create CPT', 'bit-integrations'), is_pro: false },
144-
{ name: 'update_cpt', label: __('Update CPT', 'bit-integrations'), is_pro: true },
145-
{ name: 'delete_cpt', label: __('Delete CPT', 'bit-integrations'), is_pro: true },
146-
{ name: 'create_taxonomy', label: __('Create Taxonomy', 'bit-integrations'), is_pro: true },
147-
{ name: 'update_taxonomy', label: __('Update Taxonomy', 'bit-integrations'), is_pro: true },
148-
{ name: 'delete_taxonomy', label: __('Delete Taxonomy', 'bit-integrations'), is_pro: true },
149-
{
150-
name: 'associate_taxonomy_to_cpt',
151-
label: __('Associate Taxonomy To CPT', 'bit-integrations'),
152-
is_pro: true
153-
},
154-
{ name: 'create_option_page', label: __('Create Option Page', 'bit-integrations'), is_pro: true },
155-
{ name: 'update_option_page', label: __('Update Option Page', 'bit-integrations'), is_pro: true },
156-
{ name: 'delete_option_page', label: __('Delete Option Page', 'bit-integrations'), is_pro: true },
157-
{ name: 'delete_meta_group', label: __('Delete Meta Field Group', 'bit-integrations'), is_pro: true },
158-
{ name: 'delete_dynamic_block', label: __('Delete Dynamic Block', 'bit-integrations'), is_pro: true }
159-
]
160-
161-
const cptFields = [
162-
{ label: __('Post Name', 'bit-integrations'), key: 'post_name', required: true },
163-
{ label: __('Singular Label', 'bit-integrations'), key: 'singular_label', required: true },
164-
{ label: __('Plural Label', 'bit-integrations'), key: 'plural_label', required: true },
165-
{ label: __('Icon', 'bit-integrations'), key: 'icon', required: true },
166-
{ label: __('REST API base slug', 'bit-integrations'), key: 'rest_base', required: false },
167-
{ label: __('Menu position', 'bit-integrations'), key: 'menu_position', required: false },
168-
{ label: __('Capability type', 'bit-integrations'), key: 'capability_type', required: false },
169-
{ label: __('Custom rewrite rules', 'bit-integrations'), key: 'custom_rewrite', required: false },
170-
{ label: __('Custom query var', 'bit-integrations'), key: 'custom_query_var', required: false }
171-
]
172-
173-
const cptLabels = [
174-
{ label: __('Menu Name', 'bit-integrations'), key: 'menu_name' },
175-
{ label: __('All Items', 'bit-integrations'), key: 'all_items' },
176-
{ label: __('Add New', 'bit-integrations'), key: 'add_new' },
177-
{ label: __('Add New Item', 'bit-integrations'), key: 'add_new_item' },
178-
{ label: __('Edit Item', 'bit-integrations'), key: 'edit_item' },
179-
{ label: __('New Item', 'bit-integrations'), key: 'new_item' },
180-
{ label: __('View Item', 'bit-integrations'), key: 'view_item' },
181-
{ label: __('View Items', 'bit-integrations'), key: 'view_items' },
182-
{ label: __('Search Item', 'bit-integrations'), key: 'search_item' },
183-
{ label: __('Not Found', 'bit-integrations'), key: 'not_found' },
184-
{ label: __('Not Found in Trash', 'bit-integrations'), key: 'not_found_in_trash' },
185-
{ label: __('Parent Item Colon', 'bit-integrations'), key: 'parent_item_colon' },
186-
{ label: __('Featured Image', 'bit-integrations'), key: 'featured_image' },
187-
{ label: __('Set Featured Image', 'bit-integrations'), key: 'set_featured_image' },
188-
{ label: __('Remove Featured Image', 'bit-integrations'), key: 'remove_featured_image' },
189-
{ label: __('Use Featured Image', 'bit-integrations'), key: 'use_featured_image' },
190-
{ label: __('Archives', 'bit-integrations'), key: 'archives' },
191-
{ label: __('Insert into Item', 'bit-integrations'), key: 'insert_into_item' },
192-
{ label: __('Uploaded to This Item', 'bit-integrations'), key: 'uploaded_to_this_item' },
193-
{ label: __('Filter Items List', 'bit-integrations'), key: 'filter_items_list' },
194-
{ label: __('Items List Navigation', 'bit-integrations'), key: 'items_list_navigation' },
195-
{ label: __('Items List', 'bit-integrations'), key: 'items_list' },
196-
{ label: __('Filter by Date', 'bit-integrations'), key: 'filter_by_date' },
197-
{ label: __('Item Published', 'bit-integrations'), key: 'item_published' },
198-
{ label: __('Item Published Privately', 'bit-integrations'), key: 'item_published_privately' },
199-
{ label: __('Item Reverted to Draft', 'bit-integrations'), key: 'item_reverted_to_draft' },
200-
{ label: __('Item Scheduled', 'bit-integrations'), key: 'item_scheduled' },
201-
{ label: __('Item Updated', 'bit-integrations'), key: 'item_updated' }
202-
]
203-
204-
const taxonomyLabels = [
205-
{ label: __('Menu Name', 'bit-integrations'), key: 'name' },
206-
{ label: __('Singular name', 'bit-integrations'), key: 'singular_name' },
207-
{ label: __('Search Items', 'bit-integrations'), key: 'search_items' },
208-
{ label: __('Popular Items', 'bit-integrations'), key: 'popular_items' },
209-
{ label: __('All Items', 'bit-integrations'), key: 'all_items' },
210-
{ label: __('Parent Item', 'bit-integrations'), key: 'parent_item' },
211-
{ label: __('Parent Item Colon', 'bit-integrations'), key: 'parent_item_colon' },
212-
{ label: __('Edit Item', 'bit-integrations'), key: 'edit_item' },
213-
{ label: __('View Item', 'bit-integrations'), key: 'view_item' },
214-
{ label: __('Update Item', 'bit-integrations'), key: 'update_item' },
215-
{ label: __('Add New Item', 'bit-integrations'), key: 'add_new_item' },
216-
{ label: __('New Item Name', 'bit-integrations'), key: 'new_item_name' },
217-
{
218-
label: __('Separate Items With Commas', 'bit-integrations'),
219-
key: 'separate_items_with_commas'
220-
},
221-
{ label: __('Add or Remove Items', 'bit-integrations'), key: 'add_or_remove_items' },
222-
{
223-
label: __('Choose From Most Used', 'bit-integrations'),
224-
key: 'choose_from_most_used'
225-
},
226-
{ label: __('Not Found', 'bit-integrations'), key: 'not_found' },
227-
{ label: __('No Terms', 'bit-integrations'), key: 'no_terms' },
228-
{ label: __('Filter By Item', 'bit-integrations'), key: 'filter_by_item' },
229-
{
230-
label: __('Items List Navigation', 'bit-integrations'),
231-
key: 'items_list_navigation'
232-
},
233-
{ label: __('Items List', 'bit-integrations'), key: 'items_list' },
234-
{ label: __('Most Used', 'bit-integrations'), key: 'most_used' },
235-
{ label: __('Back To Items', 'bit-integrations'), key: 'back_to_items' }
236-
]
237-
238-
const taxonomyFields = [
239-
{ label: __('Slug', 'bit-integrations'), key: 'slug', required: true },
240-
{ label: __('Singular Label', 'bit-integrations'), key: 'singular_label', required: true },
241-
{ label: __('Plural Label', 'bit-integrations'), key: 'plural_label', required: true },
242-
{ label: __('REST API base slug', 'bit-integrations'), key: 'rest_base', required: false },
243-
{
244-
label: __('REST API Controller Class', 'bit-integrations'),
245-
key: 'rest_controller_class',
246-
required: false
247-
},
248-
{ label: __('Menu position', 'bit-integrations'), key: 'menu_position', required: false },
249-
{ label: __('Capability type', 'bit-integrations'), key: 'capability_type', required: false },
250-
{ label: __('Custom rewrite rules', 'bit-integrations'), key: 'custom_rewrite', required: false },
251-
{ label: __('Custom query var', 'bit-integrations'), key: 'custom_query_var', required: false },
252-
{ label: __('Default Term', 'bit-integrations'), key: 'default_term', required: false }
253-
]
254-
255-
const optionPageFields = [
256-
{ label: __('Page Title', 'bit-integrations'), key: 'pageTitle', required: true },
257-
{ label: __('Menu Title', 'bit-integrations'), key: 'menuTitle', required: true },
258-
{ label: __('Menu Slug', 'bit-integrations'), key: 'menuSlug', required: true },
259-
{ label: __('Menu Icon', 'bit-integrations'), key: 'icon', required: true },
260-
{ label: __('Menu Position', 'bit-integrations'), key: 'position', required: true },
261-
{ label: __('Capability', 'bit-integrations'), key: 'capability', required: true },
262-
{ label: __('Page Description', 'bit-integrations'), key: 'description', required: false }
263-
]

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

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import { create } from 'mutative'
33
import MultiSelect from 'react-multiple-select-dropdown-lite'
44
import 'react-multiple-select-dropdown-lite/dist/index.css'
55
import { useRecoilValue } from 'recoil'
6-
import { $btcbi } from '../../../GlobalStates'
6+
import { $actionConf, $btcbi } from '../../../GlobalStates'
77
import { __ } from '../../../Utils/i18nwrap'
88
import Loader from '../../Loaders/Loader'
99
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'
1314

1415
export default function ACPTIntegLayout({
1516
formFields,
@@ -28,8 +29,7 @@ export default function ACPTIntegLayout({
2829
setAcptConf(prevConf =>
2930
create(prevConf, draftConf => {
3031
draftConf[name] = val
31-
32-
if ((name = 'module')) {
32+
if (name == 'module') {
3333
const { cptFields, cptLabels, taxonomyFields, taxonomyLabels, optionPageFields } = draftConf
3434

3535
draftConf.acptFields = []
@@ -75,9 +75,9 @@ export default function ACPTIntegLayout({
7575
{ label: __('Dynamic Block Id', 'bit-integrations'), key: 'id', required: true }
7676
]
7777
}
78-
}
7978

80-
draftConf.field_map = generateMappedField(draftConf.acptFields)
79+
draftConf.field_map = generateMappedField(draftConf.acptFields)
80+
}
8181
})
8282
)
8383
}
@@ -88,7 +88,7 @@ export default function ACPTIntegLayout({
8888
<div className="flx">
8989
<b className="wdt-200 d-in-b">{__('Select Action:', 'bit-integrations')}</b>
9090
<MultiSelect
91-
title={'Action'}
91+
title="Action"
9292
defaultValue={acptConf?.module}
9393
className="mt-2 w-5"
9494
onChange={val => setChanges(val, 'module')}
@@ -114,6 +114,23 @@ export default function ACPTIntegLayout({
114114
/>
115115
)}
116116

117+
{acptConf?.module &&
118+
(acptConf.module === 'create_cpt' || acptConf.module === 'create_option_page') &&
119+
!isLoading && (
120+
<div className="flx">
121+
<b className="wdt-200 d-in-b">{__('Select Icon:', 'bit-integrations')}</b>
122+
<MultiSelect
123+
title="Icon"
124+
defaultValue={acptConf?.icon}
125+
className="mt-2 w-5"
126+
onChange={val => setChanges(val, 'icon')}
127+
options={cptIcons}
128+
singleSelect
129+
closeOnSelect
130+
/>
131+
</div>
132+
)}
133+
117134
{acptConf.module && (
118135
<>
119136
{!isLoading && (

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,15 @@ function EditACPT({ allIntegURL }) {
2525

2626
const saveConfig = () => {
2727
if (!checkMappedFields(acptConf)) {
28-
setSnackbar({ show: true, msg: __('Please map mandatory fields', 'bit-integrations') })
29-
return
30-
}
31-
if (acptConf.module != 'update_license' && !checkMappedFields(acptConf)) {
3228
toast.error(__('Please map mandatory fields', 'bit-integrations'))
3329
return
3430
}
3531

36-
if (acptConf.module === 'create_license' && !acptConf?.selectedStatus) {
37-
toast.error(__('Please select Status', 'bit-integrations'))
38-
return
39-
}
40-
41-
if (acptConf.module === 'update_license' && !acptConf?.selectedLicense) {
42-
toast.error(__('Please select Status', 'bit-integrations'))
32+
if (
33+
(acptConf.module === 'create_cpt' || acptConf.module === 'create_option_page') &&
34+
!acptConf?.icon
35+
) {
36+
toast.error(__('Please select Icon', 'bit-integrations'))
4337
return
4438
}
4539

0 commit comments

Comments
 (0)