From b5dfe1233e9187a3732283f2b712fc44788b03bb Mon Sep 17 00:00:00 2001
From: zhom <2717306+zhom@users.noreply.github.com>
Date: Mon, 28 Jul 2025 02:15:27 +0400
Subject: [PATCH] refactor: trim long browser and profile names
---
src/components/profile-data-table.tsx | 80 +++++++++++++++++----------
src/lib/name-utils.ts | 9 +++
2 files changed, 61 insertions(+), 28 deletions(-)
create mode 100644 src/lib/name-utils.ts
diff --git a/src/components/profile-data-table.tsx b/src/components/profile-data-table.tsx
index 4b92865..64d54b3 100644
--- a/src/components/profile-data-table.tsx
+++ b/src/components/profile-data-table.tsx
@@ -52,6 +52,7 @@ import {
getBrowserIcon,
getCurrentOS,
} from "@/lib/browser-utils";
+import { trimName } from "@/lib/name-utils";
import { cn } from "@/lib/utils";
import type { BrowserProfile, StoredProxy } from "@/types";
import { Input } from "./ui/input";
@@ -416,8 +417,21 @@ export function ProfilesDataTable({
enableSorting: true,
sortingFn: "alphanumeric",
cell: ({ row }) => {
- const name: string = row.getValue("name");
- return
{name}
;
+ const rawName: string = row.getValue("name");
+ const name = getBrowserDisplayName(rawName);
+
+ if (name.length < 20) {
+ return {name}
;
+ }
+
+ return (
+
+
+ {trimName(name, 20)}
+
+ {name}
+
+ );
},
},
{
@@ -442,10 +456,22 @@ export function ProfilesDataTable({
},
cell: ({ row }) => {
const browser: string = row.getValue("browser");
+ const name = getBrowserDisplayName(browser);
+ if (name.length < 20) {
+ return (
+
+ {name}
+
+ );
+ }
+
return (
-
- {getBrowserDisplayName(browser)}
-
+
+
+ {trimName(name, 20)}
+
+ {name}
+
);
},
enableSorting: true,
@@ -506,29 +532,27 @@ export function ProfilesDataTable({
: "No proxy configured";
return (
-
-
-
-
- {profileHasProxy && (
-
- )}
- {proxyDisplayName.length > 10 ? (
-
- {proxyDisplayName.slice(0, 10)}...
-
- ) : (
-
- {profile.browser === "tor-browser"
- ? "Not supported"
- : proxyDisplayName}
-
- )}
-
-
- {tooltipText}
-
-
+
+
+
+ {profileHasProxy && (
+
+ )}
+ {proxyDisplayName.length > 10 ? (
+
+ {proxyDisplayName.slice(0, 10)}...
+
+ ) : (
+
+ {profile.browser === "tor-browser"
+ ? "Not supported"
+ : proxyDisplayName}
+
+ )}
+
+
+ {tooltipText}
+
);
},
},
diff --git a/src/lib/name-utils.ts b/src/lib/name-utils.ts
new file mode 100644
index 0000000..4f015ff
--- /dev/null
+++ b/src/lib/name-utils.ts
@@ -0,0 +1,9 @@
+/**
+ * Trims a name to a maximum length and adds ellipsis if needed
+ * @param name The name to trim
+ * @param maxLength Maximum length before truncation (default: 30)
+ * @returns Trimmed name with ellipsis if truncated
+ */
+export function trimName(name: string, maxLength: number = 30): string {
+ return name.length > maxLength ? `${name.substring(0, maxLength)}...` : name;
+}