Skip to content

Commit

Permalink
bug fix: enable source instrumentation via ui (#76)
Browse files Browse the repository at this point in the history
This PR fixes a bug in the UI where the application edit page caused 500
internal error.
  • Loading branch information
edeNFed authored Feb 19, 2023
1 parent 638a9c4 commit f7b0ccf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ui/components/EditAppCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function EditAppCard({
}: ApplicationData) {
return (
<div className="shadow-lg border border-gray-200 rounded-lg bg-white hover:bg-gray-100 cursor-pointer">
<Link href={`/source/${namespace}/${name}`}>
<Link href={`/source/${namespace}/${kind.toString().toLowerCase()}/${name}`}>
<a className="flex flex-row p-3 items-center space-x-4">
{getLangIcon(languages[0], "w-12 h-12")}
<div className="flex flex-col items-start">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default async function UpdateSource(
"v1alpha1",
req.query.namespace as string,
"instrumentedapplications",
req.query.name as string
`${req.query.kind}-${req.query.name}`
);

resp.body.spec.enabled = req.body.enabled;
Expand All @@ -23,7 +23,7 @@ export default async function UpdateSource(
"v1alpha1",
req.query.namespace as string,
"instrumentedapplications",
req.query.name as string,
`${req.query.kind}-${req.query.name}`,
resp.body
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ interface EditAppProps {

const EditAppPage: NextPage<EditAppProps> = ({ enabled }: EditAppProps) => {
const router = useRouter();
const { name, namespace } = router.query;
const { name, kind, namespace } = router.query;
const [isEnabled, setIsEnabled] = useState(enabled);
const updateApp = async () => {
const resp = await fetch(`/api/source/${namespace}/${name}`, {
const resp = await fetch(`/api/source/${namespace}/${kind}/${name}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down Expand Up @@ -69,7 +69,7 @@ export const getServerSideProps = async ({ query }: any) => {
};
}

const { name, namespace } = query;
const { name, kind, namespace } = query;
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const k8sApi = kc.makeApiClient(k8s.CustomObjectsApi);
Expand All @@ -78,7 +78,7 @@ export const getServerSideProps = async ({ query }: any) => {
"v1alpha1",
namespace,
"instrumentedapplications",
name
`${kind}-${name}`
);

if (!resp) {
Expand Down

0 comments on commit f7b0ccf

Please sign in to comment.