* Admin-configurable display locale * Add i18n-js and namespacing * Basic tests and clean up * A few test adjustments * Update vendor cache * Fix a few tests * Fix a few tests * Update app/views/articles/_actions.html.erb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update app/views/articles/_comments_actions.html.erb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update app/views/articles/_single_story.html.erb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update app/views/articles/_single_story.html.erb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update app/views/comments/_comment_header.html.erb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update app/views/layouts/_sidebar_tags.html.erb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update app/views/listings/index.html.erb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update spec/system/homepage/user_visits_homepage_articles_spec.rb Co-authored-by: Michael Kohl <citizen428@dev.to> * Update spec/system/user/view_user_index_spec.rb Co-authored-by: Michael Kohl <citizen428@dev.to> * Alphabetical locale page * Add activerecord custom validation error translations * Add i18n to webpacker * Fix a few tests * Adjust error messages * Add i18n-tasks * Adjust JS to get working with jest * Adjust the way translations are pulled in * Adjust jest tests * Remove time localization * Remove superfluous public js * Add basic tests for i18n application controller * Remove unnecessary content Co-authored-by: Michael Kohl <citizen428@dev.to>
74 lines
2 KiB
JavaScript
74 lines
2 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import { h, Component, createRef } from 'preact';
|
|
import { listingPropTypes } from './listingPropTypes';
|
|
import { Button, Dropdown } from '@crayons';
|
|
import { locale } from '@utilities/locale';
|
|
|
|
const Icon = () => (
|
|
<svg
|
|
width="24"
|
|
height="24"
|
|
viewBox="0 0 24 24"
|
|
className="crayons-icon"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
>
|
|
<path
|
|
fill-rule="evenodd"
|
|
clip-rule="evenodd"
|
|
d="M7 12a2 2 0 11-4 0 2 2 0 014 0zm7 0a2 2 0 11-4 0 2 2 0 014 0zm5 2a2 2 0 100-4 2 2 0 000 4z"
|
|
/>
|
|
</svg>
|
|
);
|
|
|
|
export class DropdownMenu extends Component {
|
|
componentRef = createRef();
|
|
|
|
static propTypes = {
|
|
isOwner: PropTypes.bool.isRequired,
|
|
listing: listingPropTypes.isRequired,
|
|
};
|
|
|
|
render() {
|
|
const { listing, isOwner, isModal } = this.props;
|
|
const { id, category, slug } = listing;
|
|
const editUrl = `/listings/${id}/edit`;
|
|
const reportUrl = `/report-abuse?url=https://dev.to/listings/${category}/${slug}`;
|
|
|
|
return (
|
|
<div
|
|
className="single-listing__dropdown absolute right-0 top-0"
|
|
ref={this.componentRef}
|
|
>
|
|
<Button
|
|
id={`listing-header-dropdown-btn-${id}-${isModal ? 'modal' : ''}`}
|
|
variant="ghost"
|
|
contentType="icon"
|
|
tagName="button"
|
|
aria-label="Listing options"
|
|
icon={Icon}
|
|
/>
|
|
<Dropdown
|
|
className="absolute right-0 top-100 p-1"
|
|
triggerButtonId={`listing-header-dropdown-btn-${id}-${
|
|
isModal ? 'modal' : ''
|
|
}`}
|
|
dropdownContentId={`listing-header-dropdown-${id}-${
|
|
isModal ? 'modal' : ''
|
|
}`}
|
|
>
|
|
<div>
|
|
{isOwner ? (
|
|
<a href={editUrl} className="crayons-link crayons-link--block">
|
|
Edit
|
|
</a>
|
|
) : (
|
|
<a href={reportUrl} className="crayons-link crayons-link--block">
|
|
{locale('core.report_abuse')}
|
|
</a>
|
|
)}
|
|
</div>
|
|
</Dropdown>
|
|
</div>
|
|
);
|
|
}
|
|
}
|