/* eslint-disable wpcalypso/jsx-classname-namespace */
import { Component } from 'react';
import { withoutHttp } from 'calypso/lib/url';
import { html } from '../indices-to-html';
import { linkProps } from './functions';
import Gridicon from './gridicons';
const Snippet = ( { note, snippet, url } ) => (
{ snippet.text }
);
class UserHeader extends Component {
render() {
const grav = this.props.user.media[ 0 ];
const grav_tag =
;
const base_home_url = this.props.user.ranges[ 0 ].url;
// Some site notifications populate Id with the siteId, so consider the userId falsy in this
// case.
const userId =
this.props.user.ranges[ 0 ].id !== this.props.user.ranges[ 0 ].site_id &&
this.props.user.ranges[ 0 ].id;
const home_url = userId ? `https://wordpress.com/reader/users/id/${ userId }` : base_home_url;
const note = this.props.note;
const get_home_link = function ( classNames, children ) {
if ( home_url ) {
return (
{ children }
);
}
return (
// eslint-disable-next-line jsx-a11y/anchor-is-valid
{ children }
);
};
if ( this.props.user.ranges.length > 1 ) {
const usercopy = {};
usercopy.ranges = this.props.user.ranges;
usercopy.text = this.props.user.text;
return (
);
}
return (
{ get_home_link( 'wpnc__user__site', grav_tag ) }
{ get_home_link( 'wpnc__user__home', this.props.user.text ) }
);
}
}
class BloggingPromptHeader extends Component {
render() {
const icon = this.props.site.media[ 0 ];
const img_tag =
;
const home_url = this.props.site.ranges[ 0 ].url;
// Notifications are hosted on widgets.wp.com on WordPress.com
const host =
document.location.host === 'widgets.wp.com' ? 'wordpress.com' : document.location.host;
const settings_url =
document.location.protocol + '//' + host + '/me/notifications#' + withoutHttp( home_url );
const get_home_link = function ( classNames, children ) {
if ( home_url ) {
return (
{ children }
);
}
return (
// eslint-disable-next-line jsx-a11y/anchor-is-valid
{ children }
);
};
return (
{ img_tag }
{ this.props.prompt.text }
{ get_home_link( 'wpnc__user__home', this.props.site.text ) }
);
}
}
class Header extends Component {
render() {
const subject = (
);
return (
{ subject }
);
}
}
class SummaryInSingle extends Component {
render() {
let header_url = this.props.note.url;
let parser;
if ( ! this.props.note.header || 0 === this.props.note.header.length ) {
return ;
}
if ( this.props.note.header.length > 1 ) {
if ( 'user' === this.props.note.header[ 0 ].ranges[ 0 ].type ) {
if ( this.props.note.type === 'comment' ) {
if ( this.props.note.meta.ids.parent_comment ) {
parser = document.createElement( 'a' );
parser.href = this.props.note.url;
parser.hash = '#comment-' + this.props.note.meta.ids.parent_comment;
header_url = parser.href;
}
}
return (
);
}
if ( this.props.note.type === 'blogging_prompts_note' ) {
return (
);
}
return (
);
}
return (
);
}
}
export default SummaryInSingle;