RomanL 1 день назад
Родитель
Сommit
19c8900d28

+ 14 - 6
neo/packages/app/components/elements/entity-cover.js

@@ -2,21 +2,29 @@ import { View } from 'app/design/view';
 import Image from 'app/ui/atoms/image';
 import { Text } from 'app/design/typography';
 import { CoverMenuMeta, CoverMenu } from 'app/components/elements/covers/menu-cover';
-import { stripTags } from 'app/lib/util'
+import { appSetting, stripTags } from 'app/lib/util'
 import { BlockWrapper } from 'app/components/block-wrapper'
 
-export default function ({ data, blockWrapperProps, uri }) {
+export default function ({ data, block, blockWrapperProps, uri }) {
+    const moduleName = data?.profile?.module || block?.module
+    // Same rule as the page cover: a round picture is for persons and for
+    // modules that opt in via cover.show_pic_by_module. Contexts (groups, …) skip it.
+    const showPicture = moduleName === 'bx_persons'
+        || (!!moduleName && !!appSetting('cover', 'show_pic_by_module', moduleName))
+    // Page cover title: profile.display_name, then profile.title.
+    const profileTitle = data?.profile?.display_name || data?.profile?.title || ''
+
     return (
         <BlockWrapper {...blockWrapperProps}>
-            {!!data.cover && <View className="w-full h-28 ">
-                <Image alt={data.fullname} view="cover" src={data.cover.src} priority />
+            {!!data.cover && <View className="w-full h-28 overflow-hidden rounded-t-2xl">
+                <Image alt={profileTitle} view="cover" src={data.cover.src} priority />
             </View>}
             <View className="p-4 w-full mx-auto bg-card h-min overflow-hidden rounded-2xl shadow-sm">
-                {!!data.image && <View className="w-28 h-28 overflow-hidden bg-background   rounded-full  "><Image alt={data.fullname} className="rounded-full" view="cover" src={data.image.src} priority={!data.cover} /></View>}
+                {showPicture && !!data.image?.src && <View className="w-28 h-28 overflow-hidden bg-background   rounded-full  "><Image alt={profileTitle} className="rounded-full" view="cover" src={data.image.src} priority={!data.cover} /></View>}
                 <View className="flex-row flex-wrap ">
                     <View className=" flex-auto">
                         <Text className="text-2xl pt-4 font-bold text-secondary-foreground ">
-                            {data.fullname || data.space_name || data.name}
+                            {profileTitle}
                         </Text>
 
                     </View>

+ 4 - 12
neo/packages/app/ui/molecules/sections/conductor/helpers.js

@@ -737,12 +737,6 @@ function mapLayoutBlocks(items = [], { browseAsBlocks = false } = {}) {
     return { content, endpoint: payload && designbox ? { ...payload, designbox } : payload }
 }
 
-/** Block whose content is an entity cover (`entity_cover` element). */
-function isEntityCoverBlock(item) {
-    return Array.isArray(item?.content)
-        && item.content.some((entry) => entry?.type === 'entity_cover')
-}
-
 /**
  * Build content/endpoint/sidebar/leftbar from layout_parsed page data.
  *
@@ -751,17 +745,15 @@ function isEntityCoverBlock(item) {
  * the list (marked `afterList`, see buildConductorListRows). The list is the
  * center's browse block; the top's or the bottom's only when the center has
  * none (the person profile keeps its timeline in the top area).
+ *
+ * An `entity_cover` block stays in its cell. The page header cover is a
+ * separate payload, `cover_block`, and does not replace this block.
  */
 function processParsedUrl(data) {
     const elements = data?.elements || {}
-    // A profile page's cover comes from `cover_block` (the Conductor header);
-    // an entity cover block in any cell would draw it a second time.
     const cell = (name, options) => {
         const items = Array.isArray(elements[name]) ? elements[name] : []
-        return mapLayoutBlocks(
-            data?.cover_block?.profile ? items.filter((item) => !isEntityCoverBlock(item)) : items,
-            options
-        )
+        return mapLayoutBlocks(items, options)
     }
     const cellTop = cell('cell_top')
     const cellCenter = cell('cell_center')