From c57d6a1fec325b1eea57f7e1d7c8104773016028 Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Wed, 14 Mar 2018 16:36:09 +0200 Subject: [PATCH] Fix FF bug on ManageListingCard --- .../ManageListingCard/ManageListingCard.css | 1 + .../ManageListingCard/ManageListingCard.js | 46 ++++++++++++++++--- .../ManageListingCard.test.js.snap | 29 ++---------- 3 files changed, 45 insertions(+), 31 deletions(-) diff --git a/src/components/ManageListingCard/ManageListingCard.css b/src/components/ManageListingCard/ManageListingCard.css index c6cf9610..62c9fd9b 100644 --- a/src/components/ManageListingCard/ManageListingCard.css +++ b/src/components/ManageListingCard/ManageListingCard.css @@ -15,6 +15,7 @@ display: flex; flex-direction: column; position: relative; + cursor: pointer; /* Remove link's hover effect */ &:hover { diff --git a/src/components/ManageListingCard/ManageListingCard.js b/src/components/ManageListingCard/ManageListingCard.js index ed67523f..b7b87b7f 100644 --- a/src/components/ManageListingCard/ManageListingCard.js +++ b/src/components/ManageListingCard/ManageListingCard.js @@ -8,7 +8,7 @@ import routeConfiguration from '../../routeConfiguration'; import { LISTING_STATE_PENDING_APPROVAL, LISTING_STATE_CLOSED, propTypes } from '../../util/types'; import { formatMoney } from '../../util/currency'; import { ensureOwnListing } from '../../util/data'; -import { createSlug } from '../../util/urlHelpers'; +import { LISTING_PAGE_PENDING_APPROVAL_VARIANT, createSlug } from '../../util/urlHelpers'; import { createResourceLocatorString } from '../../util/routes'; import { InlineTextButton, @@ -16,7 +16,6 @@ import { MenuLabel, MenuContent, MenuItem, - ListingLink, IconSpinner, ResponsiveImage, } from '../../components'; @@ -48,7 +47,7 @@ const priceData = (price, intl) => { return {}; }; -const createURL = (routes, listing) => { +const createEditListingURL = (routes, listing) => { const id = listing.id.uuid; const slug = createSlug(listing.attributes.title); const pathParams = { id, slug, type: 'edit', tab: 'description' }; @@ -56,6 +55,27 @@ const createURL = (routes, listing) => { return createResourceLocatorString('EditListingPage', routes, pathParams, {}); }; +const createListingURL = (routes, listing) => { + const id = listing.id.uuid; + const slug = createSlug(listing.attributes.title); + const isPendingApproval = listing.attributes.state === LISTING_STATE_PENDING_APPROVAL; + const linkProps = isPendingApproval + ? { + name: 'ListingPageVariant', + params: { + id, + slug, + variant: LISTING_PAGE_PENDING_APPROVAL_VARIANT, + }, + } + : { + name: 'ListingPage', + params: { id, slug }, + }; + + return createResourceLocatorString(linkProps.name, routes, linkProps.params, {}); +}; + // Cards are not fixed sizes - So, long words in title make flexboxed items to grow too big. // 1. We split title to an array of words and spaces. // "foo bar".split(/([^\s]+)/gi) => ["", "foo", " ", "bar", ""] @@ -196,7 +216,21 @@ export const ManageListingCardComponent = props => { }); return ( - +
{ + event.preventDefault(); + event.stopPropagation(); + + // ManageListingCard contains links, buttons and elements that are working with routing. + // This card doesn't work if or
-
+ ); }; diff --git a/src/components/ManageListingCard/__snapshots__/ManageListingCard.test.js.snap b/src/components/ManageListingCard/__snapshots__/ManageListingCard.test.js.snap index e3b8cdb3..a92cb51b 100644 --- a/src/components/ManageListingCard/__snapshots__/ManageListingCard.test.js.snap +++ b/src/components/ManageListingCard/__snapshots__/ManageListingCard.test.js.snap @@ -1,31 +1,10 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`ManageListingCard matches snapshot 1`] = ` -
@@ -157,5 +136,5 @@ exports[`ManageListingCard matches snapshot 1`] = ` />
- +
`;