Skip to content

Commit

Permalink
Merge pull request #498 from easyops-cn/jojiang/nav
Browse files Browse the repository at this point in the history
fix(): label support show flag
  • Loading branch information
weareoutman authored Oct 7, 2023
2 parents b91b0ba + 385ff97 commit bf5dcb2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ exports[`getTreeData should work 1`] = `
"console.log(1323)",
],
"parent": {
"flag": "skip",
"instanceId": "603a85ccfb595",
"label": "should work",
"name": "it",
Expand Down Expand Up @@ -179,6 +180,7 @@ exports[`getTreeData should work 1`] = `
},
],
"parent": {
"flag": "skip",
"instanceId": "603a85ccfb595",
"label": "should work",
"name": "it",
Expand Down Expand Up @@ -220,7 +222,8 @@ exports[`getTreeData should work 1`] = `
"type": "command",
},
],
"displayLabel": "it: should work",
"displayLabel": "[skip] it: should work",
"flag": "skip",
"instanceId": "603a85ccfb595",
"isChainChild": false,
"label": "should work",
Expand All @@ -243,7 +246,7 @@ exports[`getTreeData should work 1`] = `
"lib": "fa",
},
"key": "603a85ccfb595",
"name": "it: should work",
"name": "[skip] it: should work",
},
{
"children": [
Expand Down Expand Up @@ -318,6 +321,7 @@ exports[`getTreeData should work 1`] = `
"data": {
"children": [
{
"flag": "skip",
"instanceId": "603a85ccfb595",
"label": "should work",
"name": "it",
Expand Down
1 change: 1 addition & 0 deletions bricks/ui-test/src/custom-processors/get-tree-data.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe("getTreeData", () => {
name: "it",
params: null,
type: "block",
flag: "skip",
},
{
instanceId: "603ab42f8eae9",
Expand Down
18 changes: 11 additions & 7 deletions bricks/ui-test/src/custom-processors/get-tree-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface GraphData {

function getIcon(
nodeData: NodeGraphData,
commandDocList: CommandDoc[],
commandDocList: CommandDoc[]
): CommandIcon {
let icon: CommandIcon;

Expand Down Expand Up @@ -85,18 +85,22 @@ function getIcon(
}

function getDisplayLabel(nodeItem: NodeGraphData): string {
const flag =
nodeItem.flag && nodeItem.flag !== "none" ? `[${nodeItem.flag}] ` : "";

if (nodeItem.type === "suite") {
return nodeItem.name;
}

if (nodeItem.label) {
return `${nodeItem.name}: ${nodeItem.label}`;
return `${flag}${nodeItem.name}: ${nodeItem.label}`;
}

const literalParams = getLiteralParams(nodeItem.params);
const nodeLabel = `${flag}${nodeItem.name}`;
return literalParams.length === 0
? nodeItem.name
: `${nodeItem.name}: ${literalParams.join(", ")}`;
? nodeLabel
: `${nodeLabel}: ${literalParams.join(", ")}`;
}

function getLiteralParams(params: unknown[]): unknown[] {
Expand All @@ -118,7 +122,7 @@ function getLiteralParams(params: unknown[]): unknown[] {

export function getTreeData(
GraphData: GraphData,
commandDocList: CommandDoc[],
commandDocList: CommandDoc[]
): TestTreeData {
const {
topic_vertices: [rootData],
Expand All @@ -129,9 +133,9 @@ export function getTreeData(
const getChildVertices = (children: TestTreeData[]) => {
return sortBy(
vertices.filter((v) =>
children.find((c) => c.data.instanceId === v.instanceId),
children.find((c) => c.data.instanceId === v.instanceId)
),
"sort",
"sort"
);
};

Expand Down
1 change: 1 addition & 0 deletions bricks/ui-test/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export interface NodeGraphData {
params?: any;
type: NodeType;
sort?: number;
flag?: string;
}

export interface TreeNodeItemData extends NodeGraphData {
Expand Down

0 comments on commit bf5dcb2

Please sign in to comment.