Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add set metadata badge #5

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,35 @@ exports[`Method renders - execution 1`] = `
</code>
</pre>
</div>
<pre
class="bg-body text-dark rounded-1 m-0 py-1 px-2 text-break "
data-testid="json-block"
style="display: block; overflow-x: auto; padding: 0.5em; color: rgb(0, 0, 0); background: rgb(248, 248, 255);"
<div
class="d-grid"
>
<code
class="language-json"
style="white-space: pre-wrap;"
<div
class="bg-body text-dark rounded-1 m-0 py-1 px-2 text-break rounded-bottom-0"
data-testid="react-block"
>
<span>
<span
class="small"
>
Request data
</span>
</div>
<pre
class="bg-body text-dark rounded-1 m-0 py-1 px-2 text-break "
data-testid="json-block"
style="display: block; overflow-x: auto; padding: 0.5em; color: rgb(0, 0, 0); background: rgb(248, 248, 255);"
>
<code
class="language-json"
style="white-space: pre-wrap;"
>
<span>
{}
<span>
{}
</span>
</span>
</span>
</code>
</pre>
</code>
</pre>
</div>
</div>
`;
9 changes: 8 additions & 1 deletion web/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"use client";
import { Button, Form } from "react-bootstrap";
import { Badge, Button, Form } from "react-bootstrap";
import { useSourceContext } from "../contexts/SourceContext";
import dynamic from "next/dynamic";
import { Suspense, useState } from "react";
import MetadataModal from "../components/metadata/MetadataModal";
import HandleUrlHostnameParam from "@/components/HandleUrlHostnameParam";
import { useMetadataContext } from "@/contexts/MetadataContext";

const Endpoints = dynamic(() => import("../components/Endpoints"), {
ssr: false,
Expand All @@ -17,6 +18,7 @@ export default function Home() {
"This is a tool to help you interact with gRPC services. You can use it to explore the service's endpoints and make requests to them, browse types and enums, and preview options.";

const [showMetadataModal, setShowMetadataModal] = useState(false);
const { metadata } = useMetadataContext();

return (
<main>
Expand Down Expand Up @@ -61,6 +63,11 @@ export default function Home() {
onClick={() => setShowMetadataModal(true)}
data-testid="metadata-button"
>
{metadata && Object.keys(metadata).length > 0 && (
<Badge bg="dark" className="me-2">
{Object.keys(metadata).length}
</Badge>
)}
Metadata & Authorization
</Button>
<MetadataModal
Expand Down
11 changes: 8 additions & 3 deletions web/src/components/parts/method/Method.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,14 @@ export default function Method({
{JSON.stringify(request.metadata, null, 2)}
</JSONBlock>
</div>
<JSONBlock dark={false}>
{JSON.stringify(request.message, null, 2)}
</JSONBlock>
<div className="d-grid">
<JSONBlock dark={false} className="rounded-bottom-0">
<span className="small">Request data</span>
</JSONBlock>
<JSONBlock dark={false}>
{JSON.stringify(request.message, null, 2)}
</JSONBlock>
</div>
</div>
<div
className="d-grid gap-2"
Expand Down
Loading