Просмотр исходного кода

Home "Add new..." block: one chrome in NEO, set by the block (#5907)

* Home "Add new..." block: one chrome in NEO, from the block's settings

NEO drew its own card inside the block's design box, so the create-post
block showed a card inside a card. The composer row now sits straight in
the block, and the block's App config gives it a background and padding;
the title follows the design box (none with the content-only default).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* AGENTS.md: core's app-only SQL is under modules/system/install/sql

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Neo: conductor rows give the create-post block its design box too

BlockItemRenderer rendered system:get_create_post_form content-only,
which relied on the composer's own card. With that card gone, the block
in a conductor list (profile pages) would have no chrome; now it uses
the block's design box like every other block.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Andrey Yasko 1 день назад
Родитель
Сommit
03a61488fd

+ 1 - 1
AGENTS.md

@@ -36,7 +36,7 @@ These apply to UNA PHP (`inc/`, `modules/`, `studio/`, `template/`, and install
 - Do not call module by a literal name (`BxDolModule::getInstance('bx_posts')`, `BxDolService::call('bx_posts', ...)`, `new BxPostsModule`) without checking if module is installed `BxDolModuleQuery::getInstance()->isEnabledByName('bx_posts')`.
 - Call `getParam` only with a name that exists in `sys_options`. Declare the option in that module's install SQL before reading it.
 - Do not add or edit anything under `upgrade/files/`. That folder records past releases. Do not put new migrations there.
-- Set `active_api` in `modules/system/install/sql/enable-app-pages.sql` (page blocks) and `modules/system/install/sql/enable-app-menus.sql` (menu items) for core, for modules use `modules/boonex/*/install/sql/enable-app.sql` files. Do not set it in `install.sql`, `enable.sql`, or other common install and enable scripts.
+- Set `active_api` in `modules/system/install/sql/enable-app-pages.sql` (page blocks, including their `config_api`) and `modules/system/install/sql/enable-app-menus.sql` (menu items) for core, for modules use `modules/boonex/*/install/sql/enable-app.sql` files. Do not set it in `install.sql`, `enable.sql`, or other common install and enable scripts.
 
 ## Studio app icons
 

+ 1 - 0
modules/system/install/sql/enable-app-pages.sql

@@ -13,6 +13,7 @@ UPDATE `sys_pages_blocks` SET `config_api`='{\r\n\"content_type\": \"browse_simp
 UPDATE `sys_pages_blocks` SET `config_api`='{\r\n\"content_type\": \"browse_simple\", \r\n\"header_more_url\": \"/follow-suggestions\", \r\n\"header_more_text\": \"View All\"\r\n}' WHERE `object`='sys_home' AND `module`='system' AND `title_system`='_sys_page_block_title_sys_recom_subscriptions';
 UPDATE `sys_pages_blocks` SET `config_api`='{\"rounded\": true}' WHERE `object`='sys_home' AND `module`='system' AND `title_system`='_sys_page_block_system_title_login';
 UPDATE `sys_pages_blocks` SET `config_api`='{\r\n\"content_type\":\"browse_simple\", \r\n\"header_more_url\": \"/context-invitations\", \r\n\"header_more_text\": \"View All\"\r\n}' WHERE `object`='sys_home' AND `module`='system' AND `title_system`='_sys_page_block_title_sys_invitations';
+UPDATE `sys_pages_blocks` SET `config_api`='{"designbox": {"bg": true, "padding": true}}' WHERE `object`='sys_home' AND `module`='system' AND `title_system`='_sys_page_block_title_sys_create_post';
 
 -- 'active_api' switch
 UPDATE `sys_pages_blocks` SET `active_api`=1 WHERE `object`='sys_home' AND `module`='system' AND `title`='_sys_page_block_title_create_account';

+ 4 - 3
neo/packages/app/components/elements/multi-post-form.js

@@ -6,7 +6,6 @@ import { useWindowDimensions } from 'react-native'
 import { menuItemsByNameNew, cloneObject, getBreakpoint, isWeb } from 'app/lib/util'
 import { useCurrentUser } from 'app/context/user'
 import Profile from 'app/ui/molecules/profile/profile'
-import { CardList } from 'app/ui/molecules/page/card'
 import { useTranslation } from 'react-i18next'
 import FormModal, { handleFormModal, getFormModal } from 'app/ui/molecules/dialogs/form-modal';
 import { BlockWrapper } from 'app/components/block-wrapper'
@@ -122,7 +121,9 @@ export default function MultiPostForm({ data, blockWrapperProps, trigger_label:
 
     return (
         <BlockWrapper {...blockWrapperProps}>
-            <CardList className="flex-row items-center gap-3 min-w-0">
+            {/* One row straight in the block: its chrome (background, padding, title) is the
+                block's design box, so no card of its own. */}
+            <Row className="items-center gap-3 min-w-0">
                 <View className="flex-none">
                     <Profile {...profileData} displaySize="base" displayType="unit_wo_info" />
                 </View>
@@ -162,7 +163,7 @@ export default function MultiPostForm({ data, blockWrapperProps, trigger_label:
                     ))}
                 </Row>}
 
-            </CardList>
+            </Row>
         </BlockWrapper>
 
     )

+ 0 - 1
neo/packages/app/components/item-renderer.js

@@ -36,7 +36,6 @@ export function BlockItemRenderer({ route, item, sidebar }) {
     const block = BlockByName2({ 
         b: item.data, 
         name: item.block, 
-        contentOnly:item?.data?.source == "system:get_create_post_form",
         fill: fillViewport,
         extraProps: {
             pageTitle: route?.title,

+ 12 - 0
tests/units/install/SystemSqlDefaultsTest.php

@@ -24,6 +24,18 @@ class SystemSqlDefaultsTest extends \PHPUnit\Framework\TestCase
         $this->assertSame(0, (int)$aMatch[1], 'It shows only its form: the content-only design box (BX_DB_CONTENT_ONLY).');
     }
 
+    public function testHomeCreatePostBlockHasBackgroundInApp(): void
+    {
+        // NEO draws the composer row straight in the block, so the block's App config gives it a background
+        // and padding there. The title is left to the design box (none with the content-only one).
+        $sSql = file_get_contents(__DIR__ . '/../../../modules/system/install/sql/enable-app-pages.sql');
+        $bFound = preg_match("/UPDATE `sys_pages_blocks` SET `config_api`='([^']*)' WHERE `object`='sys_home' AND `module`='system' AND `title_system`='_sys_page_block_title_sys_create_post';/", (string)$sSql, $aMatch);
+
+        $this->assertSame(1, $bFound, 'enable-app-pages.sql sets the App config of the home create-post block.');
+        $aConfig = json_decode($aMatch[1], true);
+        $this->assertSame(['bg' => true, 'padding' => true], $aConfig['designbox'] ?? null, 'Background and padding on every tier, title from the design box.');
+    }
+
     public function testPoweredByBadgeFollowsTheFooterColour(): void
     {
         $bFound = preg_match("/\\('sys_footer', 'system', 'powered_by', [^\\n]*?'_blank', '(<svg.*?<\\/svg>)'/", self::systemSql(), $aMatch);