2020-02-11 20:04:51 +01:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
2020-10-28 20:18:58 +01:00
|
|
|
import classnames from 'classnames';
|
2020-02-11 20:04:51 +01:00
|
|
|
import Page from 'component/page';
|
|
|
|
import ClaimListDiscover from 'component/claimListDiscover';
|
2020-02-12 16:10:17 +01:00
|
|
|
import ClaimEffectiveAmount from 'component/claimEffectiveAmount';
|
2020-10-28 20:18:58 +01:00
|
|
|
import SearchTopClaim from 'component/searchTopClaim';
|
2021-03-03 20:23:42 +01:00
|
|
|
import * as CS from 'constants/claim_search';
|
2020-10-28 20:18:58 +01:00
|
|
|
import Button from 'component/button';
|
2020-12-04 01:10:23 +01:00
|
|
|
import I18nMessage from 'component/i18nMessage';
|
|
|
|
import * as PAGES from 'constants/pages';
|
2020-02-11 20:04:51 +01:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
name: string,
|
2021-03-03 20:23:42 +01:00
|
|
|
beginPublish: (string) => void,
|
2020-02-11 20:04:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
function TopPage(props: Props) {
|
2020-12-04 01:10:23 +01:00
|
|
|
const { name, beginPublish } = props;
|
2020-10-28 20:18:58 +01:00
|
|
|
const [channelActive, setChannelActive] = React.useState(false);
|
2020-12-04 01:10:23 +01:00
|
|
|
// if the query was actually '@name', still offer repost for 'name'
|
|
|
|
const queryName = name[0] === '@' ? name.slice(1) : name;
|
2020-02-11 20:04:51 +01:00
|
|
|
return (
|
|
|
|
<Page>
|
2020-12-08 03:53:06 +01:00
|
|
|
<SearchTopClaim query={name} hideLink setChannelActive={setChannelActive} />
|
2020-02-11 20:04:51 +01:00
|
|
|
<ClaimListDiscover
|
2020-12-04 01:10:23 +01:00
|
|
|
name={channelActive ? `@${queryName}` : queryName}
|
2021-03-03 20:23:42 +01:00
|
|
|
defaultFreshness={CS.FRESH_ALL}
|
|
|
|
defaultOrderBy={CS.ORDER_BY_TOP}
|
|
|
|
streamType={CS.CONTENT_ALL}
|
2020-12-04 01:10:23 +01:00
|
|
|
meta={
|
2020-12-16 19:38:18 +01:00
|
|
|
<div className="search__top-links">
|
|
|
|
<I18nMessage
|
|
|
|
tokens={{
|
|
|
|
repost: (
|
|
|
|
<Button
|
|
|
|
button="secondary"
|
|
|
|
navigate={`/$/${PAGES.REPOST_NEW}?to=${queryName}`}
|
|
|
|
label={__('Repost Here')}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
publish: <Button button="secondary" onClick={() => beginPublish(queryName)} label={'Publish Here'} />,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
%repost% %publish%
|
|
|
|
</I18nMessage>
|
|
|
|
</div>
|
2020-12-04 01:10:23 +01:00
|
|
|
}
|
2020-10-23 20:57:40 +02:00
|
|
|
includeSupportAction
|
2021-03-03 20:23:42 +01:00
|
|
|
renderProperties={(claim) => (
|
2020-10-28 20:18:58 +01:00
|
|
|
<span className="claim-preview__custom-properties">
|
|
|
|
{claim.meta.is_controlling && <span className="help--inline">{__('Currently winning')}</span>}
|
2020-02-12 16:10:17 +01:00
|
|
|
<ClaimEffectiveAmount uri={claim.repost_url || claim.canonical_url} />
|
|
|
|
</span>
|
|
|
|
)}
|
2020-10-28 20:18:58 +01:00
|
|
|
header={
|
2020-11-13 21:25:18 +01:00
|
|
|
<div className="claim-search__menu-group">
|
2020-10-28 20:18:58 +01:00
|
|
|
<Button
|
2020-12-04 01:10:23 +01:00
|
|
|
label={queryName}
|
2020-10-28 20:18:58 +01:00
|
|
|
button="alt"
|
|
|
|
onClick={() => setChannelActive(false)}
|
|
|
|
className={classnames('button-toggle', {
|
|
|
|
'button-toggle--active': !channelActive,
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
<Button
|
2020-12-04 01:10:23 +01:00
|
|
|
label={`@${queryName}`}
|
2020-10-28 20:18:58 +01:00
|
|
|
button="alt"
|
|
|
|
onClick={() => setChannelActive(true)}
|
|
|
|
className={classnames('button-toggle', {
|
|
|
|
'button-toggle--active': channelActive,
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
}
|
2020-02-11 20:04:51 +01:00
|
|
|
/>
|
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TopPage;
|