Skip to content

Commit

Permalink
check if click handler for bookmarking is present before rendering bu…
Browse files Browse the repository at this point in the history
…tton for bookmarking
  • Loading branch information
BrittanyIRL committed Jun 25, 2020
1 parent 32ab304 commit d38a807
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
3 changes: 0 additions & 3 deletions assets/src/dashboard/app/views/templateDetails/index.js
Expand Up @@ -22,7 +22,6 @@ import { sprintf, __ } from '@wordpress/i18n';
* External dependencies
*/
import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
import { useFeature } from 'flagged';

/**
* Internal dependencies
Expand Down Expand Up @@ -65,7 +64,6 @@ function TemplateDetails() {
const [orderedTemplates, setOrderedTemplates] = useState([]);
const { pageSize } = usePagePreviewSize({ isGrid: true });
const { isRTL } = useConfig();
const enableBookmarks = useFeature('enableBookmarkActions');

const {
state: {
Expand Down Expand Up @@ -206,7 +204,6 @@ function TemplateDetails() {
<DetailViewNavBar
ctaText={__('Use template', 'web-stories')}
handleCta={() => createStoryFromTemplate(template)}
isBookmarkingEnabled={enableBookmarks}
/>
</Layout.Fixed>
<Layout.Scrollable>
Expand Down
10 changes: 2 additions & 8 deletions assets/src/dashboard/components/detailViewNavBar/index.js
Expand Up @@ -79,19 +79,14 @@ const CapitalizedButton = styled(Button)`
text-transform: uppercase;
`;

export function DetailViewNavBar({
handleCta,
handleBookmarkClick,
isBookmarkingEnabled,
ctaText,
}) {
export function DetailViewNavBar({ handleCta, handleBookmarkClick, ctaText }) {
return (
<Nav>
<Container>
<CloseLink href={parentRoute()}>{__('Close', 'web-stories')}</CloseLink>
</Container>
<Container>
{isBookmarkingEnabled && (
{handleBookmarkClick && (
<BookmarkToggle onClick={handleBookmarkClick} />
)}
<CapitalizedButton type={BUTTON_TYPES.CTA} onClick={handleCta}>
Expand All @@ -106,5 +101,4 @@ DetailViewNavBar.propTypes = {
ctaText: PropTypes.string.isRequired,
handleBookmarkClick: PropTypes.func,
handleCta: PropTypes.func.isRequired,
isBookmarkingEnabled: PropTypes.bool,
};
12 changes: 10 additions & 2 deletions assets/src/dashboard/components/detailViewNavBar/stories/index.js
Expand Up @@ -17,7 +17,7 @@
* External dependencies
*/
import { action } from '@storybook/addon-actions';
import { boolean, text } from '@storybook/addon-knobs';
import { text } from '@storybook/addon-knobs';

/**
* Internal dependencies
Expand All @@ -33,7 +33,15 @@ export const _default = () => {
<DetailViewNavBar
handleCta={action('handle cta clicked')}
handleBookmarkClick={action('handle bookmark clicked')}
isBookmarkingEnabled={boolean('isBookmarkingEnabled')}
ctaText={text('ctaText', 'Use template')}
/>
);
};

export const NoBookmarking = () => {
return (
<DetailViewNavBar
handleCta={action('handle cta clicked')}
ctaText={text('ctaText', 'Use template')}
/>
);
Expand Down

0 comments on commit d38a807

Please sign in to comment.