Skip to content

Commit

Permalink
fix: clarify custom truncate from npm truncate (#464)
Browse files Browse the repository at this point in the history
chore: add @ where we can for less long imports
  • Loading branch information
timothycarambat authored Dec 17, 2023
1 parent 2def9a6 commit 1c549e2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { useState } from "react";
import {
formatDate,
getFileExtension,
truncate,
} from "../../../../../../utils/directories";
middleTruncate,
} from "@/utils/directories";
import { File, Trash } from "@phosphor-icons/react";
import System from "../../../../../../models/system";
import System from "@/models/system";
import debounce from "lodash.debounce";

export default function FileRow({
Expand Down Expand Up @@ -76,7 +76,7 @@ export default function FileRow({
onMouseLeave={handleMouseLeave}
>
<p className="whitespace-nowrap overflow-hidden">
{truncate(item.title, 17)}
{middleTruncate(item.title, 17)}
</p>
{showTooltip && (
<div className="absolute left-0 bg-white text-black p-1.5 rounded shadow-lg whitespace-nowrap">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from "react";
import FileRow from "../FileRow";
import { CaretDown, FolderNotch } from "@phosphor-icons/react";
import { truncate } from "../../../../../../utils/directories";
import { middleTruncate } from "@/utils/directories";

export default function FolderRow({
item,
Expand Down Expand Up @@ -50,7 +50,7 @@ export default function FolderRow({
weight="fill"
/>
<p className="whitespace-nowrap overflow-show">
{truncate(item.name, 40)}
{middleTruncate(item.name, 40)}
</p>
</div>
<p className="col-span-2 pl-3.5" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import UploadFile from "../UploadFile";
import PreLoader from "../../../../Preloader";
import PreLoader from "@/components/Preloader";
import { useEffect, useState } from "react";
import FolderRow from "./FolderRow";
import pluralize from "pluralize";
import Workspace from "../../../../../models/workspace";

export default function Directory({
files,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { useState } from "react";
import {
formatDate,
getFileExtension,
truncate,
} from "../../../../../../utils/directories";
middleTruncate,
} from "@/utils/directories";
import { ArrowUUpLeft, File } from "@phosphor-icons/react";
import Workspace from "../../../../../../models/workspace";
import Workspace from "@/models/workspace";
import debounce from "lodash.debounce";

export default function WorkspaceFileRow({
Expand Down Expand Up @@ -65,7 +65,7 @@ export default function WorkspaceFileRow({
onMouseLeave={handleMouseLeave}
>
<p className="whitespace-nowrap overflow-hidden">
{truncate(item.title, 17)}
{middleTruncate(item.title, 17)}
</p>
{showTooltip && (
<div className="absolute left-0 bg-white text-black p-1.5 rounded shadow-lg whitespace-nowrap">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PreLoader from "../../../../Preloader";
import { dollarFormat } from "../../../../../utils/numbers";
import PreLoader from "@/components/Preloader";
import { dollarFormat } from "@/utils/numbers";
import WorkspaceFileRow from "./WorkspaceFileRow";

export default function WorkspaceDirectory({
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/utils/directories.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function getFileExtension(path) {
return path?.split(".")?.slice(-1)?.[0] || "file";
}

export function truncate(str, n) {
export function middleTruncate(str, n) {
const fileExtensionPattern = /(\..+)$/;
const extensionMatch = str.match(fileExtensionPattern);

Expand Down

0 comments on commit 1c549e2

Please sign in to comment.