@@ -62,12 +62,8 @@ const ImageAutomationDetails = ({
diff --git a/ui/components/PodDetail.tsx b/ui/components/PodDetail.tsx
index 51bbacb35b..19520c2a47 100644
--- a/ui/components/PodDetail.tsx
+++ b/ui/components/PodDetail.tsx
@@ -2,6 +2,7 @@ import { Tabs } from "@material-ui/core";
import * as React from "react";
import styled from "styled-components";
import { Container, FluxObject } from "../lib/objects";
+import { createYamlCommand } from "../lib/utils";
import DataTable from "./DataTable";
import Flex from "./Flex";
import InfoList from "./InfoList";
@@ -142,12 +143,7 @@ function PodDetail({ className, pod }: Props) {
return (
);
}
diff --git a/ui/components/ProviderDetail.tsx b/ui/components/ProviderDetail.tsx
index a2b17a992a..be33bb399d 100644
--- a/ui/components/ProviderDetail.tsx
+++ b/ui/components/ProviderDetail.tsx
@@ -4,6 +4,7 @@ import styled from "styled-components";
import { useListAlerts } from "../hooks/notifications";
import { Kind } from "../lib/api/core/types.pb";
import { Provider } from "../lib/objects";
+import { createYamlCommand } from "../lib/utils";
import Alert from "./Alert";
import AlertsTable from "./AlertsTable";
import Flex from "./Flex";
@@ -30,11 +31,11 @@ function ProviderDetail({ className, provider }: Props) {
diff --git a/ui/components/SourceDetail.tsx b/ui/components/SourceDetail.tsx
index b8e09d48d0..605976f51f 100644
--- a/ui/components/SourceDetail.tsx
+++ b/ui/components/SourceDetail.tsx
@@ -5,7 +5,7 @@ import styled from "styled-components";
import { useListAutomations } from "../hooks/automations";
import { Kind } from "../lib/api/core/types.pb";
import { HelmRelease, OCIRepository, Source } from "../lib/objects";
-import { getSourceRefForAutomation } from "../lib/utils";
+import { createYamlCommand, getSourceRefForAutomation } from "../lib/utils";
import AutomationsTable from "./AutomationsTable";
import EventsTable from "./EventsTable";
import Flex from "./Flex";
@@ -120,11 +120,7 @@ function SourceDetail({ className, source, info, type, customActions }: Props) {
diff --git a/ui/components/YamlView.tsx b/ui/components/YamlView.tsx
index 57dfa8dafe..d248a16ef8 100644
--- a/ui/components/YamlView.tsx
+++ b/ui/components/YamlView.tsx
@@ -4,8 +4,6 @@ import { darcula } from "react-syntax-highlighter/dist/cjs/styles/prism";
import styled from "styled-components";
import { ThemeTypes } from "../contexts/AppContext";
import { useInDarkMode } from "../hooks/theme";
-import { ObjectRef } from "../lib/api/core/types.pb";
-import { createYamlCommand } from "../lib/utils";
import CopyToClipboard from "./CopyToCliboard";
import Flex from "./Flex";
@@ -13,7 +11,7 @@ export type YamlViewProps = {
className?: string;
type?: string;
yaml: string;
- object?: ObjectRef;
+ header?: string;
theme?: ThemeTypes;
};
@@ -28,17 +26,11 @@ const YamlHeader = styled(Flex)`
function UnstyledYamlView({
yaml,
- object,
+ header,
className,
theme,
type = "yaml",
}: YamlViewProps) {
- const headerText = createYamlCommand(
- object?.kind,
- object?.name,
- object?.namespace
- );
-
const dark = theme ? theme === ThemeTypes.Dark : useInDarkMode();
const styleProps = {
@@ -60,11 +52,11 @@ function UnstyledYamlView({
return (
- {headerText && (
+ {header && (
- {headerText}
+ {header}
diff --git a/ui/components/__tests__/YamlView.test.tsx b/ui/components/__tests__/YamlView.test.tsx
index e49cba137a..c21c01cb3d 100644
--- a/ui/components/__tests__/YamlView.test.tsx
+++ b/ui/components/__tests__/YamlView.test.tsx
@@ -3,6 +3,7 @@ import React from "react";
import renderer from "react-test-renderer";
import { Kind } from "../../lib/api/core/types.pb";
import { withContext, withTheme } from "../../lib/test-utils";
+import { createYamlCommand } from "../../lib/utils";
import YamlView from "../YamlView";
describe("YamlView", () => {
@@ -13,11 +14,11 @@ describe("YamlView", () => {
withTheme(
withContext(
,
"",
diff --git a/ui/lib/__tests__/utils.test.ts b/ui/lib/__tests__/utils.test.ts
index 111f5da617..4ef63ef32d 100644
--- a/ui/lib/__tests__/utils.test.ts
+++ b/ui/lib/__tests__/utils.test.ts
@@ -425,6 +425,11 @@ describe("createYamlCommand", () => {
null
);
});
+ it("uses the path prop if it is defined", () => {
+ expect(createYamlCommand(undefined, undefined, undefined, "http")).toEqual(
+ "http"
+ );
+ });
describe("getBasePath", () => {
describe("without a base tag set in the dom", () => {
diff --git a/ui/lib/utils.ts b/ui/lib/utils.ts
index e107f7839f..e9461f792e 100644
--- a/ui/lib/utils.ts
+++ b/ui/lib/utils.ts
@@ -244,10 +244,12 @@ export function formatLogTimestamp(timestamp?: string, zone?: string): string {
}
export const createYamlCommand = (
- kind: string,
- name: string,
- namespace: string
+ kind?: string,
+ name?: string,
+ namespace?: string,
+ path?: string
): string => {
+ if (path) return path;
if (kind && name) {
const namespaceString = namespace ? ` -n ${namespace}` : "";
return `kubectl get ${kind.toLowerCase()} ${name}${namespaceString} -o yaml`;