非管理员隐藏头部
This commit is contained in:
@@ -3,12 +3,19 @@ import React, { useState } from 'react'
|
||||
import { usePathname } from 'next/navigation'
|
||||
import s from './index.module.css'
|
||||
import { useEventEmitterContextContext } from '@/context/event-emitter'
|
||||
import { useSelector } from '@/context/app-context'
|
||||
import classNames from '@/utils/classnames'
|
||||
|
||||
type HeaderWrapperProps = {
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
/**
|
||||
* HeaderWrapper
|
||||
* 负责包裹并渲染全局头部区域。
|
||||
* - 在工作流画布最大化时隐藏头部
|
||||
* - 当当前用户非管理员(owner/admin 之外)时隐藏头部(不区分是否在 iframe)
|
||||
*/
|
||||
const HeaderWrapper = ({
|
||||
children,
|
||||
}: HeaderWrapperProps) => {
|
||||
@@ -20,6 +27,7 @@ const HeaderWrapper = ({
|
||||
const workflowCanvasMaximize = localStorage.getItem('workflow-canvas-maximize') === 'true'
|
||||
const [hideHeader, setHideHeader] = useState(workflowCanvasMaximize)
|
||||
const { eventEmitter } = useEventEmitterContextContext()
|
||||
const isCurrentWorkspaceManager = useSelector(s => s.isCurrentWorkspaceManager)
|
||||
|
||||
eventEmitter?.useSubscription((v: any) => {
|
||||
if (v?.type === 'workflow-canvas-maximize')
|
||||
@@ -29,9 +37,10 @@ const HeaderWrapper = ({
|
||||
return (
|
||||
<div className={classNames(
|
||||
'sticky left-0 right-0 top-0 z-[30] flex min-h-[56px] shrink-0 grow-0 basis-auto flex-col',
|
||||
'app-global-header',
|
||||
s.header,
|
||||
isBordered ? 'border-b border-divider-regular' : '',
|
||||
hideHeader && (inWorkflowCanvas || isPipelineCanvas) && 'hidden',
|
||||
((!isCurrentWorkspaceManager) || (hideHeader && (inWorkflowCanvas || isPipelineCanvas))) && 'hidden',
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
|
||||
Reference in New Issue
Block a user