import { CloudProviderConst } from 'dbaas/features/Project'

import { useSharedTiDBContext } from '../../tidb-mgmt-container/shared/tidb-context'
import { TiDBPageShell } from '../../tidb-mgmt-container/shared/TiDBPageShell'

import { Encryption } from './Encryption'
import { LogRedaction } from './LogRedaction'
import { PlanReplayerAccess } from './PlanReplayerAccess'

const SecurityPageShell = () => {
  const tidb = useSharedTiDBContext()
  const showEncryption =
    tidb.cloudProvider === CloudProviderConst.AWS || tidb.cloudProvider === CloudProviderConst.ALICLOUD

  return (
    <TiDBPageShell
      wrapperProps={{
        display: 'flex',
        h: '100%',
        sx: {
          flexDirection: 'column'
        }
      }}
      bodyProps={{
        sx: { flex: 1, minHeight: 0 }
      }}
      title="Security"
    >
      <LogRedaction tidb={tidb} />
      {showEncryption && <Encryption tidb={tidb} />}
      {(tidb.computed.isPremium || tidb.computed.isEssentialV2) && <PlanReplayerAccess tidb={tidb} />}
    </TiDBPageShell>
  )
}

export default SecurityPageShell
