fix: truncate long labels in nodes

pull/69/head^2
Artem Golub 3 years ago
parent ec82ef7364
commit cf49dfb15c

@ -1,4 +1,5 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { ServerIcon } from "@heroicons/react/outline";
import { truncateStr } from "../../utils"; import { truncateStr } from "../../utils";
import { IServiceNodeItem, CallbackFunction } from "../../types"; import { IServiceNodeItem, CallbackFunction } from "../../types";
import eventBus from "../../events/eventBus"; import eventBus from "../../events/eventBus";
@ -53,19 +54,21 @@ export default function ServiceNode(props: INodeProps) {
}} }}
></Popover> ></Popover>
)} )}
<div className="node-label w-full py-2 px-4"> <div className="relative node-label w-full py-2 px-4">
<> <>
{node.canvasConfig.service_name && ( {node.canvasConfig.service_name && (
<div className="text-sm font-semibold overflow-x-hidden"> <div className="text-sm font-semibold overflow-x-hidden">
{truncateStr(node.canvasConfig.service_name, 10)} {truncateStr(node.canvasConfig.service_name, 12)}
</div> </div>
)} )}
{node.serviceConfig.container_name && ( {node.serviceConfig.container_name && (
<div className="text-xs text-gray-500 overflow-x-hidden"> <div className="text-xs text-gray-500 overflow-x-hidden">
{truncateStr(node.serviceConfig.container_name, 10)} {truncateStr(node.serviceConfig.container_name, 20)}
</div> </div>
)} )}
<ServerIcon className="w-3 h-3 text-gray-600 absolute top-2 right-2" />
</> </>
</div> </div>
</div> </div>

@ -1,4 +1,5 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { DatabaseIcon } from "@heroicons/react/outline";
import { truncateStr } from "../../utils"; import { truncateStr } from "../../utils";
import { IVolumeNodeItem, CallbackFunction } from "../../types"; import { IVolumeNodeItem, CallbackFunction } from "../../types";
import eventBus from "../../events/eventBus"; import eventBus from "../../events/eventBus";
@ -53,13 +54,15 @@ export default function VolumeNode(props: INodeProps) {
}} }}
></Popover> ></Popover>
)} )}
<div className="node-label w-full py-2 px-4"> <div className="relative node-label w-full py-2 px-4">
<> <>
{node.volumeConfig.name && ( {node.volumeConfig.name && (
<div className="text-sm font-semibold overflow-x-hidden"> <div className="text-sm font-semibold overflow-x-hidden">
{truncateStr(node.volumeConfig.name, 10)} {truncateStr(node.volumeConfig.name, 20)}
</div> </div>
)} )}
<DatabaseIcon className="w-3 h-3 text-gray-600 absolute top-2 right-2" />
</> </>
</div> </div>
</div> </div>

Loading…
Cancel
Save