7.5.2. OpenShift Container Platform 控制台 API


useActivePerspective

提供用于设置活跃视角的 hook,以及用于设置活跃视角的回调。它返回一个包含当前活跃视角和 setter 回调的元组。

Example

const Component: React.FC = (props) => {
   const [activePerspective, setActivePerspective] = useActivePerspective();
   return <select
     value={activePerspective}
     onChange={(e) => setActivePerspective(e.target.value)}
   >
     {
       // ...perspective options
     }
   </select>
}

GreenCheckCircleIcon

显示绿色勾号图标的组件。

Example

<GreenCheckCircleIcon title="Healthy" />

Expand
参数名称描述

className

(可选)组件的额外类名称

title

(可选)图标标题

size

(可选)图标大小:(sm,md,lg,xl)

RedExclamationCircleIcon

用于显示感叹号圆圈图标的组件。

Example

<RedExclamationCircleIcon title="Failed" />

Expand
参数名称描述

className

(可选)组件的额外类名称

title

(可选)图标标题

size

(可选)图标大小:(sm,md,lg,xl)

YellowExclamationTriangleIcon

用于显示一个黄色三角形感叹号图标的组件。

Example

<YellowExclamationTriangleIcon title="Warning" />

Expand
参数名称描述

className

(可选)组件的额外类名称

title

(可选)图标标题

size

(可选)图标大小:(sm,md,lg,xl)

BlueInfoCircleIcon

用于显示信息的蓝色圆圈图标的组件。

Example

<BlueInfoCircleIcon title="Info" />

Expand
参数名称描述

className

(可选)组件的额外类名称

title

(可选)图标标题

size

(可选)图标大小:('sm', 'md', 'lg', 'xl')

ErrorStatus

用于显示错误状态弹出的组件。

Example

<ErrorStatus title={errorMsg} />

Expand
参数名称描述

title

(可选)状态文本

iconOnly

(可选)如果为 true,则仅显示图标

noTooltip

(可选)如果为 true,则不会显示工具提示

className

(可选)组件的额外类名称

popoverTitle

(可选)弹出的标题

InfoStatus

用于显示信息状态弹出窗口的组件。

Example

<InfoStatus title={infoMsg} />

Expand
参数名称描述

title

(可选)状态文本

iconOnly

(可选)如果为 true,则仅显示图标

noTooltip

(可选)如果为 true,则不会显示工具提示

className

(可选)组件的额外类名称

popoverTitle

(可选)弹出的标题

ProgressStatus

显示进度状态弹出的组件。

Example

<ProgressStatus title={progressMsg} />

Expand
参数名称描述

title

(可选)状态文本

iconOnly

(可选)如果为 true,则仅显示图标

noTooltip

(可选)如果为 true,则不会显示工具提示

className

(可选)组件的额外类名称

popoverTitle

(可选)弹出的标题

SuccessStatus

用于显示成功状态弹出窗口的组件。

Example

<SuccessStatus title={successMsg} />

Expand
参数名称描述

title

(可选)状态文本

iconOnly

(可选)如果为 true,则仅显示图标

noTooltip

(可选)如果为 true,则不会显示工具提示

className

(可选)组件的额外类名称

popoverTitle

(可选)弹出的标题

checkAccess

提供有关用户对给定资源的访问权限的信息。它返回一个具有资源访问信息的对象。

Expand
参数名称描述

resourceAttributes

访问查看的资源属性

impersonate

模拟详情

useAccessReview

hook,提供有关用户对给定资源的访问权限的信息。它返回一个带有 isAllowedloading 值的数组。

Expand
参数名称描述

resourceAttributes

访问查看的资源属性

impersonate

模拟详情

useResolvedExtensions

使用已解析的 CodeRef 属性为消耗控制台扩展做出反应 hook。此 hook 接受与 useExtensions hook 相同的参数,并返回自适应扩展实例列表,从而解析每个扩展属性中的所有代码引用。

最初,hook 返回一个空数组。完成解析后,React 组件将重新渲染,使用 hook 返回已修改的扩展列表。当匹配扩展列表更改时,会重启解析。hook 将继续返回前面的结果,直到解析完成为止。

hook 结果元素保证在重新方之间保持稳定。它返回一个包含已解析代码引用的自适应扩展实例列表的元组、指示解析是否完成的布尔值标志,以及在解析过程中检测到的错误列表。

Example

const [navItemExtensions, navItemsResolved] = useResolvedExtensions<NavItem>(isNavItem);
// process adapted extensions and render your component

Expand
参数名称描述

typeGuards

每个接受动态插件扩展作为参数的回调列表,并返回布尔值标记,指示扩展是否满足所需的类型限制

HorizontalNav

为页面创建导航栏的组件。路由作为组件的一部分进行处理。console.tab/horizontalNav 可用于向任何横向导航中添加额外的内容。

Example

const HomePage: React.FC = (props) => {
    const page = {
      href: '/home',
      name: 'Home',
      component: () => <>Home</>
    }
    return <HorizontalNav match={props.match} pages={[page]} />
}

Expand
参数名称描述

resource

与这个 Navigation 关联的资源,对象为 K8sResourceCommon 类型

pages

页面对象数组

match

匹配 React Router 提供的对象

VirtualizedTable

创建虚拟化表的组件。

Example

const MachineList: React.FC<MachineListProps> = (props) => {
  return (
    <VirtualizedTable<MachineKind>
     {...props}
     aria-label='Machines'
     columns={getMachineColumns}
     Row={getMachineTableRow}
    />
  );
}

Expand
参数名称描述

data

表的数据

loaded

表示数据已加载的标记

loadError

如果问题载入数据,则错误对象

columns

列设置

Row

行设置

unfilteredData

没有过滤器的原始数据

NoDataEmptyMsg

(可选)没有数据空消息组件

EmptyMsg

(可选)空消息组件

scrollNode

(可选)处理滚动的功能

label

(可选)表的标签

ariaLabel

(可选)aria 标签

gridBreakPoint

调整用于响应的网格如何分隔

onSelect

(可选)处理表选择的功能

rowData

(可选)特定于行的数据

TableData

用于在表行中显示表数据的组件。

Example

const PodRow: React.FC<RowProps<K8sResourceCommon>> = ({ obj, activeColumnIDs }) => {
  return (
    <>
      <TableData id={columns[0].id} activeColumnIDs={activeColumnIDs}>
        <ResourceLink kind="Pod" name={obj.metadata.name} namespace={obj.metadata.namespace} />
      </TableData>
      <TableData id={columns[1].id} activeColumnIDs={activeColumnIDs}>
        <ResourceLink kind="Namespace" name={obj.metadata.namespace} />
      </TableData>
    </>
  );
};

Expand
参数名称描述

id

表的唯一 ID

activeColumnIDs

active 列

className

(可选) 风格的选项类名称

useActiveColumns

一个 hook,它提供了用户选择的 active TableColumns 列表。

Example

// See implementation for more details on TableColumn type
  const [activeColumns, userSettingsLoaded] = useActiveColumns({
    columns,
    showNamespaceOverride: false,
    columnManagementID,
  });
  return userSettingsAreLoaded ? <VirtualizedTable columns={activeColumns} {...otherProps} /> : null

Expand
参数名称描述

options

哪些作为键-值映射传递

\{TableColumn[]} options.columns

所有可用 TableColumns 的数组

{boolean} [options.showNamespaceOverride]

(可选)如果为 true,则会包括命名空间列,无论列管理选择是什么

{string} [options.columnManagementID]

(可选)用于保留和检索列管理选择的唯一 ID,并从用户设置中保留和检索列管理选择。通常,一个资源的 group/version/kind (GVK) 字符串。

包含当前用户所选活跃列(options.columns 的子集)和布尔值标志,指示用户设置是否已加载。

ListPageHeader

用于生成页面标头的组件。

Example

const exampleList: React.FC = () => {
  return (
    <>
      <ListPageHeader title="Example List Page"/>
    </>
  );
};

Expand
参数名称描述

title

头标题

helpText

(可选) help 部分作为响应节点

badge

(可选)作为响应节点的徽标图标

ListPageCreate

用于为特定资源类型添加创建按钮的组件,它们会自动为该资源创建 YAML 生成链接。

Example

const exampleList: React.FC<MyProps> = () => {
  return (
    <>
      <ListPageHeader title="Example Pod List Page"/>
        <ListPageCreate groupVersionKind="Pod">Create Pod</ListPageCreate>
      </ListPageHeader>
    </>
  );
};

Expand
参数名称描述

groupVersionKind

要代表的资源组/版本/类型

用于创建样式链接的组件。

Example

const exampleList: React.FC<MyProps> = () => {
 return (
  <>
   <ListPageHeader title="Example Pod List Page"/>
      <ListPageCreateLink to={'/link/to/my/page'}>Create Item</ListPageCreateLink>
   </ListPageHeader>
  </>
 );
};

Expand
参数名称描述

链接应连接到的字符串位置

createAccessReview

(可选)用于决定访问的命名空间和 kind 的对象

children

(可选)组件的子项

ListPageCreateButton

创建按钮的组件。

Example

const exampleList: React.FC<MyProps> = () => {
  return (
    <>
      <ListPageHeader title="Example Pod List Page"/>
        <ListPageCreateButton createAccessReview={access}>Create Pod</ListPageCreateButton>
      </ListPageHeader>
    </>
  );
};

Expand
参数名称描述

createAccessReview

(可选)用于决定访问的命名空间和 kind 的对象

pfButtonProps

(可选) Patternfly Button props

ListPageCreateDropdown

创建权限检查嵌套的下拉菜单的组件。

Example

const exampleList: React.FC<MyProps> = () => {
  const items = {
    SAVE: 'Save',
    DELETE: 'Delete',
  }
  return (
    <>
     <ListPageHeader title="Example Pod List Page"/>
       <ListPageCreateDropdown createAccessReview={access} items={items}>Actions</ListPageCreateDropdown>
     </ListPageHeader>
    </>
  );
};

Expand
参数名称描述

items

Key:ReactNode 对,以便在组件下拉列表中显示

onClick

点下拉菜单项目的回调功能

createAccessReview

(可选)用于决定访问的命名空间和 kind 的对象

children

(可选)下拉菜单的子项

ListPageFilter

为列表页面生成过滤器的组件。

Example

  // See implementation for more details on RowFilter and FilterValue types
  const [staticData, filteredData, onFilterChange] = useListPageFilter(
    data,
    rowFilters,
    staticFilters,
  );
  // ListPageFilter updates filter state based on user interaction and resulting filtered data can be rendered in an independent component.
  return (
    <>
      <ListPageHeader .../>
      <ListPagBody>
        <ListPageFilter data={staticData} onFilterChange={onFilterChange} />
        <List data={filteredData} />
      </ListPageBody>
    </>
  )

Expand
参数名称描述

data

一个数据点的数组

loaded

表示数据已加载

onFilterChange

更新过滤器时的回调功能

rowFilters

(可选)定义可用过滤器选项的 RowFilter 元素的数组

nameFilterPlaceholder

(可选)名称过滤器的占位符

labelFilterPlaceholder

(可选)标签过滤器的占位符

hideLabelFilter

(可选)仅显示 name 过滤器,而不是 name 和 label 过滤器

hideNameLabelFilter

(可选)隐藏 name 和 label filter

columnLayout

(可选)列布局对象

hideColumnManagement

(可选)隐藏列管理的标记

useListPageFilter

管理 ListPageFilter 组件的过滤器状态的 hook。它返回一个 tuple,其中包含由所有静态过滤器过滤的数据、由所有静态和行过滤器过滤的数据,以及更新 rowFilters 的回调。

Example

  // See implementation for more details on RowFilter and FilterValue types
  const [staticData, filteredData, onFilterChange] = useListPageFilter(
    data,
    rowFilters,
    staticFilters,
  );
  // ListPageFilter updates filter state based on user interaction and resulting filtered data can be rendered in an independent component.
  return (
    <>
      <ListPageHeader .../>
      <ListPagBody>
        <ListPageFilter data={staticData} onFilterChange={onFilterChange} />
        <List data={filteredData} />
      </ListPageBody>
    </>
  )

Expand
参数名称描述

data

一个数据点的数组

rowFilters

(可选)定义可用过滤器选项的 RowFilter 元素的数组

staticFilters

(可选)静态应用到数据的 FilterValue 元素的数组

创建指向带有图标徽标的特定资源类型的链接的组件。

Example

  <ResourceLink
      kind="Pod"
      name="testPod"
      title={metadata.uid}
  />

Expand
参数名称描述

kind

(可选)资源(如 Pod、Deployment、Namespace)的类型

groupVersionKind

(可选)带有 group、version 和 kind 的对象

className

(可选)组件类风格

displayName

(可选)组件显示名称,如果设置则覆盖资源名称

inline

(可选)使用子项创建图标徽标和名称标记

linkTo

(可选)创建 Link 对象的标记 - 默认为 true

name

(可选)资源名称

namesapce

(可选)要链接到的 kind 资源的特定命名空间

hideIcon

(可选)隐藏图标徽标的标记

title

(可选)链接对象的标题(未显示)

dataTest

(可选)用于测试的标识符

onClick

(可选)当点组件时的回调功能

truncate

(可选)用于截断链接(如果太长)的标记

ResourceIcon

为特定资源类型创建图标徽标的组件。

Example

<ResourceIcon kind="Pod"/>

Expand
参数名称描述

kind

(可选)资源(如 Pod、Deployment、Namespace)的类型

groupVersionKind

(可选)带有 group、version 和 kind 的对象

className

(可选)组件类风格

useK8sModel

用于为来自 redux 的 K8sGroupVersionKind 获取 k8s 模型的 hook。它返回一个数组,第一个项为 k8s 模型,第二个项目为 inFlight 状态。

Example

const Component: React.FC = () => {
  const [model, inFlight] = useK8sModel({ group: 'app'; version: 'v1'; kind: 'Deployment' });
  return ...
}

Expand
参数名称描述

groupVersionKind

group, version, k8s 资源 kind K8sGroupVersionKind 是首选的,或为 group, version 传递引用,kind 已弃用,例如 group/version/kind (GVK) K8sResourceKindReference。

useK8sModels

从 redux 检索所有当前 k8s 模型的 hook。它返回一个数组,第一个项是 k8s 模型列表,第二个项目是 inFlight 状态。

Example

const Component: React.FC = () => {
  const [models, inFlight] = UseK8sModels();
  return ...
}

useK8sWatchResource

检索 k8s 资源以及加载和错误的状态的 hook。它返回一个数组,包含第一个项目作为资源,第二个项目作为加载的状态,第三个项目则作为错误状态(若有)。

Example

const Component: React.FC = () => {
  const watchRes = {
        ...
      }
  const [data, loaded, error] = useK8sWatchResource(watchRes)
  return ...
}

Expand
参数名称描述

initResource

监视资源所需的选项。

useK8sWatchResources

检索 k8s 资源的 hook,以及它们的相应状态用于加载和错误。它返回一个映射,在 initResouces 中提供的键,值有三个属性 data, loaded 和 error。

Example

const Component: React.FC = () => {
  const watchResources = {
        'deployment': {...},
        'pod': {...}
        ...
      }
  const {deployment, pod} = useK8sWatchResources(watchResources)
  return ...
}

Expand
参数名称描述

initResources

资源需要被监视为键值对,其中键对于资源是唯一的,值将是监视相应资源的选项。

consoleFetch

一个围绕 fetch 添加控制台特定标头的自定义打包程序,并允许重试和超时。它还验证响应状态代码,并抛出适当的错误或根据需要注销用户。它返回一个可以解析到响应的承诺。

Expand
参数名称描述

url

要获取的 URL

options

传递给获取的选项

timeout

以毫秒为单位的超时时间

consoleFetchJSON

围绕 fetch 的自定义打包程序,添加特定于控制台的标头并允许重试和超时。它还验证响应状态代码,并在需要时抛出适当的错误或注销用户。它将响应返回为 JSON 对象。在内部使用 consoleFetch。它返回一个承诺,它将解析为 JSON 对象的响应。

Expand
参数名称描述

url

要获取的 URL

方法

要使用的 HTTP 方法。默认为 GET

options

传递给获取的选项

timeout

以毫秒为单位的超时时间

cluster

发出请求的集群名称。默认为用户选择的活跃集群

consoleFetchText

围绕 fetch 的自定义打包程序,添加特定于控制台的标头并允许重试和超时。它还验证响应状态代码,并在需要时抛出适当的错误或注销用户。它将响应返回为文本。在内部使用 consoleFetch。它返回一个能以文本方式解析到响应的承诺。

Expand
参数名称描述

url

要获取的 URL

options

传递给获取的选项

timeout

以毫秒为单位的超时时间

cluster

发出请求的集群名称。默认为用户选择的活跃集群

getConsoleRequestHeaders

使用当前 redux 状态的 API 请求创建模拟和多集群相关标头的功能。它根据 redux 状态返回一个包含适当模拟和冲突的对象。

Expand
参数名称描述

targetCluster

使用提供的 targetCluster 覆盖当前活跃的集群

k8sGetResource

它根据提供的选项从集群获取资源。如果提供了名称,它会返回一个资源,它会返回与模型匹配的所有资源。如果名称被提供,它会返回一个承诺,它将作为 JSON 对象解析到 JSON 对象(如果其返回与模型匹配的所有资源)。如果出现故障,则承诺将被拒绝,并附带 HTTP 错误响应。

Expand
参数名称描述

options

在映射中作为键值对传递

options.model

k8s 模型

options.name

如果没有提供资源名称,它将查找与模型匹配的所有资源。

options.ns

要查找的命名空间,不应为集群范围的资源指定。

options.path

如果提供,请附加为子路径

options.queryParams

URL 中包含的查询参数。

options.requestInit

要使用的 fetch init 对象。这可以具有请求标头、方法、重定向等。如需更多信息,请参阅 Interface RequestInit

k8sCreateResource

它会根据提供的选项在集群中创建资源。它返回一个能够解析所创建的资源响应的承诺。如果失败承诺,则拒绝 HTTP 错误响应。

Expand
参数名称描述

options

在映射中作为键值对传递

options.model

k8s 模型

options.data

要创建的资源的有效负载

options.path

如果提供,请附加为子路径

options.queryParams

URL 中包含的查询参数。

k8sUpdateResource

它根据提供的选项更新集群中的整个资源。当客户端需要完全替换现有资源时,它们可以使用 k8sUpdate。或者,也可以使用 k8sPatch 执行部分更新。它返回一个可以解析到更新的资源响应的承诺。如果失败承诺,则拒绝 HTTP 错误响应。

Expand
参数名称描述

options

在映射中作为键值对传递

options.model

k8s 模型

options.data

要更新的 k8s 资源的有效负载

options.ns

要查找的命名空间,不应为集群范围的资源指定。

options.name

要更新的资源名称。

options.path

如果提供,请附加为子路径

options.queryParams

URL 中包含的查询参数。

k8sPatchResource

它根据提供的选项对集群中的任何资源进行补丁。当客户端需要执行部分更新时,可以使用 k8sPatch。或者可以使用 k8sUpdate 来完全替换现有资源。如需更多信息,请参阅数据跟踪器。它返回一个可以解析到修补资源响应的承诺。如果失败承诺,则拒绝 HTTP 错误响应。

Expand
参数名称描述

options

在映射中作为键值对传递。

options.model

k8s 模型

options.resource

要修补的资源。

options.data

只有现有资源使用操作、路径和值修补的数据。

options.path

如果提供,请附加为子路径。

options.queryParams

URL 中包含的查询参数。

k8sDeleteResource

它根据提供的模型资源从集群中删除资源。垃圾回收基于 Foreground|Background,可以在提供的模型中使用 propagationPolicy 属性进行配置,或者在 json 中传递。它返回一个解析为 Status 的响应的承诺。如果失败承诺,则拒绝 HTTP 错误响应。

Example

kind: 'DeleteOptions', apiVersion: 'v1', propagationPolicy

Expand
参数名称描述

options

在映射中作为键值对传递。

options.model

k8s 模型

options.resource

要删除的资源。

options.path

如果提供,请附加为子路径

options.queryParams

URL 中包含的查询参数。

options.requestInit

要使用的 fetch init 对象。这可以具有请求标头、方法、重定向等。如需更多信息,请参阅 Interface RequestInit

options.json

如果其他提供的资源被默认设置为"propagationPolicy",则可以明确控制资源的垃圾回收。

k8sListResource

根据提供的选项,将资源列为集群中的数组。它返回一个可以解析到响应的承诺。

Expand
参数名称描述

options

在映射中作为键值对传递

options.model

k8s 模型

options.queryParams

URL 中包含的查询参数,并可使用键 "labelSelector" 传递标签选择器。

options.requestInit

要使用的 fetch init 对象。这可以具有请求标头、方法、重定向等。如需更多信息,请参阅 Interface RequestInit

k8sListResourceItems

与 k8sListResource 相同的接口,但会返回子项目。它返回模型的 apiVersion,即 group/version

getAPIVersionForModel

为 k8s 模型提供 apiVersion。

Expand
参数名称描述

model

k8s 模型

getGroupVersionKindForResource

为资源提供组、版本和类型。它返回提供的资源的组 version 和 kind。如果资源没有 API 组,则返回组"core"。如果资源具有无效的 apiVersion,它将抛出错误。

Expand
参数名称描述

resource

k8s 资源

getGroupVersionKindForModel

为 k8s 模型提供组、版本和类型。这会返回提供的模型的组版本 kind。如果模型没有 apiGroup,则会返回组"core"。

Expand
参数名称描述

model

k8s 模型

StatusPopupSection

在弹出窗口中显示状态的组件。用于构建 console.dashboards/overview/health/resource 扩展的有用组件。

Example

  <StatusPopupSection
    firstColumn={
      <>
        <span>{title}</span>
        <span className="text-secondary">
          My Example Item
        </span>
      </>
    }
    secondColumn='Status'
  >

Expand
参数名称描述

firstColumn

弹出的第一列的值

secondColumn

(可选)弹出的第二列的值

children

(可选)弹出窗口的子项

StatusPopupItem

状态弹出窗口中使用的 status 元素;在 StatusPopupSection 中使用。

Example

<StatusPopupSection
   firstColumn='Example'
   secondColumn='Status'
>
   <StatusPopupItem icon={healthStateMapping[MCGMetrics.state]?.icon}>
      Complete
   </StatusPopupItem>
   <StatusPopupItem icon={healthStateMapping[RGWMetrics.state]?.icon}>
       Pending
   </StatusPopupItem>
</StatusPopupSection>

Expand
参数名称描述

value

(可选)要显示的文本值

icon

(可选)要显示的图标

children

子元素

概述

为仪表板创建一个打包程序组件。

Example

    <Overview>
      <OverviewGrid mainCards={mainCards} leftCards={leftCards} rightCards={rightCards} />
    </Overview>

Expand
参数名称描述

className

(可选) div 的风格类

children

(可选)仪表板的元素

OverviewGrid

为仪表板创建卡元素的网格;在 Overview 中使用。

Example

    <Overview>
      <OverviewGrid mainCards={mainCards} leftCards={leftCards} rightCards={rightCards} />
    </Overview>

Expand
参数名称描述

mainCards

网格的卡

leftCards

(可选)网格左侧的卡

rightCards

(可选)网格右侧的卡

InventoryItem

创建清单卡项。

Example

  return (
    <InventoryItem>
      <InventoryItemTitle>{title}</InventoryItemTitle>
      <InventoryItemBody error={loadError}>
        {loaded && <InventoryItemStatus count={workerNodes.length} icon={<MonitoringIcon />} />}
      </InventoryItemBody>
    </InventoryItem>
  )

Expand
参数名称描述

children

在项目内呈现的元素

InventoryItemTitle

为清单卡项目创建标题;在 InventoryItem 内使用。

Example

 return (
   <InventoryItem>
     <InventoryItemTitle>{title}</InventoryItemTitle>
     <InventoryItemBody error={loadError}>
       {loaded && <InventoryItemStatus count={workerNodes.length} icon={<MonitoringIcon />} />}
     </InventoryItemBody>
   </InventoryItem>
 )

Expand
参数名称描述

children

在标题内呈现的元素

InventoryItemBody

创建清单卡的正文;在 InventoryCard 中使用,并可与 InventoryTitle 一起使用。

Example

 return (
   <InventoryItem>
     <InventoryItemTitle>{title}</InventoryItemTitle>
     <InventoryItemBody error={loadError}>
       {loaded && <InventoryItemStatus count={workerNodes.length} icon={<MonitoringIcon />} />}
     </InventoryItemBody>
   </InventoryItem>
 )

Expand
参数名称描述

children

在清单卡或标题内呈现的元素

错误

div 的元素

InventoryItemStatus

为带有可选链接地址的清单卡创建一个计数和图标;在 InventoryItemBody 中使用

Example

 return (
   <InventoryItem>
     <InventoryItemTitle>{title}</InventoryItemTitle>
     <InventoryItemBody error={loadError}>
       {loaded && <InventoryItemStatus count={workerNodes.length} icon={<MonitoringIcon />} />}
     </InventoryItemBody>
   </InventoryItem>
 )

Expand
参数名称描述

数�

显示计数

icon

显示图标

linkTo

(可选)链接地址

InventoryItemLoading

为清单卡加载时创建框架容器;与 InventoryItem 和相关组件一起使用

Example

if (loadError) {
   title = <Link to={workerNodesLink}>{t('Worker Nodes')}</Link>;
} else if (!loaded) {
  title = <><InventoryItemLoading /><Link to={workerNodesLink}>{t('Worker Nodes')}</Link></>;
}
return (
  <InventoryItem>
    <InventoryItemTitle>{title}</InventoryItemTitle>
  </InventoryItem>
)

useFlag

从 FLAGS redux 状态返回给定功能标记的 hook。它返回请求的功能标记或未定义的布尔值。

Expand
参数名称描述

flag

要返回的功能标志

YAMLEditor

有一个基本的 lazy 加载的 YAML 编辑器,带有悬停的帮助和完成。

Example

<React.Suspense fallback={<LoadingBox />}>
  <YAMLEditor
    value={code}
  />
</React.Suspense>

Expand
参数名称描述

value

代表要呈现的 yaml 代码的字符串。

options

Monaco 编辑器选项.

minHeight

有效 CSS 高度中的值的最小编辑器高度。

showShortcuts

布尔值,以显示编辑器顶部的快捷方式。

toolbarLinks

编辑器顶部的工具栏链接部分上 ReactNode rendered 的数组。

onChange

代码更改事件的回调。

onSave

触发命令 CTRL / CMD + S 时调用的回调。

ref

{ editor?: IStandaloneCodeEditor } 的响应参考。使用 editor 属性,您可以访问所有方法来控制编辑器。

ResourceYAMLEditor

一个 lazy 载入的 Kubernetes 资源的 YAML 编辑器,带有悬停的帮助和完成。组件使用 YAMLEditor 并在其之上添加更多功能,如资源更新处理、警报、保存、取消和重新加载按钮、可访问性等。除非提供了 onSave 回调,否则自动处理资源更新。它应该嵌套在 React.Suspense 组件中。

Example

<React.Suspense fallback={<LoadingBox />}>
  <ResourceYAMLEditor
    initialResource={resource}
    header="Create resource"
    onSave={(content) => updateResource(content)}
  />
</React.Suspense>

Expand
参数名称描述

initialResource

代表编辑器显示资源的 YAML/Object。这个 prop 仅在初始呈现过程中使用

header

在 YAML 编辑器之上添加一个标头

onSave

保存按钮的回调。传递它将覆盖编辑器对资源执行的默认更新

ResourceEventStream

显示与特定资源相关的事件的组件。

Example

const [resource, loaded, loadError] = useK8sWatchResource(clusterResource);
return <ResourceEventStream resource={resource} />

Expand
参数名称描述

resource

应该会显示相关事件的对象。

usePrometheusPoll

为单个查询设置对 Prometheus 的轮询。它返回一个包含查询响应的元组、指示响应是否已完成的布尔值标志,以及请求请求或后处理过程中遇到的任何错误。

Expand
参数名称描述

{PrometheusEndpoint} props.endpoint

PrometheusEndpoint 中的一个(label, query, range, rules, targets)

{string} [props.query]

(可选)Prometheus 查询字符串。如果为空或未定义,则不会启动轮询。

{number} [props.delay]

(可选)轮询延迟间隔 (ms)

{number} [props.endTime]

(可选)用于 QUERY_RANGE enpoint,查询范围的末尾

{number} [props.samples]

(可选)用于 QUERY_RANGE enpoint

{number} [options.timespan]

(可选)用于 QUERY_RANGE enpoint

{string} [options.namespace]

(可选)要附加的搜索参数

{string} [options.timeout]

(可选)要附加的搜索参数

Timestamp

呈现时间戳的组件。时间戳在 Timestamp 组件的 invidual 实例之间同步。提供的时间戳会根据用户区域设置进行格式化。

Expand
参数名称描述

timestamp

呈现的时间戳。格式预期为 ISO 8601 (由 Kubernetes 使用)、epo 时间时间戳或日期的实例。

simple

呈现组件的简单版本,省略图标和工具提示。

omitSuffix

格式化日期消息后缀。

className

组件的额外类名称。

useModal

用于启动修改的 hook。

Example

const context: AppPage: React.FC = () => {<br/> const [launchModal] = useModal();<br/> const onClick = () => launchModal(ModalComponent);<br/> return (<br/>   <Button onClick={onClick}>Launch a Modal</Button><br/> )<br/>}<br/>`

ActionServiceProvider

允许从 console.action/provider 扩展类型的其他插件接收贡献的组件。

Example

   const context: ActionContext = { 'a-context-id': { dataFromDynamicPlugin } };

   ...

   <ActionServiceProvider context={context}>
       {({ actions, options, loaded }) =>
         loaded && (
           <ActionMenu actions={actions} options={options} variant={ActionMenuVariant.DROPDOWN} />
         )
       }
   </ActionServiceProvider>

Expand
参数名称描述

context

带有 contextId 和可选插件数据的对象

NamespaceBar

一个组件,它呈现一个水平工具栏,其中有一个命名空间下拉菜单(在最左边)。其他组件可以作为子项传递,并呈现到命名空间下拉菜单的右侧。此组件设计为在页面的顶部使用。它应用于用户需要更改活动命名空间的页面,如 k8s 资源的页面中。

Example

   const logNamespaceChange = (namespace) => console.log(`New namespace: ${namespace}`);

   ...

   <NamespaceBar onNamespaceChange={logNamespaceChange}>
     <NamespaceBarApplicationSelector />
   </NamespaceBar>
   <Page>

     ...

Expand
参数名称描述

onNamespaceChange

(可选)当选择命名空间选项时执行的功能。它接受字符串形式的新命名空间作为其唯一参数。选择了选项时,活跃命名空间会自动更新,但可通过此功能应用其他逻辑。当更改命名空间时,URL 中的 namespace 参数将从以前的命名空间改为新选择的命名空间。

isDisabled

(可选)如果设为 true,则禁用命名空间下拉菜单的布尔值标志。这个选项只适用于命名空间下拉菜单,对子组件没有影响。

children

(可选)在命名空间下拉菜单右侧的工具栏中呈现的其他元素。

ErrorBoundaryFallbackPage

创建全页 ErrorBoundaryFallbackPage 组件以显示 "Oh no!Something went wrong." 消息与堆栈跟踪和其他有帮助的调试信息一起。这与组件一起使用。

Example

//in ErrorBoundary component
 return (
   if (this.state.hasError) {
     return <ErrorBoundaryFallbackPage errorMessage={errorString} componentStack={componentStackString}
      stack={stackTraceString} title={errorString}/>;
   }

   return this.props.children;
)

Expand
参数名称描述

errorMessage

错误消息的文本描述

componentStack

异常的组件追踪

queue

异常的堆栈追踪

title

将标题显示为错误边界页面的标头

PerspectiveContext

弃用: 使用提供的 usePerspectiveContext 替代。创建视角上下文。

Expand
参数名称描述

PerspectiveContextType

带有活跃视角和 setter 的对象

useAccessReviewAllowed

弃用:使用来自 @console/dynamic-plugin-sdkuseAccessReview 替代。hook,提供有关用户对给定资源的访问权限的允许状态。它返回 isAllowed 布尔值。

Expand
参数名称描述

resourceAttributes

访问查看的资源属性

impersonate

模拟详情

useSafetyFirst

弃用:此 hook 与控制台功能无关。在可以卸载给定组件时,确保安全 asynchronnous 设置 React 状态的 hook。它返回一个数组,它带有一对状态值及其 set 功能。

Expand
参数名称描述

initialState

初始状态值

Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部