Skip to content

Commit

Permalink
fix leaf name and default search tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
molotgor committed Feb 4, 2025
1 parent 44d8798 commit 9d776d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 30 deletions.
1 change: 0 additions & 1 deletion src/components/JSONViewer/TreeLeaf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ const TreeLeaf = ({
}}>
<div className={createBemBlock('event-status-icon')} />
<span style={{ color: treeNode.isGeneratedKey ? '#333333' : undefined }}>
{treeNode.id} ={'>'} {treeNode.parentIds.join(', ')} {' '}
{splitContent.map((contentPart, index) => (
<span
key={index}
Expand Down
47 changes: 18 additions & 29 deletions src/stores/JSONViewer/JSONViewerStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,21 @@ export interface BodyReaderSearchResult extends BaseReaderSearchResult {
position: 'key' | 'value';
}

const defaultSearchTokens: SearchToken[] = [
{
pattern: 'PASS',
color: 'green',
isScrollable: true,
isActive: false,
},
{
pattern: 'FAIL',
color: 'red',
isScrollable: true,
isActive: false,
},
];

type ReaderSearchResult = NameReaderSearchResult | TableReaderSearchResult | BodyReaderSearchResult;

export type PanelType = 'default' | 'compare';
Expand Down Expand Up @@ -163,20 +178,7 @@ export class JSONViewerStore {
@observable isCompare = false;

@observable
public tokens: SearchToken[] = [
{
pattern: 'PASS',
color: 'green',
isScrollable: true,
isActive: false,
},
{
pattern: 'FAIL',
color: 'red',
isScrollable: true,
isActive: false,
},
];
public tokens: SearchToken[] = [...defaultSearchTokens];

@observable
public currentSearchResult: {
Expand Down Expand Up @@ -523,7 +525,7 @@ export class JSONViewerStore {

@action
updateTokensFromText = (text: string) => {
const newTokens: SearchToken[] = [];
const newTokens: SearchToken[] = [...defaultSearchTokens];
try {
const json = JSON.parse(text);
for (let i = 0; i < json.length; i++) {
Expand Down Expand Up @@ -579,20 +581,7 @@ export class JSONViewerStore {

@action
clearSearchField = () => {
this.tokens = [
{
pattern: 'PASS',
color: 'green',
isScrollable: true,
isActive: false,
},
{
pattern: 'FAIL',
color: 'red',
isScrollable: true,
isActive: false,
},
];
this.tokens = [...defaultSearchTokens];
};

@action
Expand Down

0 comments on commit 9d776d1

Please sign in to comment.