lbry-desktop/ui/component/fileTitleSection/view.jsx

128 lines
4.2 KiB
React
Raw Permalink Normal View History

2021-03-11 18:08:11 +01:00
// @flow
import * as React from 'react';
import { normalizeURI } from 'util/lbryURI';
2021-03-11 18:08:11 +01:00
import FilePrice from 'component/filePrice';
import ClaimInsufficientCredits from 'component/claimInsufficientCredits';
import FileSubtitle from 'component/fileSubtitle';
wip wip wip - everything but publish, autoplay, and styling collection publishing add channel to collection publish cleanup wip bump clear mass add after success move collection item management controls redirect replace to published collection id bump playlist selector on create bump use new collection add ui element bump wip gitignore add content json wip bump context add to playlist basic collections page style pass wip wip: edits, buttons, styles... change fileAuthor to claimAuthor update, pending bugfixes, delete modal progress, collection header, other bugfixes bump cleaning show page bugfix builtin collection headers no playlists, no grid title wip style tweaks use normal looking claim previews for collection tiles add collection changes style library previews collection menulist for delete/view on library delete modal works for unpublished rearrange collection publish tabs clean up collection publishing and items show on odysee begin collectoin edit header and css renaming better thumbnails bump fix collection publish redirect view collection in menu does something copy and thumbs list previews, pending, context menus, list page enter to add collection, lists page empty state playable lists only, delete feature, bump put fileListDownloaded back better collection titles improve collection claim details fix horiz more icon fix up channel page style, copy, bump refactor preview overlay properties, fix reposts showing as floppydisk add watch later toast, small overlay properties on wunderbar results, fix collection actions buttons bump cleanup cleaning, refactoring bump preview thumb styling, cleanup support discover page lists search sync, bump bump, fix sync more enforce builtin order for now new lists page empty state try to indicate unpublished edits in lists bump fix autoplay and linting consts, fix autoplay bugs fixes cleanup fix, bump lists experimental ui, fixes refactor listIndex out hack in collection fallback thumb bump
2021-02-06 08:03:51 +01:00
import ClaimAuthor from 'component/claimAuthor';
2021-03-11 18:08:11 +01:00
import Card from 'component/common/card';
import * as ICONS from 'constants/icons';
2021-07-06 20:29:38 +02:00
import * as PAGES from 'constants/pages';
2021-03-11 18:08:11 +01:00
import Icon from 'component/common/icon';
import I18nMessage from 'component/i18nMessage';
import Button from 'component/button';
import FileDescription from 'component/fileDescription';
import usePersistedState from 'effects/use-persisted-state';
2021-07-06 20:29:38 +02:00
import { ENABLE_MATURE } from 'config';
2021-03-11 18:08:11 +01:00
type Props = {
uri: string,
title: string,
nsfw: boolean,
isNsfwBlocked: boolean,
subCount: number,
channelClaimId?: string,
fetchSubCount: (string) => void,
2021-03-11 18:08:11 +01:00
};
function FileTitleSection(props: Props) {
2021-10-19 06:49:51 +02:00
const { title, uri, nsfw, isNsfwBlocked, subCount, channelClaimId, fetchSubCount } = props;
const [hasAcknowledgedSec, setHasAcknowledgedSec] = usePersistedState('sec-nag', false);
2021-03-11 18:08:11 +01:00
React.useEffect(() => {
if (channelClaimId) {
fetchSubCount(channelClaimId);
}
}, [channelClaimId, fetchSubCount]);
2021-03-11 18:08:11 +01:00
return (
<>
{!hasAcknowledgedSec && (
<div className="notice-message">
<Button button="close" icon={ICONS.REMOVE} onClick={() => setHasAcknowledgedSec(true)} />
<h1 className="section__title">{__('Help LBRY Save Crypto')}</h1>
<p className="section__subtitle">
{__('The US government is attempting to destroy the cryptocurrency industry. Can you help?')}{' '}
<Button label={__('Learn more and sign petition')} button="link" href="https://helplbrysavecrypto.com" />
</p>
</div>
)}
<Card
isPageTitle
noTitleWrap
title={
<React.Fragment>
{title}
{nsfw && (
<span className="media__title-badge">
<span className="badge badge--tag-mature">{__('Mature')}</span>
</span>
)}
</React.Fragment>
}
titleActions={<FilePrice uri={normalizeURI(uri)} type="filepage" />}
body={
<React.Fragment>
<ClaimInsufficientCredits uri={uri} />
2021-10-19 06:49:51 +02:00
<FileSubtitle uri={uri} />
</React.Fragment>
}
actions={
isNsfwBlocked ? (
<div className="main--empty">
<h2>
2021-07-06 20:29:38 +02:00
{!ENABLE_MATURE && (
<>
<Icon className="icon--hidden" icon={ICONS.EYE_OFF} />
{__('Mature content is not supported.')}
</>
)}
{ENABLE_MATURE && (
<>
<Icon className="icon--hidden" icon={ICONS.EYE_OFF} />
{__('Mature content blocked.')}
</>
)}
</h2>
<div>
2021-07-06 20:29:38 +02:00
{ENABLE_MATURE && (
<>
<I18nMessage
tokens={{
content_settings: (
<Button button="link" label={__('content settings')} navigate={`/$/${PAGES.SETTINGS}`} />
),
}}
>
Change this in your %content_settings%.
</I18nMessage>
</>
)}
{!ENABLE_MATURE && (
<>
<I18nMessage
tokens={{
download_url: <Button label={__('lbry.com')} button="link" href="https://lbry.com/get" />,
}}
>
You can download the LBRY Desktop or Android app on %download_url% and enable mature content in
Settings.
</I18nMessage>
</>
)}
</div>
2021-03-11 18:08:11 +01:00
</div>
) : (
<div className="section">
<ClaimAuthor channelSubCount={subCount} uri={uri} />
<FileDescription uri={uri} />
</div>
)
}
/>
</>
2021-03-11 18:08:11 +01:00
);
}
export default FileTitleSection;