1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Factor out mode display function

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-05-30 09:50:26 -04:00
parent ba31a2528b
commit 8c354f029b
3 changed files with 15 additions and 2 deletions

View File

@ -4,6 +4,7 @@
*/
import React from "react";
import { displayMode } from "../../../../../utils";
import { DrawerItem, DrawerTitle } from "../../../../drawer";
import type { VolumeVariantComponent } from "../variant-helpers";
@ -12,7 +13,7 @@ export const Projected: VolumeVariantComponent<"projected"> = (
<>
{typeof defaultMode === "number" && (
<DrawerItem name="Default Mount Mode">
{`0o${defaultMode.toString(8)}`}
{displayMode(defaultMode)}
</DrawerItem>
)}
<DrawerItem name="Sources">
@ -31,7 +32,7 @@ export const Projected: VolumeVariantComponent<"projected"> = (
<li key={key}>
{`${key}${path}`}
{typeof mode === "number" && (
` (0o${mode.toString(8)})`
` (${displayMode(mode)})`
)}
</li>
))}

View File

@ -0,0 +1,11 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
/**
* Format `mode` in octal notation
*/
export function displayMode(mode: number): string {
return `0o${mode.toString(8)}`;
}

View File

@ -10,6 +10,7 @@ export * from "../../common/event-emitter";
export * from "./cssNames";
export * from "./cssVar";
export * from "./display-booleans";
export * from "./display-mode";
export * from "./interval";
export * from "./isMiddleClick";
export * from "./isReactNode";