Skip to content

Commit

Permalink
Merge pull request #939 from omonk/context-aware-method-endpoint-render
Browse files Browse the repository at this point in the history
Dont render serverUrl on callbacks MethodEndpoint component
  • Loading branch information
sserrata authored Sep 5, 2024
2 parents bdc4028 + 7d09cd7 commit e7d4a50
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* ============================================================================
* Copyright (c) Palo Alto Networks
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* ========================================================================== */

import { create } from "./utils";

export function createCallbackMethodEndpoint(method: String, path: String) {
return [
create("MethodEndpoint", {
method: method,
path: path,
context: "callback",
}),
"\n\n",
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
* ========================================================================== */

import { createCallbackMethodEndpoint } from "./createCallbackMethodEndpoint";
import { createDescription } from "./createDescription";
import { createMethodEndpoint } from "./createMethodEndpoint";
import { createRequestBodyDetails } from "./createRequestBodyDetails";
import { createStatusCodes } from "./createStatusCodes";
import { create } from "./utils";
Expand Down Expand Up @@ -78,7 +78,7 @@ export function createCallbacks({ callbacks }: Props) {
label: `${method.toUpperCase()} ${name}`,
value: `${method}-${name}`,
children: [
createMethodEndpoint(method, path),
createCallbackMethodEndpoint(method, path),
// TODO: add `deprecation notice` when markdown support is added
createDescription(description),
createRequestBodyDetails({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,12 @@
import { create } from "./utils";

export function createMethodEndpoint(method: String, path: String) {
return [create("MethodEndpoint", { method: method, path: path }), "\n\n"];
return [
create("MethodEndpoint", {
method: method,
path: path,
context: "endpoint",
}),
"\n\n",
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,18 @@ function colorForMethod(method: string) {
export interface Props {
method: string;
path: string;
context?: "endpoint" | "callback";
}

function MethodEndpoint({ method, path }: Props) {
function MethodEndpoint({ method, path, context }: Props) {
let serverValue = useTypedSelector((state: any) => state.server.value);
let serverUrlWithVariables = "";

const renderServerUrl = () => {
if (context === "callback") {
return "";
}

if (serverValue && serverValue.variables) {
serverUrlWithVariables = serverValue.url.replace(/\/$/, "");

Expand Down

0 comments on commit e7d4a50

Please sign in to comment.