Skip to content

Commit

Permalink
Add copy url button to profile pane
Browse files Browse the repository at this point in the history
  • Loading branch information
SupertigerDev committed Sep 24, 2024
1 parent 4a7d92a commit fb8be6c
Showing 1 changed file with 44 additions and 26 deletions.
70 changes: 44 additions & 26 deletions src/components/profile-pane/ProfilePane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export default function ProfilePane() {
user={user()!}
size={width() <= 500 ? 92 : 110}
/>
<Show when={!isMe() && !isMobileWidth()}>
<Show when={!isMobileWidth()}>
<ActionButtons
class={css`
background-color: ${bgColor()};
Expand Down Expand Up @@ -288,7 +288,7 @@ export default function ProfilePane() {
</div>
</FlexColumn>
</div>
<Show when={!isMe() && isMobileWidth()}>
<Show when={isMobileWidth()}>
<div
style={{
margin: "4px",
Expand Down Expand Up @@ -335,6 +335,7 @@ const ActionButtons = (props: {
const showProfileContext = (event: MouseEvent) => {
setContextPosition({ x: event.clientX, y: event.clientY });
};
const isMe = () => account.user()?.id === params.userId;

const friend = () => friends.get(params.userId);

Expand Down Expand Up @@ -399,7 +400,7 @@ const ActionButtons = (props: {
</CustomLink>
</Show>

{!isFollowing() && !isBlocked() && (
{!isFollowing() && !isBlocked() && !isMe() && (
<ActionButton
icon="add_circle"
label={t("profile.followButton")}
Expand All @@ -423,7 +424,7 @@ const ActionButtons = (props: {
onClick={removeClicked}
/>
)}
{showAddFriend() && (
{showAddFriend() && !isMe() && (
<ActionButton
icon="group_add"
label={t("profile.addFriendButton")}
Expand Down Expand Up @@ -456,9 +457,10 @@ const ActionButtons = (props: {
onClick={unblockClicked}
/>
</Show>

<ActionButton
icon="mail"
label={t("profile.messageButton")}
icon={isMe() ? "note_alt" : "mail"}
label={isMe() ? "Saved Notes" : t("profile.messageButton")}
color={props.primaryColor || "var(--primary-color)"}
onClick={onMessageClicked}
/>
Expand All @@ -485,43 +487,55 @@ function ProfileContextMenu(props: Omit<ContextMenuProps, "items">) {
const friend = () => friends.get(params.userId);

const isBlocked = () => friend()?.status === FriendStatus.BLOCKED;
const isMe = () => account.user()?.id === params.userId;

const items = () => {
const items: ContextMenuItem[] = [
{
id: "message",
label: "Message",
icon: "mail",
label: isMe() ? "Saved Notes" : "Message",
icon: isMe() ? "note_alt" : "mail",
onClick: onMessageClicked,
},
{ separator: true },
];

if (isBlocked()) {
items.push({
label: "Unblock",
icon: "block",
alert: true,
onClick: unblockClicked,
});
items.push(
{ separator: true },
{
label: "Unblock",
icon: "block",
alert: true,
onClick: unblockClicked,
}
);
} else {
if (!isMe()) {
items.push({
label: "Block",
icon: "block",
alert: true,
onClick: blockClicked,
});
}
}

if (!isMe()) {
items.push({
label: "Block",
icon: "block",
id: "report",
label: "Report",
icon: "flag",
alert: true,
onClick: blockClicked,
onClick: reportClicked,
});
}

items.push({
id: "report",
label: "Report",
icon: "flag",
alert: true,
onClick: reportClicked,
});
items.push(
{ separator: true },
{
label: "Copy Profile URL",
icon: "content_copy",
onClick: copyProfileClick,
},
{ label: "Copy ID", icon: "content_copy", onClick: copyIdClick }
);
return items;
Expand Down Expand Up @@ -551,6 +565,10 @@ function ProfileContextMenu(props: Omit<ContextMenuProps, "items">) {
const copyIdClick = () => {
copyToClipboard(params.userId);
};
const copyProfileClick = () => {
console.log(`${env.APP_URL}/app/profile/${params.userId}`);
copyToClipboard(`${env.APP_URL}/app/profile/${params.userId}`);
};

return <ContextMenu {...props} items={items()} />;
}
Expand Down

0 comments on commit fb8be6c

Please sign in to comment.