From 959c687da5bd17d82daec13105aa4ad3967ef147 Mon Sep 17 00:00:00 2001 From: Alquen Sarmiento Date: Mon, 18 Aug 2025 15:13:05 +0800 Subject: [PATCH 1/4] fix: use the translated roles from editorRoles for the search tree --- src/welcome/admin.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/welcome/admin.js b/src/welcome/admin.js index 63ee636319..2dd1b3f691 100644 --- a/src/welcome/admin.js +++ b/src/welcome/admin.js @@ -29,6 +29,7 @@ import { isPro, v2disabledBlocks, defaultBreakpoints, + editorRoles, } from 'stackable' import classnames from 'classnames' import { fetchSettings, importBlocks } from '~stackable/util/admin' @@ -167,12 +168,7 @@ const SEARCH_TREE = [ { id: 'role-manager', children: [ - __( 'Role Manager', i18n ), - __( 'Administrator', i18n ), - __( 'Editor', i18n ), - __( 'Author', i18n ), - __( 'Contributor', i18n ), - __( 'Subscriber', i18n ), + ...Object.values( editorRoles ), ], }, ], @@ -185,11 +181,7 @@ const SEARCH_TREE = [ id: 'custom-fields-settings', children: [ __( 'Custom Fields', i18n ), - __( 'Administrator', i18n ), - __( 'Editor', i18n ), - __( 'Author', i18n ), - __( 'Contributor', i18n ), - __( 'Subscriber', i18n ), + ...Object.values( editorRoles ), ], }, ], From abbe6340f49d484d87595e98778fedbba1bc70ee Mon Sep 17 00:00:00 2001 From: Alquen Sarmiento Date: Mon, 18 Aug 2025 21:04:46 +0800 Subject: [PATCH 2/4] fix: add the previous values as fallback --- src/welcome/admin.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/welcome/admin.js b/src/welcome/admin.js index 2dd1b3f691..2a49b8e7af 100644 --- a/src/welcome/admin.js +++ b/src/welcome/admin.js @@ -167,9 +167,17 @@ const SEARCH_TREE = [ groups: [ { id: 'role-manager', - children: [ - ...Object.values( editorRoles ), - ], + children: ( editorRoles + ? Object.values( editorRoles ) + : [ + __( 'Role Manager', i18n ), + __( 'Administrator', i18n ), + __( 'Editor', i18n ), + __( 'Author', i18n ), + __( 'Contributor', i18n ), + __( 'Subscriber', i18n ), + ] + ), }, ], }, @@ -181,7 +189,17 @@ const SEARCH_TREE = [ id: 'custom-fields-settings', children: [ __( 'Custom Fields', i18n ), - ...Object.values( editorRoles ), + ...( editorRoles + ? Object.values( editorRoles ) + : [ + __( 'Role Manager', i18n ), + __( 'Administrator', i18n ), + __( 'Editor', i18n ), + __( 'Author', i18n ), + __( 'Contributor', i18n ), + __( 'Subscriber', i18n ), + ] + ), ], }, ], From 57aa761a825190e44565704665115f4576404a32 Mon Sep 17 00:00:00 2001 From: Alquen Sarmiento Date: Wed, 20 Aug 2025 10:58:29 +0800 Subject: [PATCH 3/4] fix: do not search if current search string is empty --- src/welcome/admin.js | 77 +++++++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 37 deletions(-) diff --git a/src/welcome/admin.js b/src/welcome/admin.js index 2a49b8e7af..3ada907954 100644 --- a/src/welcome/admin.js +++ b/src/welcome/admin.js @@ -588,13 +588,13 @@ const Settings = () => { }, [ hasUnsavedChanges ] ) const filteredSearchTree = useMemo( () => { - if ( ! currentSearch ) { - return SEARCH_TREE - } const loweredSearch = currentSearch.toLowerCase() return SEARCH_TREE.map( tabs => { const filtedGroups = tabs.groups.map( group => { + if ( ! currentSearch ) { + return { ...group, children: null } + } const filteredChildren = group.children.filter( child => { return child.toLowerCase().includes( loweredSearch.toLowerCase() ) } ) @@ -607,6 +607,7 @@ const Settings = () => { const props = { settings, handleSettingsChange, + currentSearch, filteredSearchTree, currentTab, isFetching, @@ -653,15 +654,15 @@ const EditorSettings = props => { const editor = groups.find( group => group.id === 'editor' ) const toolbar = groups.find( group => group.id === 'toolbar' ) const inspector = groups.find( group => group.id === 'inspector' ) - const groupLength = groups.reduce( ( acc, curr ) => acc + curr.children.length, 0 ) + const hasGroupMatch = groups.some( group => group.children === null || group.children.length > 0 ) return (
- { groupLength <= 0 ? ( + { ! hasGroupMatch ? (

{ __( 'No matching settings', i18n ) }

) : ( <> - { blocks.children.length > 0 && + { ( blocks.children === null || blocks.children.length > 0 ) &&

{ __( 'Block Widths', i18n ) }

{ __( 'Adjust the width of Stackable blocks here.', i18n ) }

@@ -687,7 +688,7 @@ const EditorSettings = props => { />
} - { editor.children.length > 0 && + { ( editor.children === null || editor.children.length > 0 ) &&

{ __( 'Editor', i18n ) }

{ __( 'You can customize some of the features and behavior of Stackable in the editor here.', i18n ) }

@@ -746,7 +747,7 @@ const EditorSettings = props => { />
} - { toolbar.children.length > 0 && + { ( toolbar.children === null || toolbar.children.length > 0 ) &&

{ __( 'Toolbar', i18n ) }

{ __( 'You can disable some toolbar features here.', i18n ) }

@@ -797,7 +798,7 @@ const EditorSettings = props => { /> }
} - { inspector.children.length > 0 && + { ( inspector.children === null || inspector.children.length > 0 ) &&

{ __( 'Inspector', i18n ) }

{ __( 'You can customize some of the features and behavior of Stackable in the inspector here.', i18n ) }

@@ -836,15 +837,15 @@ const Responsiveness = props => { const groups = filteredSearchTree.find( tab => tab.id === 'responsiveness' ).groups const dynamicBreakpoints = groups.find( group => group.id === 'dynamic-breakpoints' ) - const groupLength = groups.reduce( ( acc, curr ) => acc + curr.children.length, 0 ) + const hasGroupMatch = groups.some( group => group.children === null || group.children.length > 0 ) return (
- { groupLength <= 0 ? ( + { ! hasGroupMatch ? (

{ __( 'No matching settings', i18n ) }

) : ( <> - { dynamicBreakpoints.children.length > 0 && + { ( dynamicBreakpoints.children === null || dynamicBreakpoints.children.length > 0 ) &&

{ __( 'Dynamic Breakpoints', i18n ) }

@@ -908,7 +909,7 @@ const Blocks = props => { } ) const DERIVED_BLOCKS = getAllBlocks() const groups = filteredSearchTree.find( tab => tab.id === 'blocks' ).groups - const groupLength = groups.reduce( ( acc, curr ) => acc + curr.children.length, 0 ) + const hasGroupMatch = groups.some( group => group.children === null || group.children.length > 0 ) const disabledBlocks = settings.stackable_block_states ?? {} // eslint-disable-line camelcase const [ isDisabledDialogOpen, setIsDisabledDialogOpen ] = useState( false ) @@ -1089,7 +1090,7 @@ const Blocks = props => { ) }

- { groupLength <= 0 ? ( + { ! hasGroupMatch ? (

{ __( 'No matching settings', i18n ) }

) : (
@@ -1108,7 +1109,7 @@ const Blocks = props => { `s-box-block__title--${ id }`, ] ) const group = groups.find( group => group.id === id ) - return group.children.length > 0 && ( + return ( group.children === null || group.children.length > 0 ) && (

{ Icon && } @@ -1175,15 +1176,15 @@ const Optimizations = props => { const groups = filteredSearchTree.find( tab => tab.id === 'optimizations' ).groups const optimizations = groups.find( group => group.id === 'optimizations' ) - const groupLength = groups.reduce( ( acc, curr ) => acc + curr.children.length, 0 ) + const hasGroupMatch = groups.some( group => group.children === null || group.children.length > 0 ) return (
- { groupLength <= 0 ? ( + { ! hasGroupMatch ? (

{ __( 'No matching settings', i18n ) }

) : ( <> - { optimizations.children.length > 0 && + { ( optimizations.children === null || optimizations.children.length > 0 ) &&

{ __( 'Optimizations', i18n ) }

{ __( 'Here you can adjust some optimization settings that are performed by Stackable.', i18n ) }

@@ -1216,15 +1217,15 @@ const Optimizations = props => { const GlobalSettings = props => { const groups = props.filteredSearchTree.find( tab => tab.id === 'global-settings' ).groups const globalSettings = groups.find( group => group.id === 'global-settings' ) - const groupLength = groups.reduce( ( acc, curr ) => acc + curr.children.length, 0 ) + const hasGroupMatch = groups.some( group => group.children === null || group.children.length > 0 ) return (
- { groupLength <= 0 ? ( + { ! hasGroupMatch ? (

{ __( 'No matching settings', i18n ) }

) : ( <> - { globalSettings.children.length > 0 && + { ( globalSettings.children === null || globalSettings.children.length > 0 ) &&

{ __( 'Global Settings', i18n ) }

{ __( 'Here you can tweak Global Settings that affect the styles across your entire site.', i18n ) }

@@ -1248,7 +1249,7 @@ const GlobalSettings = props => { const RoleManager = props => { const groups = props.filteredSearchTree.find( tab => tab.id === 'role-manager' ).groups - const groupLength = groups.reduce( ( acc, curr ) => acc + curr.children.length, 0 ) + const hasGroupMatch = groups.some( group => group.children === null || group.children.length > 0 ) const propsToPass = { ...props, roleManager: groups.find( group => group.id === 'role-manager' ), @@ -1258,11 +1259,11 @@ const RoleManager = props => { return (
- { groupLength <= 0 ? ( + { ! hasGroupMatch ? (

{ __( 'No matching settings', i18n ) }

) : ( <> - { propsToPass.roleManager.children.length > 0 && + { ( propsToPass.roleManager.children === null || propsToPass.roleManager.children.length > 0 ) &&

{ __( 'Role Manager', i18n ) }

@@ -1300,7 +1301,7 @@ const RoleManager = props => { const CustomFields = props => { const groups = props.filteredSearchTree.find( tab => tab.id === 'custom-fields-settings' ).groups - const groupLength = groups.reduce( ( acc, curr ) => acc + curr.children.length, 0 ) + const hasGroupMatch = groups.some( group => group.children === null || group.children.length > 0 ) const propsToPass = { ...props, customFields: groups.find( group => group.id === 'custom-fields-settings' ), @@ -1311,11 +1312,11 @@ const CustomFields = props => { return (

- { groupLength <= 0 ? ( + { ! hasGroupMatch ? (

{ __( 'No matching settings', i18n ) }

) : ( <> - { propsToPass.customFields.children.length > 0 && + { ( propsToPass.customFields.children === null || propsToPass.customFields.children.length > 0 ) &&

{ __( 'Custom Fields', i18n ) }

@@ -1362,7 +1363,7 @@ const Integrations = props => { } = props const groups = filteredSearchTree.find( tab => tab.id === 'integrations' ).groups - const groupLength = groups.reduce( ( acc, curr ) => acc + curr.children.length, 0 ) + const hasGroupMatch = groups.some( group => group.children === null || group.children.length > 0 ) const propsToPass = { ...props, integrations: groups.find( group => group.id === 'integrations' ), @@ -1372,11 +1373,11 @@ const Integrations = props => { return (
- { groupLength <= 0 ? ( + { ! hasGroupMatch ? (

{ __( 'No matching settings', i18n ) }

) : ( <> - { propsToPass.integrations.children.length > 0 && + { ( propsToPass.integrations.children === null || propsToPass.integrations.children.length > 0 ) &&

{ __( 'Integrations', i18n ) }

{ __( 'Here are settings for the different integrations available in Stackable.', i18n ) }

@@ -1469,19 +1470,21 @@ const AdditionalOptions = props => { const groups = filteredSearchTree.find( tab => tab.id === 'other-settings' ).groups const miscellaneous = groups.find( group => group.id === 'miscellaneous' ) const migrationSettings = groups.find( group => group.id === 'migration-settings' ) - const groupLength = groups.reduce( ( acc, curr ) => acc + curr.children.length, 0 ) + const hasGroupMatch = groups.some( group => group.children === null || group.children.length > 0 ) const searchClassname = ( label, searchedSettings ) => { - return searchedSettings.children.includes( label ) ? '' : 'ugb-admin-setting--not-highlight' + return searchedSettings.children === null || searchedSettings.children.includes( label ) + ? '' + : 'ugb-admin-setting--not-highlight' } return (
- { groupLength <= 0 ? ( + { ! hasGroupMatch ? (

{ __( 'No matching settings', i18n ) }

) : ( <> - { miscellaneous.children.length > 0 && + { ( miscellaneous.children === null || miscellaneous.children.length > 0 ) &&

{ __( 'Miscellaneous', i18n ) }

{ __( 'Below are other minor settings. Some may be useful when upgrading from older versions of Stackable.', i18n ) }

@@ -1538,7 +1541,7 @@ const AdditionalOptions = props => { />
} - { migrationSettings.children.length > 0 && + { ( migrationSettings.children === null || migrationSettings.children.length > 0 ) &&

{ __( 'Migration Settings', i18n ) }

{ __( 'After enabling the version 2 blocks, please refresh the page to re-fetch the blocks from the server.', i18n ) }

@@ -1602,7 +1605,7 @@ const V2Settings = props => { return (
- { optimizations.children.length > 0 && + { ( optimizations.children === null || optimizations.children.length > 0 ) &&

{ __( '🏃‍♂️ Optimization Settings', i18n ) } (V2)

@@ -1614,7 +1617,7 @@ const V2Settings = props => {

} - { blocks.children.length > 0 && + { ( blocks.children === null || blocks.children.length > 0 ) &&

{ __( 'Enable & Disable Blocks', i18n ) } (V2)

{ __( 'This only works for version 2 blocks.', i18n ) } From 4afe14b859fb7c1bb7ea91ec7975a738bc8e20b4 Mon Sep 17 00:00:00 2001 From: Alquen Sarmiento Date: Wed, 20 Aug 2025 12:23:00 +0800 Subject: [PATCH 4/4] fix: remove fallback --- src/welcome/admin.js | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/src/welcome/admin.js b/src/welcome/admin.js index 3ada907954..6a8a079b06 100644 --- a/src/welcome/admin.js +++ b/src/welcome/admin.js @@ -167,17 +167,7 @@ const SEARCH_TREE = [ groups: [ { id: 'role-manager', - children: ( editorRoles - ? Object.values( editorRoles ) - : [ - __( 'Role Manager', i18n ), - __( 'Administrator', i18n ), - __( 'Editor', i18n ), - __( 'Author', i18n ), - __( 'Contributor', i18n ), - __( 'Subscriber', i18n ), - ] - ), + children: Object.values( editorRoles || {} ), }, ], }, @@ -189,17 +179,7 @@ const SEARCH_TREE = [ id: 'custom-fields-settings', children: [ __( 'Custom Fields', i18n ), - ...( editorRoles - ? Object.values( editorRoles ) - : [ - __( 'Role Manager', i18n ), - __( 'Administrator', i18n ), - __( 'Editor', i18n ), - __( 'Author', i18n ), - __( 'Contributor', i18n ), - __( 'Subscriber', i18n ), - ] - ), + ...Object.values( editorRoles || {} ), ], }, ],