Skip to content

Commit

Permalink
fix: Bring back the JSON tab
Browse files Browse the repository at this point in the history
Signed-off-by: Noble Mittal <[email protected]>
  • Loading branch information
beingnoble03 committed Jan 3, 2025
1 parent 0667994 commit f727d9a
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 7 deletions.
3 changes: 1 addition & 2 deletions web/vtadmin/src/components/routes/VTExplain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import style from './VTExplain.module.scss';
import { Code } from '../Code';
import { useDocumentTitle } from '../../hooks/useDocumentTitle';
import { Label } from '../inputs/Label';
import JSONViewTree from '../jsonViewTree/JSONViewTree';

// TODO(doeg): persist form data in URL, error handling, loading state, um... hm. Most things still need doing.
// This whole component is the hastiest prototype ever. :')
Expand Down Expand Up @@ -108,7 +107,7 @@ export const VTExplain = () => {

{error && (
<section className={style.errorPanel}>
<JSONViewTree data={error} />
<Code code={JSON.stringify(error, null, 2)} />
</section>
)}

Expand Down
7 changes: 7 additions & 0 deletions web/vtadmin/src/components/routes/keyspace/Keyspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import style from './Keyspace.module.scss';
import { KeyspaceShards } from './KeyspaceShards';
import { KeyspaceVSchema } from './KeyspaceVSchema';
import JSONViewTree from '../../jsonViewTree/JSONViewTree';
import { Code } from '../../Code';

interface RouteParams {
clusterID: string;
Expand Down Expand Up @@ -94,6 +95,7 @@ export const Keyspace = () => {
<Tab text="Shards" to={`${url}/shards`} />
<Tab text="VSchema" to={`${url}/vschema`} />
<Tab text="JSON" to={`${url}/json`} />
<Tab text="JSON Tree" to={`${url}/json_tree`} />

<ReadOnlyGate>
<Tab text="Advanced" to={`${url}/advanced`} />
Expand All @@ -110,6 +112,11 @@ export const Keyspace = () => {
</Route>

<Route path={`${path}/json`}>
<QueryLoadingPlaceholder query={kq} />
<Code code={JSON.stringify(keyspace, null, 2)} />
</Route>

<Route path={`${path}/json_tree`}>
<QueryLoadingPlaceholder query={kq} />
<JSONViewTree data={keyspace} />
</Route>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { useVSchema } from '../../../hooks/api';
import JSONViewTree from '../../jsonViewTree/JSONViewTree';
import { Code } from '../../Code';
import { QueryErrorPlaceholder } from '../../placeholders/QueryErrorPlaceholder';
import { QueryLoadingPlaceholder } from '../../placeholders/QueryLoadingPlaceholder';

Expand All @@ -30,7 +30,7 @@ export const KeyspaceVSchema = ({ clusterID, name }: Props) => {
<div>
<QueryLoadingPlaceholder query={query} />
<QueryErrorPlaceholder query={query} title="Couldn't load VSchema" />
{query.isSuccess && <JSONViewTree data={query.data} />}
{query.isSuccess && <Code code={JSON.stringify(query.data, null, 2)} />}
</div>
);
};
5 changes: 4 additions & 1 deletion web/vtadmin/src/components/routes/shard/Shard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { useKeyspace } from '../../../hooks/api';
import { ShardTablets } from './ShardTablets';
import Advanced from './Advanced';
import JSONViewTree from '../../jsonViewTree/JSONViewTree';
import { Code } from '../../Code';

interface RouteParams {
clusterID: string;
Expand Down Expand Up @@ -114,6 +115,7 @@ export const Shard = () => {
<TabContainer>
<Tab text="Tablets" to={`${url}/tablets`} />
<Tab text="JSON" to={`${url}/json`} />
<Tab text="JSON Tree" to={`${url}/json_tree`} />
<Tab text="Advanced" to={`${url}/advanced`} />
</TabContainer>

Expand All @@ -122,7 +124,8 @@ export const Shard = () => {
<ShardTablets {...params} />
</Route>

<Route path={`${path}/json`}>{shard && <JSONViewTree data={shard} />}</Route>
<Route path={`${path}/json`}>{shard && <Code code={JSON.stringify(shard, null, 2)} />}</Route>
<Route path={`${path}/json_tree`}>{shard && <JSONViewTree data={shard} />}</Route>
<Route path={`${path}/advanced`}>
<Advanced />
</Route>
Expand Down
18 changes: 16 additions & 2 deletions web/vtadmin/src/components/routes/stream/Stream.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Link, useParams } from 'react-router-dom';
import { Link, Redirect, Route, Switch, useParams, useRouteMatch } from 'react-router-dom';

import { useWorkflow } from '../../../hooks/api';
import { useDocumentTitle } from '../../../hooks/useDocumentTitle';
Expand All @@ -24,6 +24,9 @@ import { WorkspaceHeader } from '../../layout/WorkspaceHeader';
import { WorkspaceTitle } from '../../layout/WorkspaceTitle';
import style from './Stream.module.scss';
import JSONViewTree from '../../jsonViewTree/JSONViewTree';
import { TabContainer } from '../../tabs/TabContainer';
import { Tab } from '../../tabs/Tab';
import { Code } from '../../Code';

interface RouteParams {
clusterID: string;
Expand All @@ -36,6 +39,7 @@ interface RouteParams {

export const Stream = () => {
const params = useParams<RouteParams>();
const { path, url } = useRouteMatch();
const { data: workflow } = useWorkflow({
clusterID: params.clusterID,
keyspace: params.keyspace,
Expand Down Expand Up @@ -72,7 +76,17 @@ export const Stream = () => {
</div>
</WorkspaceHeader>
<ContentContainer>
<JSONViewTree data={stream} />
<TabContainer>
<Tab text="JSON" to={`${url}/json`} />
<Tab text="JSON Tree" to={`${url}/json_tree`} />
</TabContainer>

<Switch>
<Route path={`${path}/json`}>{stream && <Code code={JSON.stringify(stream, null, 2)} />}</Route>
<Route path={`${path}/json_tree`}>{stream && <JSONViewTree data={stream} />}</Route>

<Redirect exact from={path} to={`${path}/json`} />
</Switch>
</ContentContainer>
</div>
);
Expand Down
12 changes: 12 additions & 0 deletions web/vtadmin/src/components/routes/tablet/Tablet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { TabletCharts } from './TabletCharts';
import { env } from '../../../util/env';
import FullStatus from './FullStatus';
import JSONViewTree from '../../jsonViewTree/JSONViewTree';
import { Code } from '../../Code';

interface RouteParams {
alias: string;
Expand Down Expand Up @@ -108,6 +109,7 @@ export const Tablet = () => {
<Tab text="QPS" to={`${url}/qps`} />
<Tab text="Full Status" to={`${url}/full-status`} />
<Tab text="JSON" to={`${url}/json`} />
<Tab text="JSON Tree" to={`${url}/json_tree`} />
<ReadOnlyGate>
<Tab text="Advanced" to={`${url}/advanced`} />
</ReadOnlyGate>
Expand All @@ -119,6 +121,16 @@ export const Tablet = () => {
</Route>

<Route path={`${path}/json`}>
<div>
<Code code={JSON.stringify(tablet, null, 2)} />

{env().VITE_ENABLE_EXPERIMENTAL_TABLET_DEBUG_VARS && (
<Code code={JSON.stringify(debugVars, null, 2)} />
)}
</div>
</Route>

<Route path={`${path}/json_tree`}>
<div>
<JSONViewTree data={tablet} />

Expand Down
6 changes: 6 additions & 0 deletions web/vtadmin/src/components/routes/workflow/Workflow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { WorkflowVDiff } from './WorkflowVDiff';
import { Select } from '../../inputs/Select';
import { formatDateTimeShort } from '../../../util/time';
import JSONViewTree from '../../jsonViewTree/JSONViewTree';
import { Code } from '../../Code';

interface RouteParams {
clusterID: string;
Expand Down Expand Up @@ -168,6 +169,7 @@ export const Workflow = () => {
<Tab text="Details" to={`${url}/details`} />
<Tab text="VDiff" to={`${url}/vdiff`} />
<Tab text="JSON" to={`${url}/json`} />
<Tab text="JSON Tree" to={`${url}/json_tree`} />
</TabContainer>

<Switch>
Expand All @@ -189,6 +191,10 @@ export const Workflow = () => {
</Route>

<Route path={`${path}/json`}>
<Code code={JSON.stringify(data, null, 2)} />
</Route>

<Route path={`${path}/json_tree`}>
<JSONViewTree data={data} />
</Route>

Expand Down

0 comments on commit f727d9a

Please sign in to comment.