Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): link to asset and refer to item icons #1272

Merged
merged 5 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions web/src/components/atoms/Icon/Icons/arrowUpRightSlash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions web/src/components/atoms/Icon/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {

import ArrowSquareOut from "./Icons/arrowSquareOut.svg";
import ArrowUpRight from "./Icons/arrowUpRight.svg";
import ArrowUpRightSlash from "./Icons/arrowUpRightSlash.svg";
import Asset from "./Icons/asset.svg";
import Boolean from "./Icons/boolean.svg";
import CheckSquare from "./Icons/checkSquare.svg";
Expand Down Expand Up @@ -123,6 +124,7 @@ export default {
asset: Asset,
listBullets: ListBullets,
arrowUpRight: ArrowUpRight,
arrowUpRightSlash: ArrowUpRightSlash,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Migration to arrowUpRightSlash icon is incomplete - found remaining unlinkSolid usages

The verification revealed that while arrowUpRightSlash is being used in some components, there are still two components using the old unlinkSolid icon:

  • web/src/components/molecules/Common/Form/AssetItem/index.tsx
  • web/src/components/molecules/Common/LinkAssetModal/LinkAssetModal.tsx

These components should be updated to use the new arrowUpRightSlash icon for consistency with the rest of the codebase.

🔗 Analysis chain

Verify the icon replacement across the codebase.

The icon mapping is correctly added. Since this icon is replacing unlinkSolid in the ReferenceFormItem component, let's verify there are no other components still using the old icon.


Let me try with a different command that doesn't rely on file type specifications.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining usage of unlinkSolid icon
# to ensure complete migration to arrowUpRightSlash

echo "Checking for remaining unlinkSolid icon usage..."
rg -l "unlinkSolid" --type ts --type tsx

echo "Checking for new arrowUpRightSlash icon usage..."
rg -l "arrowUpRightSlash" --type ts --type tsx

Length of output: 357


Script:

#!/bin/bash
# Search for unlinkSolid usage across all files
echo "Checking for remaining unlinkSolid icon usage..."
rg "unlinkSolid"

echo -e "\nChecking for new arrowUpRightSlash icon usage..."
rg "arrowUpRightSlash"

Length of output: 1074

numberNine: NumberNine,
link: Link,
linkSolid: LinkSolid,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from "@emotion/styled";
import { useState, useRef, useCallback, useMemo } from "react";
import { useRef, useCallback, useMemo } from "react";

import Button from "@reearth-cms/components/atoms/Button";
import Icon from "@reearth-cms/components/atoms/Icon";
Expand Down Expand Up @@ -74,7 +74,6 @@ const LinkAssetModal: React.FC<Props> = ({
onUploadAndLink,
}) => {
const t = useT();
const [hoveredAssetId, setHoveredAssetId] = useState<string>();
const resetFlag = useRef(false);

const options: OptionConfig = useMemo(
Expand Down Expand Up @@ -127,14 +126,10 @@ const LinkAssetModal: React.FC<Props> = ({
width: 48,
minWidth: 48,
render: (_, asset) => {
const isLink =
(asset.id === linkedAsset?.id && hoveredAssetId !== asset.id) ||
(asset.id !== linkedAsset?.id && hoveredAssetId === asset.id);
const isLink = asset.id !== linkedAsset?.id;
return (
<Button
type="link"
onMouseEnter={() => setHoveredAssetId(asset.id)}
onMouseLeave={() => setHoveredAssetId(undefined)}
icon={<Icon icon={isLink ? "linkSolid" : "unlinkSolid"} size={16} />}
onClick={() => onLinkClick(isLink, asset)}
/>
Expand Down Expand Up @@ -184,7 +179,7 @@ const LinkAssetModal: React.FC<Props> = ({
minWidth: 100,
},
],
[hoveredAssetId, linkedAsset?.id, onLinkClick, t],
[linkedAsset?.id, onLinkClick, t],
);

const handleChange = useCallback(
Expand Down Expand Up @@ -242,9 +237,7 @@ const LinkAssetModal: React.FC<Props> = ({
width="70vw"
styles={{
body: {
minHeight: "50vh",
position: "relative",
padding: "12px",
height: "70vh",
},
}}>
<ResizableProTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ const StyledProTable = styled(ProTable)<{
overflow: auto !important;
height: calc(100% - 47px);
}
.ant-pro-table-list-toolbar-container {
flex-direction: row;
}
.ant-pro-table-list-toolbar-left {
flex: 1;
max-width: calc(100% - 150px);
margin: 0;
.ant-pro-table-list-toolbar-search {
width: 100%;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ const ReferenceFormItem: React.FC<Props> = ({
disabled={disabled}
/>
{!disabled && (
<Button
<UnreferButton
type="link"
icon={<Icon icon={"unlinkSolid"} size={16} />}
icon={<Icon icon={"arrowUpRightSlash"} size={16} />}
onClick={() => {
onChange?.();
}}
Expand All @@ -101,7 +101,7 @@ const ReferenceFormItem: React.FC<Props> = ({
)}
{!disabled && (
<StyledButton onClick={handleClick} type="primary">
<Icon icon="arrowUpRight" size={14} /> {t("Refer to item")}
<Icon icon="arrowUpRight" size={14} /> {value ? t("Replace item") : t("Refer to item")}
</StyledButton>
)}
{!!onSearchTerm &&
Expand Down Expand Up @@ -130,13 +130,14 @@ const ReferenceFormItem: React.FC<Props> = ({
);
};

const UnreferButton = styled(Button)`
color: #000000d9;
`;

const StyledButton = styled(Button)`
display: flex;
align-items: center;
margin-top: 8px;
> span {
padding: 4px;
}
`;

const ReferenceItemWrapper = styled.div`
Expand Down
19 changes: 6 additions & 13 deletions web/src/components/molecules/Content/LinkItemModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from "@emotion/styled";
import { useState, useCallback, useMemo } from "react";
import { useCallback, useMemo } from "react";

import Button from "@reearth-cms/components/atoms/Button";
import Icon from "@reearth-cms/components/atoms/Icon";
Expand Down Expand Up @@ -53,7 +53,6 @@ const LinkItemModal: React.FC<Props> = ({
onChange,
onCheckItemReference,
}) => {
const [hoveredAssetId, setHoveredItemId] = useState<string>();
const t = useT();
const { confirm } = Modal;
const { value, pagination, handleInput } = useHooks(
Expand Down Expand Up @@ -110,16 +109,12 @@ const LinkItemModal: React.FC<Props> = ({
width: 48,
minWidth: 48,
render: (_, item) => {
const link =
(item.id === linkedItem && hoveredAssetId !== item.id) ||
(item.id !== linkedItem && hoveredAssetId === item.id);
const isLink = item.id !== linkedItem;
return (
<Button
type="link"
onMouseEnter={() => setHoveredItemId(item.id)}
onMouseLeave={() => setHoveredItemId(undefined)}
icon={<Icon icon={link ? "linkSolid" : "unlinkSolid"} size={16} />}
onClick={() => handleClick(link, item)}
icon={<Icon icon={isLink ? "arrowUpRight" : "arrowUpRightSlash"} size={18} />}
onClick={() => handleClick(isLink, item)}
/>
);
},
Expand Down Expand Up @@ -158,7 +153,7 @@ const LinkItemModal: React.FC<Props> = ({
render: (_text, record) => dateTimeFormat(record.createdAt),
},
],
[t, linkedItem, hoveredAssetId, handleClick],
[t, linkedItem, handleClick],
);

const toolbar: ListToolBarProps = useMemo(
Expand Down Expand Up @@ -188,9 +183,7 @@ const LinkItemModal: React.FC<Props> = ({
onCancel={onLinkItemModalCancel}
styles={{
body: {
minHeight: "50vh",
position: "relative",
padding: "12px",
height: "70vh",
caichi-t marked this conversation as resolved.
Show resolved Hide resolved
},
}}>
<ResizableProTable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ const LinkItemRequestModal: React.FC<Props> = ({
width="70vw"
styles={{
body: {
minHeight: "50vh",
position: "relative",
padding: "12px 12px 0",
height: "70vh",
},
}}
afterClose={() => {
Expand Down
Loading
Loading