Skip to content

Commit

Permalink
CW-copy-link-in-2-steps
Browse files Browse the repository at this point in the history
Fixed text for Share
  • Loading branch information
MeyerPV committed Oct 10, 2024
1 parent 350b39d commit 28b27cf
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import copyToClipboard from "copy-to-clipboard";
import { selectUser } from "@/pages/Auth/store/selectors";
import { DiscussionService } from "@/services";
import { DeletePrompt, GlobalOverlay, ReportModal } from "@/shared/components";
import { DiscussionMessageOwnerType, EntityTypes, InboxItemType } from "@/shared/constants";
import { DiscussionMessageOwnerType, EntityTypes, InboxItemType, ShareButtonText } from "@/shared/constants";
import { useModal, useNotification } from "@/shared/hooks";
import {
FeedItemFollowState,
Expand Down Expand Up @@ -186,6 +186,7 @@ function DiscussionFeedCard(props, ref) {
getNonAllowedItems,
feedItemUserMetadata,
withoutMenu,
shareText: ShareButtonText.Stream
},
{
report: onReportModalOpen,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const useMenuItems = (
feedItem,
feedItemFollow,
feedItemUserMetadata,
shareText
} = options;
const {
report,
Expand Down Expand Up @@ -92,7 +93,7 @@ export const useMenuItems = (
},
{
id: FeedItemMenuItem.Share,
text: "Share",
text: shareText ?? "Share",
onClick: share,
icon: <Share3Icon />,
},
Expand Down
2 changes: 2 additions & 0 deletions src/pages/common/components/FeedItem/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
CommonFeedObjectUserUnique,
} from "@/shared/models";
import { FeedItemMenuItem } from "./constants";
import { ShareButtonText } from "@/shared/constants";

export type GetNonAllowedItemsOptions = (
type: CommonFeedType,
Expand All @@ -26,6 +27,7 @@ export interface GetAllowedItemsOptions {
getNonAllowedItems?: GetNonAllowedItemsOptions;
feedItemUserMetadata: CommonFeedObjectUserUnique | null;
withoutMenu?: boolean;
shareText?: ShareButtonText;
}

export type MenuItemOptions = Omit<GetAllowedItemsOptions, "feedItemFollow">;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { selectUser } from "@/pages/Auth/store/selectors";
import { useCommonMember, useProposalUserVote } from "@/pages/OldCommon/hooks";
import { ProposalService } from "@/services";
import { DeletePrompt, GlobalOverlay } from "@/shared/components";
import { InboxItemType } from "@/shared/constants";
import { InboxItemType, ShareButtonText } from "@/shared/constants";
import { useRoutesContext } from "@/shared/contexts";
import { useForceUpdate, useModal, useNotification } from "@/shared/hooks";
import {
Expand Down Expand Up @@ -195,6 +195,7 @@ const ProposalFeedCard = forwardRef<FeedItemRef, ProposalFeedCardProps>(
getNonAllowedItems,
feedItemUserMetadata,
withoutMenu,
shareText: ShareButtonText.Stream
},
{
report: () => {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DesktopMenu, MenuButton } from "@/shared/ui-kit";
import { StaticLinkType, generateStaticShareLink } from "@/shared/utils";
import { useMenuItems } from "./hooks";
import { useUpdateCommonSeenState } from "@/shared/hooks/useCases";
import { ShareButtonText } from "@/shared/constants";

interface ActionsButtonProps {
common: Common;
Expand All @@ -27,6 +28,7 @@ const ActionsButton: FC<ActionsButtonProps> = (props) => {
commonMember,
isFollowInProgress: commonFollow.isFollowInProgress,
isSearchActionAvailable: Boolean(onSearchClick),
shareText: ShareButtonText.Space,
},
{
share: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const useMenuItems = (
options: GetAllowedItemsOptions,
actions: Actions,
): Item[] => {
const { common } = options;
const { common, shareText } = options;
const { share, onFollowToggle, onSearchClick, markCommonAsSeen } = actions;

const items: Item[] = [
Expand All @@ -37,7 +37,7 @@ export const useMenuItems = (
},
{
id: CommonFeedMenuItem.Share,
text: "Share",
text: shareText ?? "Share",
onClick: share,
icon: <Share3Icon />,
},
Expand Down
2 changes: 2 additions & 0 deletions src/pages/commonFeed/utils/getAllowedItems.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { MenuItem as Item } from "@/shared/interfaces";
import { CirclesPermissions, Common, CommonMember } from "@/shared/models";
import { CommonFeedMenuItem } from "../constants";
import { ShareButtonText } from "@/shared/constants";

export interface Options {
common: Common;
commonMember: (CommonMember & CirclesPermissions) | null;
isFollowInProgress: boolean;
isSearchActionAvailable: boolean;
shareText?: ShareButtonText;
}

const MENU_ITEM_TO_CHECK_FUNCTION_MAP: Record<
Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/Dropdown/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
}

.custom-dropdown-wrapper__menu-list {
max-height: 16.875rem;
max-height: 18rem;
margin: 0;
padding: 0;
overflow-y: auto;
Expand Down
17 changes: 11 additions & 6 deletions src/shared/components/ElementDropdown/ElementDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classNames from "classnames";
import copyToClipboard from "copy-to-clipboard";
import { selectUser } from "@/pages/Auth/store/selectors";
import { MenuButton, ShareModal } from "@/shared/components";
import { Orientation, EntityTypes } from "@/shared/constants";
import { Orientation, EntityTypes, ShareButtonText } from "@/shared/constants";
import { useNotification, useModal } from "@/shared/hooks";
import {
CopyIcon,
Expand Down Expand Up @@ -165,9 +165,10 @@ const ElementDropdown: FC<ElementDropdownProps> = ({
}

if (!isChatMessage) {
const shareText = isDiscussionMessage ? ShareButtonText.Message : "Share";
items.push({
text: <ElementDropdownItem text="Share" icon={<Share3Icon />} />,
searchText: "Share",
text: <ElementDropdownItem text={shareText} icon={<Share3Icon />} />,
searchText: shareText,
value: ElementDropdownMenuItems.Share,
});
}
Expand Down Expand Up @@ -261,8 +262,12 @@ const ElementDropdown: FC<ElementDropdownProps> = ({

switch (selectedItem) {
case ElementDropdownMenuItems.Share:
copyToClipboard(staticShareLink);
notify("The link has copied!");
if(isDiscussionMessage) {
copyToClipboard(staticShareLink);
notify("The link has copied!");
} else {
onOpen();
}
break;
case ElementDropdownMenuItems.Copy:
copyToClipboard(
Expand Down Expand Up @@ -313,7 +318,7 @@ const ElementDropdown: FC<ElementDropdownProps> = ({

const menuInlineStyle = useMemo(
() => ({
height: `${2.5 * (ElementDropdownMenuItemsList.length || 1)}rem`,
height: `${3 * (ElementDropdownMenuItemsList.length || 1)}rem`,
}),
[ElementDropdownMenuItemsList],
);
Expand Down
8 changes: 4 additions & 4 deletions src/shared/components/ElementDropdown/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

.element-dropdown__menu-wrapper {
.element-dropdown__menu {
width: 10rem;
height: 5.625rem;
width: 14rem;
height: 9rem;
right: 0;
display: flex;
flex-direction: column;
Expand All @@ -16,9 +16,9 @@
display: flex;
align-items: center;
box-sizing: border-box;
height: 2.5rem;
height: 3rem;
padding: 0.65625rem 1.5rem;
font-size: $small;
font-size: $xsmall;
box-shadow: inset 0 -0.0625rem 0 var(--drop-shadow);

> :first-child {
Expand Down
1 change: 1 addition & 0 deletions src/shared/constants/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ export * from "./docChange";
export * from "./files";
export * from "./inboxAction";
export * from "./featureFlags";
export * from "./shareText";
5 changes: 5 additions & 0 deletions src/shared/constants/shareText.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export enum ShareButtonText {
Space = "Copy space link",
Stream = "Copy link",
Message = "Copy message link"
}

0 comments on commit 28b27cf

Please sign in to comment.