Skip to content

Commit 9442afc

Browse files
Blazing-Mikekof
andauthored
fix: Long redirects urls and paths don't shorten in the UI (#4944) (#4988)
## Description fix issue #4944 long redirect urls don't shorten, they extend across Project seetings container and parts of it disappears which make UI looks broken. i added a word-break to the links, set a width for old link and max-width for the new-path link. ![Screen Shot 2025-03-12 at 12 02 52 PM](https://github.com/user-attachments/assets/72743a23-9f8b-4df3-abca-65524db8df91) ## Steps for reproduction 1. click on Menu button 2. click on "Project settings" Menu item 3. Click on the Redirects on the sidebar 4. Input old-path and new-path or URL 5. Click Add ## Code Review - [ ] hi @kof, I need you to do - conceptual review (architecture, feature-correctness) - detailed review (read every line) - test it on preview ## Before requesting a review - [x] made a self-review - [ ] added inline comments where things may be not obvious (the "why", not "what") ## Before merging - [x] tested locally and on preview environment (preview dev login: 0000) - [ ] updated [test cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md) document - [ ] added tests - [ ] if any new env variables are added, added them to `.env` file --------- Co-authored-by: Oleg Isonen <[email protected]>
1 parent 62b0418 commit 9442afc

File tree

1 file changed

+28
-20
lines changed

1 file changed

+28
-20
lines changed

apps/builder/app/builder/features/project-settings/section-redirects.tsx

+28-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
import { useState, type ChangeEvent, useRef } from "react";
2-
import { flushSync } from "react-dom";
31
import { useStore } from "@nanostores/react";
42
import {
5-
Grid,
3+
Button,
64
Flex,
5+
Grid,
6+
InputErrorsTooltip,
77
InputField,
8-
Button,
9-
Text,
10-
theme,
8+
Link,
119
List,
1210
ListItem,
13-
SmallIconButton,
14-
InputErrorsTooltip,
1511
Select,
16-
Link,
17-
truncate,
12+
SmallIconButton,
13+
Text,
14+
theme,
1815
Tooltip,
1916
} from "@webstudio-is/design-system";
2017
import { ArrowRightIcon, TrashIcon } from "@webstudio-is/icons";
@@ -23,16 +20,19 @@ import {
2320
PageRedirect,
2421
ProjectNewRedirectPath,
2522
} from "@webstudio-is/sdk";
23+
import { useRef, useState, type ChangeEvent } from "react";
24+
import { flushSync } from "react-dom";
25+
import { matchPathnamePattern } from "~/builder/shared/url-pattern";
2626
import { $pages, $publishedOrigin } from "~/shared/nano-states";
2727
import { serverSyncStore } from "~/shared/sync";
28-
import { matchPathnamePattern } from "~/builder/shared/url-pattern";
2928
import { getExistingRoutePaths, sectionSpacing } from "./utils";
3029

3130
export const SectionRedirects = () => {
3231
const publishedOrigin = useStore($publishedOrigin);
3332
const [redirects, setRedirects] = useState(
3433
() => $pages.get()?.redirects ?? []
3534
);
35+
3636
const [oldPath, setOldPath] = useState<string>("");
3737
const [newPath, setNewPath] = useState<string>("");
3838
const [httpStatus, setHttpStatus] =
@@ -224,7 +224,7 @@ export const SectionRedirects = () => {
224224
{redirectKeys.length > 0 ? (
225225
<Grid css={sectionSpacing}>
226226
<List asChild>
227-
<Flex direction="column" gap="1">
227+
<Flex direction="column" gap="1" align="stretch">
228228
{redirects.map((redirect, index) => {
229229
return (
230230
<ListItem asChild key={redirect.old} index={index}>
@@ -245,7 +245,10 @@ export const SectionRedirects = () => {
245245
redirect.old,
246246
publishedOrigin
247247
).toString()}
248-
css={truncate()}
248+
css={{
249+
width: theme.spacing[18],
250+
wordBreak: "break-all",
251+
}}
249252
target="_blank"
250253
>
251254
{redirect.old}
@@ -262,19 +265,24 @@ export const SectionRedirects = () => {
262265
redirect.new,
263266
publishedOrigin
264267
).toString()}
265-
css={truncate()}
268+
css={{
269+
wordBreak: "break-all",
270+
maxWidth: theme.spacing[30],
271+
}}
266272
target="_blank"
267273
>
268274
{redirect.new}
269275
</Link>
270276
</Tooltip>
271277
</Flex>
272-
<SmallIconButton
273-
variant="destructive"
274-
icon={<TrashIcon />}
275-
aria-label={`Delete redirect from ${redirect.old}`}
276-
onClick={() => handleDeleteRedirect(index)}
277-
/>
278+
<Flex gap="2">
279+
<SmallIconButton
280+
variant="destructive"
281+
icon={<TrashIcon />}
282+
aria-label={`Delete redirect from ${redirect.old}`}
283+
onClick={() => handleDeleteRedirect(index)}
284+
/>
285+
</Flex>
278286
</Flex>
279287
</ListItem>
280288
);

0 commit comments

Comments
 (0)