Merge branch 'main' into lemmy-282/add-open-in-new-tab-setting
This commit is contained in:
commit
298577bf0f
16 changed files with 156 additions and 133 deletions
|
@ -276,10 +276,7 @@ hr {
|
||||||
}
|
}
|
||||||
|
|
||||||
.mini-overlay {
|
.mini-overlay {
|
||||||
position: absolute;
|
display: block;
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
padding: 2px;
|
|
||||||
height: 1.5em;
|
height: 1.5em;
|
||||||
width: 1.5em;
|
width: 1.5em;
|
||||||
background: rgba(0, 0, 0, 0.4);
|
background: rgba(0, 0, 0, 0.4);
|
||||||
|
|
|
@ -347,7 +347,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
||||||
</li>
|
</li>
|
||||||
)}
|
)}
|
||||||
{person && (
|
{person && (
|
||||||
<div id="dropdownUser" className="dropdown">
|
<li id="dropdownUser" className="dropdown">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn dropdown-toggle"
|
className="btn dropdown-toggle"
|
||||||
|
@ -398,7 +398,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</li>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
@ -367,7 +367,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
<Spinner />
|
<Spinner />
|
||||||
) : (
|
) : (
|
||||||
<span
|
<span
|
||||||
className="me-1 font-weight-bold"
|
className="me-1 fw-bold"
|
||||||
aria-label={I18NextService.i18n.t("number_of_points", {
|
aria-label={I18NextService.i18n.t("number_of_points", {
|
||||||
count: Number(this.commentView.counts.score),
|
count: Number(this.commentView.counts.score),
|
||||||
formattedCount: numToSI(
|
formattedCount: numToSI(
|
||||||
|
@ -420,7 +420,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="d-flex justify-content-between justify-content-lg-start flex-wrap text-muted font-weight-bold">
|
<div className="d-flex justify-content-between justify-content-lg-start flex-wrap text-muted fw-bold">
|
||||||
{this.props.showContext && this.linkBtn()}
|
{this.props.showContext && this.linkBtn()}
|
||||||
{this.props.markable && (
|
{this.props.markable && (
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -50,6 +50,7 @@ export class EmojiPicker extends Component<EmojiPickerProps, EmojiPickerState> {
|
||||||
pickerOptions={{}}
|
pickerOptions={{}}
|
||||||
></EmojiMart>
|
></EmojiMart>
|
||||||
</div>
|
</div>
|
||||||
|
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */}
|
||||||
<div
|
<div
|
||||||
onClick={linkEvent(this, this.togglePicker)}
|
onClick={linkEvent(this, this.togglePicker)}
|
||||||
className="click-away-container"
|
className="click-away-container"
|
||||||
|
|
|
@ -33,13 +33,12 @@ export class ImageUploadForm extends Component<
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<form className="image-upload-form d-inline">
|
<form className="image-upload-form d-inline">
|
||||||
<label
|
<label htmlFor={this.id} className="pointer text-muted small fw-bold">
|
||||||
htmlFor={this.id}
|
|
||||||
className="pointer text-muted small font-weight-bold"
|
|
||||||
>
|
|
||||||
{this.props.imageSrc ? (
|
{this.props.imageSrc ? (
|
||||||
<span className="d-inline-block position-relative">
|
<span className="d-inline-block position-relative">
|
||||||
|
{/* TODO: Create "Current Iamge" translation for alt text */}
|
||||||
<img
|
<img
|
||||||
|
alt=""
|
||||||
src={this.props.imageSrc}
|
src={this.props.imageSrc}
|
||||||
height={this.props.rounded ? 60 : ""}
|
height={this.props.rounded ? 60 : ""}
|
||||||
width={this.props.rounded ? 60 : ""}
|
width={this.props.rounded ? 60 : ""}
|
||||||
|
@ -47,12 +46,14 @@ export class ImageUploadForm extends Component<
|
||||||
this.props.rounded ? "rounded-circle" : ""
|
this.props.rounded ? "rounded-circle" : ""
|
||||||
}`}
|
}`}
|
||||||
/>
|
/>
|
||||||
<a
|
<button
|
||||||
|
className="position-absolute d-block p-0 end-0 border-0 top-0 bg-transparent text-white"
|
||||||
|
type="button"
|
||||||
onClick={linkEvent(this, this.handleRemoveImage)}
|
onClick={linkEvent(this, this.handleRemoveImage)}
|
||||||
aria-label={I18NextService.i18n.t("remove")}
|
aria-label={I18NextService.i18n.t("remove")}
|
||||||
>
|
>
|
||||||
<Icon icon="x" classes="mini-overlay" />
|
<Icon icon="x" classes="mini-overlay" />
|
||||||
</a>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<span className="btn btn-secondary">{this.props.uploadTitle}</span>
|
<span className="btn btn-secondary">{this.props.uploadTitle}</span>
|
||||||
|
|
|
@ -167,7 +167,7 @@ export class MarkdownTextArea extends Component<
|
||||||
onEmojiClick={e => this.handleEmoji(this, e)}
|
onEmojiClick={e => this.handleEmoji(this, e)}
|
||||||
disabled={this.isDisabled}
|
disabled={this.isDisabled}
|
||||||
></EmojiPicker>
|
></EmojiPicker>
|
||||||
<form className="btn btn-sm text-muted font-weight-bold">
|
<form className="btn btn-sm text-muted fw-bold">
|
||||||
<label
|
<label
|
||||||
htmlFor={`file-upload-${this.id}`}
|
htmlFor={`file-upload-${this.id}`}
|
||||||
className={`mb-0 ${
|
className={`mb-0 ${
|
||||||
|
@ -210,7 +210,7 @@ export class MarkdownTextArea extends Component<
|
||||||
{this.getFormatButton("spoiler", this.handleInsertSpoiler)}
|
{this.getFormatButton("spoiler", this.handleInsertSpoiler)}
|
||||||
<a
|
<a
|
||||||
href={markdownHelpUrl}
|
href={markdownHelpUrl}
|
||||||
className="btn btn-sm text-muted font-weight-bold"
|
className="btn btn-sm text-muted fw-bold"
|
||||||
title={I18NextService.i18n.t("formatting_help")}
|
title={I18NextService.i18n.t("formatting_help")}
|
||||||
rel={relTags}
|
rel={relTags}
|
||||||
>
|
>
|
||||||
|
|
|
@ -39,7 +39,7 @@ export class MomentTime extends Component<MomentTimeProps, any> {
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
data-tippy-content={this.createdAndModifiedTimes()}
|
data-tippy-content={this.createdAndModifiedTimes()}
|
||||||
className="moment-time font-italics pointer unselectable"
|
className="moment-time fst-italic pointer unselectable"
|
||||||
>
|
>
|
||||||
<Icon icon="edit-2" classes="icon-inline me-1" />
|
<Icon icon="edit-2" classes="icon-inline me-1" />
|
||||||
{formatPastDate(this.props.updated)}
|
{formatPastDate(this.props.updated)}
|
||||||
|
|
|
@ -106,8 +106,12 @@ export class SearchableSelect extends Component<
|
||||||
<button
|
<button
|
||||||
id={id}
|
id={id}
|
||||||
type="button"
|
type="button"
|
||||||
|
role="combobox"
|
||||||
className="form-select d-inline-block text-start"
|
className="form-select d-inline-block text-start"
|
||||||
aria-haspopup="listbox"
|
aria-haspopup="listbox"
|
||||||
|
aria-controls="searchable-select-input"
|
||||||
|
aria-activedescendant={options[selectedIndex].label}
|
||||||
|
aria-expanded={false}
|
||||||
data-bs-toggle="dropdown"
|
data-bs-toggle="dropdown"
|
||||||
onClick={linkEvent(this, focusSearch)}
|
onClick={linkEvent(this, focusSearch)}
|
||||||
ref={this.toggleButtonRef}
|
ref={this.toggleButtonRef}
|
||||||
|
@ -116,17 +120,14 @@ export class SearchableSelect extends Component<
|
||||||
? `${I18NextService.i18n.t("loading")}${loadingEllipses}`
|
? `${I18NextService.i18n.t("loading")}${loadingEllipses}`
|
||||||
: options[selectedIndex].label}
|
: options[selectedIndex].label}
|
||||||
</button>
|
</button>
|
||||||
<div
|
<div className="modlog-choices-font-size dropdown-menu w-100 p-2">
|
||||||
role="combobox"
|
|
||||||
aria-activedescendant={options[selectedIndex].label}
|
|
||||||
className="modlog-choices-font-size dropdown-menu w-100 p-2"
|
|
||||||
>
|
|
||||||
<div className="input-group">
|
<div className="input-group">
|
||||||
<span className="input-group-text">
|
<span className="input-group-text">
|
||||||
{loading ? <Spinner /> : <Icon icon="search" />}
|
{loading ? <Spinner /> : <Icon icon="search" />}
|
||||||
</span>
|
</span>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
id="searchable-select-input"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
ref={this.searchInputRef}
|
ref={this.searchInputRef}
|
||||||
onInput={linkEvent(this, handleSearch)}
|
onInput={linkEvent(this, handleSearch)}
|
||||||
|
|
|
@ -204,17 +204,17 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{community.removed && (
|
{community.removed && (
|
||||||
<small className="me-2 text-muted font-italic">
|
<small className="me-2 text-muted fst-italic">
|
||||||
{I18NextService.i18n.t("removed")}
|
{I18NextService.i18n.t("removed")}
|
||||||
</small>
|
</small>
|
||||||
)}
|
)}
|
||||||
{community.deleted && (
|
{community.deleted && (
|
||||||
<small className="me-2 text-muted font-italic">
|
<small className="me-2 text-muted fst-italic">
|
||||||
{I18NextService.i18n.t("deleted")}
|
{I18NextService.i18n.t("deleted")}
|
||||||
</small>
|
</small>
|
||||||
)}
|
)}
|
||||||
{community.nsfw && (
|
{community.nsfw && (
|
||||||
<small className="me-2 text-muted font-italic">
|
<small className="me-2 text-muted fst-italic">
|
||||||
{I18NextService.i18n.t("nsfw")}
|
{I18NextService.i18n.t("nsfw")}
|
||||||
</small>
|
</small>
|
||||||
)}
|
)}
|
||||||
|
@ -309,7 +309,7 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
|
||||||
const community_view = this.props.community_view;
|
const community_view = this.props.community_view;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ul className="list-inline mb-1 text-muted font-weight-bold">
|
<ul className="list-inline mb-1 text-muted fw-bold">
|
||||||
{amMod(this.props.moderators) && (
|
{amMod(this.props.moderators) && (
|
||||||
<>
|
<>
|
||||||
<li className="list-inline-item-action">
|
<li className="list-inline-item-action">
|
||||||
|
|
|
@ -44,7 +44,6 @@ interface AdminSettingsState {
|
||||||
instancesRes: RequestState<GetFederatedInstancesResponse>;
|
instancesRes: RequestState<GetFederatedInstancesResponse>;
|
||||||
bannedRes: RequestState<BannedPersonsResponse>;
|
bannedRes: RequestState<BannedPersonsResponse>;
|
||||||
leaveAdminTeamRes: RequestState<GetSiteResponse>;
|
leaveAdminTeamRes: RequestState<GetSiteResponse>;
|
||||||
emojiLoading: boolean;
|
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
themeList: string[];
|
themeList: string[];
|
||||||
isIsomorphic: boolean;
|
isIsomorphic: boolean;
|
||||||
|
@ -59,7 +58,6 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
|
||||||
bannedRes: { state: "empty" },
|
bannedRes: { state: "empty" },
|
||||||
instancesRes: { state: "empty" },
|
instancesRes: { state: "empty" },
|
||||||
leaveAdminTeamRes: { state: "empty" },
|
leaveAdminTeamRes: { state: "empty" },
|
||||||
emojiLoading: false,
|
|
||||||
loading: false,
|
loading: false,
|
||||||
themeList: [],
|
themeList: [],
|
||||||
isIsomorphic: false,
|
isIsomorphic: false,
|
||||||
|
@ -215,7 +213,6 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
|
||||||
onCreate={this.handleCreateEmoji}
|
onCreate={this.handleCreateEmoji}
|
||||||
onDelete={this.handleDeleteEmoji}
|
onDelete={this.handleDeleteEmoji}
|
||||||
onEdit={this.handleEditEmoji}
|
onEdit={this.handleEditEmoji}
|
||||||
loading={this.state.emojiLoading}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -345,35 +342,23 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleEditEmoji(form: EditCustomEmoji) {
|
async handleEditEmoji(form: EditCustomEmoji) {
|
||||||
this.setState({ emojiLoading: true });
|
|
||||||
|
|
||||||
const res = await HttpService.client.editCustomEmoji(form);
|
const res = await HttpService.client.editCustomEmoji(form);
|
||||||
if (res.state === "success") {
|
if (res.state === "success") {
|
||||||
updateEmojiDataModel(res.data.custom_emoji);
|
updateEmojiDataModel(res.data.custom_emoji);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({ emojiLoading: false });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleDeleteEmoji(form: DeleteCustomEmoji) {
|
async handleDeleteEmoji(form: DeleteCustomEmoji) {
|
||||||
this.setState({ emojiLoading: true });
|
|
||||||
|
|
||||||
const res = await HttpService.client.deleteCustomEmoji(form);
|
const res = await HttpService.client.deleteCustomEmoji(form);
|
||||||
if (res.state === "success") {
|
if (res.state === "success") {
|
||||||
removeFromEmojiDataModel(res.data.id);
|
removeFromEmojiDataModel(res.data.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({ emojiLoading: false });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleCreateEmoji(form: CreateCustomEmoji) {
|
async handleCreateEmoji(form: CreateCustomEmoji) {
|
||||||
this.setState({ emojiLoading: true });
|
|
||||||
|
|
||||||
const res = await HttpService.client.createCustomEmoji(form);
|
const res = await HttpService.client.createCustomEmoji(form);
|
||||||
if (res.state === "success") {
|
if (res.state === "success") {
|
||||||
updateEmojiDataModel(res.data.custom_emoji);
|
updateEmojiDataModel(res.data.custom_emoji);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({ emojiLoading: false });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { myAuthRequired, setIsoData } from "@utils/app";
|
import { myAuthRequired, setIsoData } from "@utils/app";
|
||||||
|
import { capitalizeFirstLetter } from "@utils/helpers";
|
||||||
import { Component, linkEvent } from "inferno";
|
import { Component, linkEvent } from "inferno";
|
||||||
import {
|
import {
|
||||||
CreateCustomEmoji,
|
CreateCustomEmoji,
|
||||||
|
@ -11,14 +12,13 @@ import { HttpService, I18NextService } from "../../services";
|
||||||
import { pictrsDeleteToast, toast } from "../../toast";
|
import { pictrsDeleteToast, toast } from "../../toast";
|
||||||
import { EmojiMart } from "../common/emoji-mart";
|
import { EmojiMart } from "../common/emoji-mart";
|
||||||
import { HtmlTags } from "../common/html-tags";
|
import { HtmlTags } from "../common/html-tags";
|
||||||
import { Icon } from "../common/icon";
|
import { Icon, Spinner } from "../common/icon";
|
||||||
import { Paginator } from "../common/paginator";
|
import { Paginator } from "../common/paginator";
|
||||||
|
|
||||||
interface EmojiFormProps {
|
interface EmojiFormProps {
|
||||||
onEdit(form: EditCustomEmoji): void;
|
onEdit(form: EditCustomEmoji): void;
|
||||||
onCreate(form: CreateCustomEmoji): void;
|
onCreate(form: CreateCustomEmoji): void;
|
||||||
onDelete(form: DeleteCustomEmoji): void;
|
onDelete(form: DeleteCustomEmoji): void;
|
||||||
loading: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EmojiFormState {
|
interface EmojiFormState {
|
||||||
|
@ -36,6 +36,7 @@ interface CustomEmojiViewForm {
|
||||||
keywords: string;
|
keywords: string;
|
||||||
changed: boolean;
|
changed: boolean;
|
||||||
page: number;
|
page: number;
|
||||||
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
|
@ -52,6 +53,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
keywords: x.keywords.map(x => x.keyword).join(" "),
|
keywords: x.keywords.map(x => x.keyword).join(" "),
|
||||||
changed: false,
|
changed: false,
|
||||||
page: 1 + Math.floor(index / this.itemsPerPage),
|
page: 1 + Math.floor(index / this.itemsPerPage),
|
||||||
|
loading: false,
|
||||||
})),
|
})),
|
||||||
page: 1,
|
page: 1,
|
||||||
};
|
};
|
||||||
|
@ -119,33 +121,39 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
.map((cv, index) => (
|
.map((cv, index) => (
|
||||||
<tr key={index} ref={e => (this.scrollRef[cv.shortcode] = e)}>
|
<tr key={index} ref={e => (this.scrollRef[cv.shortcode] = e)}>
|
||||||
<td style="text-align:center;">
|
<td style="text-align:center;">
|
||||||
<label
|
{cv.image_url.length > 0 && (
|
||||||
htmlFor={index.toString()}
|
<img
|
||||||
className="pointer text-muted small font-weight-bold"
|
className="icon-emoji-admin"
|
||||||
>
|
src={cv.image_url}
|
||||||
{cv.image_url.length > 0 && (
|
alt={cv.alt_text}
|
||||||
<img
|
/>
|
||||||
className="icon-emoji-admin"
|
)}
|
||||||
src={cv.image_url}
|
{cv.image_url.length === 0 && (
|
||||||
/>
|
<form>
|
||||||
)}
|
<label
|
||||||
{cv.image_url.length == 0 && (
|
className="btn btn-sm btn-secondary pointer"
|
||||||
<span className="btn btn-sm btn-secondary">
|
htmlFor={`file-uploader-${index}`}
|
||||||
Upload
|
data-tippy-content={I18NextService.i18n.t(
|
||||||
</span>
|
"upload_image"
|
||||||
)}
|
)}
|
||||||
</label>
|
>
|
||||||
<input
|
{capitalizeFirstLetter(
|
||||||
name={index.toString()}
|
I18NextService.i18n.t("upload")
|
||||||
id={index.toString()}
|
)}
|
||||||
type="file"
|
<input
|
||||||
accept="image/*"
|
name={`file-uploader-${index}`}
|
||||||
className="d-none"
|
id={`file-uploader-${index}`}
|
||||||
onChange={linkEvent(
|
type="file"
|
||||||
{ form: this, index: index },
|
accept="image/*"
|
||||||
this.handleImageUpload
|
className="d-none"
|
||||||
)}
|
onChange={linkEvent(
|
||||||
/>
|
{ form: this, index: index },
|
||||||
|
this.handleImageUpload
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</form>
|
||||||
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td className="text-right">
|
<td className="text-right">
|
||||||
<input
|
<input
|
||||||
|
@ -213,8 +221,9 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
<span title={this.getEditTooltip(cv)}>
|
<span title={this.getEditTooltip(cv)}>
|
||||||
<button
|
<button
|
||||||
className={
|
className={
|
||||||
(cv.changed ? "text-success " : "text-muted ") +
|
(this.canEdit(cv)
|
||||||
"btn btn-link btn-animate"
|
? "text-success "
|
||||||
|
: "text-muted ") + "btn btn-link btn-animate"
|
||||||
}
|
}
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
{ i: this, cv: cv },
|
{ i: this, cv: cv },
|
||||||
|
@ -222,17 +231,15 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
)}
|
)}
|
||||||
data-tippy-content={I18NextService.i18n.t("save")}
|
data-tippy-content={I18NextService.i18n.t("save")}
|
||||||
aria-label={I18NextService.i18n.t("save")}
|
aria-label={I18NextService.i18n.t("save")}
|
||||||
disabled={
|
disabled={!this.canEdit(cv)}
|
||||||
this.props.loading ||
|
|
||||||
!this.canEdit(cv) ||
|
|
||||||
!cv.changed
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{/* <Icon
|
{cv.loading ? (
|
||||||
icon="edit"
|
<Spinner />
|
||||||
classes={`icon-inline`}
|
) : (
|
||||||
/> */}
|
capitalizeFirstLetter(
|
||||||
Save
|
I18NextService.i18n.t("save")
|
||||||
|
)
|
||||||
|
)}
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
|
@ -243,7 +250,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
)}
|
)}
|
||||||
data-tippy-content={I18NextService.i18n.t("delete")}
|
data-tippy-content={I18NextService.i18n.t("delete")}
|
||||||
aria-label={I18NextService.i18n.t("delete")}
|
aria-label={I18NextService.i18n.t("delete")}
|
||||||
disabled={this.props.loading}
|
disabled={cv.loading}
|
||||||
title={I18NextService.i18n.t("delete")}
|
title={I18NextService.i18n.t("delete")}
|
||||||
>
|
>
|
||||||
<Icon
|
<Icon
|
||||||
|
@ -281,7 +288,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
this.state.customEmojis.filter(
|
this.state.customEmojis.filter(
|
||||||
x => x.shortcode == cv.shortcode && x.id != cv.id
|
x => x.shortcode == cv.shortcode && x.id != cv.id
|
||||||
).length == 0;
|
).length == 0;
|
||||||
return noEmptyFields && noDuplicateShortCodes;
|
return noEmptyFields && noDuplicateShortCodes && !cv.loading && cv.changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
getEditTooltip(cv: CustomEmojiViewForm) {
|
getEditTooltip(cv: CustomEmojiViewForm) {
|
||||||
|
@ -339,19 +346,36 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEmojiImageUrlChange(
|
handleEmojiImageUrlChange(
|
||||||
props: { form: EmojiForm; index: number; overrideValue: string | null },
|
{
|
||||||
|
form,
|
||||||
|
index,
|
||||||
|
overrideValue,
|
||||||
|
}: { form: EmojiForm; index: number; overrideValue: string | null },
|
||||||
event: any
|
event: any
|
||||||
) {
|
) {
|
||||||
const custom_emojis = [...props.form.state.customEmojis];
|
form.setState(prevState => {
|
||||||
const pagedIndex =
|
const custom_emojis = [...form.state.customEmojis];
|
||||||
(props.form.state.page - 1) * props.form.itemsPerPage + props.index;
|
const pagedIndex = (form.state.page - 1) * form.itemsPerPage + index;
|
||||||
const item = {
|
const item = {
|
||||||
...props.form.state.customEmojis[pagedIndex],
|
...form.state.customEmojis[pagedIndex],
|
||||||
image_url: props.overrideValue ?? event.target.value,
|
image_url: overrideValue ?? event.target.value,
|
||||||
changed: true,
|
changed: true,
|
||||||
};
|
};
|
||||||
custom_emojis[Number(pagedIndex)] = item;
|
custom_emojis[Number(pagedIndex)] = item;
|
||||||
props.form.setState({ customEmojis: custom_emojis });
|
return {
|
||||||
|
...prevState,
|
||||||
|
customEmojis: prevState.customEmojis.map((ce, i) =>
|
||||||
|
i === pagedIndex
|
||||||
|
? {
|
||||||
|
...ce,
|
||||||
|
image_url: overrideValue ?? event.target.value,
|
||||||
|
changed: true,
|
||||||
|
loading: false,
|
||||||
|
}
|
||||||
|
: ce
|
||||||
|
),
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEmojiAltTextChange(
|
handleEmojiAltTextChange(
|
||||||
|
@ -409,7 +433,7 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
.split(" ")
|
.split(" ")
|
||||||
.filter(x => x.length > 0) as string[];
|
.filter(x => x.length > 0) as string[];
|
||||||
const uniqueKeywords = Array.from(new Set(keywords));
|
const uniqueKeywords = Array.from(new Set(keywords));
|
||||||
if (d.cv.id != 0) {
|
if (d.cv.id !== 0) {
|
||||||
d.i.props.onEdit({
|
d.i.props.onEdit({
|
||||||
id: d.cv.id,
|
id: d.cv.id,
|
||||||
category: d.cv.category,
|
category: d.cv.category,
|
||||||
|
@ -432,24 +456,33 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
|
|
||||||
handleAddEmojiClick(form: EmojiForm, event: any) {
|
handleAddEmojiClick(form: EmojiForm, event: any) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const custom_emojis = [...form.state.customEmojis];
|
form.setState(prevState => {
|
||||||
const page =
|
const page =
|
||||||
1 + Math.floor(form.state.customEmojis.length / form.itemsPerPage);
|
1 + Math.floor(prevState.customEmojis.length / form.itemsPerPage);
|
||||||
const item: CustomEmojiViewForm = {
|
const item: CustomEmojiViewForm = {
|
||||||
id: 0,
|
id: 0,
|
||||||
shortcode: "",
|
shortcode: "",
|
||||||
alt_text: "",
|
alt_text: "",
|
||||||
category: "",
|
category: "",
|
||||||
image_url: "",
|
image_url: "",
|
||||||
keywords: "",
|
keywords: "",
|
||||||
changed: true,
|
changed: false,
|
||||||
page: page,
|
page: page,
|
||||||
};
|
loading: false,
|
||||||
custom_emojis.push(item);
|
};
|
||||||
form.setState({ customEmojis: custom_emojis, page: page });
|
|
||||||
|
return {
|
||||||
|
...prevState,
|
||||||
|
customEmojis: [...prevState.customEmojis, item],
|
||||||
|
page,
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleImageUpload(props: { form: EmojiForm; index: number }, event: any) {
|
handleImageUpload(
|
||||||
|
{ form, index }: { form: EmojiForm; index: number },
|
||||||
|
event: any
|
||||||
|
) {
|
||||||
let file: any;
|
let file: any;
|
||||||
if (event.target) {
|
if (event.target) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -458,20 +491,25 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
|
||||||
file = event;
|
file = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form.setState(prevState => ({
|
||||||
|
...prevState,
|
||||||
|
customEmojis: prevState.customEmojis.map((cv, i) =>
|
||||||
|
i === index ? { ...cv, loading: true } : cv
|
||||||
|
),
|
||||||
|
}));
|
||||||
|
|
||||||
HttpService.client.uploadImage({ image: file }).then(res => {
|
HttpService.client.uploadImage({ image: file }).then(res => {
|
||||||
console.log("pictrs upload:");
|
console.log("pictrs upload:");
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (res.state === "success") {
|
if (res.state === "success") {
|
||||||
if (res.data.msg === "ok") {
|
if (res.data.msg === "ok") {
|
||||||
pictrsDeleteToast(file.name, res.data.delete_url as string);
|
pictrsDeleteToast(file.name, res.data.delete_url as string);
|
||||||
} else {
|
form.handleEmojiImageUrlChange(
|
||||||
toast(JSON.stringify(res), "danger");
|
{ form: form, index: index, overrideValue: res.data.url as string },
|
||||||
const hash = res.data.files?.at(0)?.file;
|
|
||||||
const url = `${res.data.url}/${hash}`;
|
|
||||||
props.form.handleEmojiImageUrlChange(
|
|
||||||
{ form: props.form, index: props.index, overrideValue: url },
|
|
||||||
event
|
event
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
toast(JSON.stringify(res), "danger");
|
||||||
}
|
}
|
||||||
} else if (res.state === "failed") {
|
} else if (res.state === "failed") {
|
||||||
console.error(res.msg);
|
console.error(res.msg);
|
||||||
|
|
|
@ -108,7 +108,7 @@ export class Login extends Component<any, State> {
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={linkEvent(this, this.handlePasswordReset)}
|
onClick={linkEvent(this, this.handlePasswordReset)}
|
||||||
className="btn p-0 btn-link d-inline-block float-right text-muted small font-weight-bold pointer-events not-allowed"
|
className="btn p-0 btn-link d-inline-block float-right text-muted small fw-bold pointer-events not-allowed"
|
||||||
disabled={
|
disabled={
|
||||||
!!this.state.form.username_or_email &&
|
!!this.state.form.username_or_email &&
|
||||||
!validEmail(this.state.form.username_or_email)
|
!validEmail(this.state.form.username_or_email)
|
||||||
|
|
|
@ -43,7 +43,7 @@ export class MetadataCard extends Component<
|
||||||
</h5>
|
</h5>
|
||||||
<span className="d-inline-block ms-2 mb-2 small text-muted">
|
<span className="d-inline-block ms-2 mb-2 small text-muted">
|
||||||
<a
|
<a
|
||||||
className="text-muted font-italic"
|
className="text-muted fst-italic"
|
||||||
href={post.url}
|
href={post.url}
|
||||||
rel={relTags}
|
rel={relTags}
|
||||||
>
|
>
|
||||||
|
|
|
@ -358,7 +358,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
htmlFor="file-upload"
|
htmlFor="file-upload"
|
||||||
className={`${
|
className={`${
|
||||||
UserService.Instance.myUserInfo && "pointer"
|
UserService.Instance.myUserInfo && "pointer"
|
||||||
} d-inline-block float-right text-muted font-weight-bold`}
|
} d-inline-block float-right text-muted fw-bold`}
|
||||||
data-tippy-content={I18NextService.i18n.t("upload_image")}
|
data-tippy-content={I18NextService.i18n.t("upload_image")}
|
||||||
>
|
>
|
||||||
<Icon icon="image" classes="icon-inline" />
|
<Icon icon="image" classes="icon-inline" />
|
||||||
|
@ -377,7 +377,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
<div>
|
<div>
|
||||||
<a
|
<a
|
||||||
href={`${webArchiveUrl}/save/${encodeURIComponent(url)}`}
|
href={`${webArchiveUrl}/save/${encodeURIComponent(url)}`}
|
||||||
className="me-2 d-inline-block float-right text-muted small font-weight-bold"
|
className="me-2 d-inline-block float-right text-muted small fw-bold"
|
||||||
rel={relTags}
|
rel={relTags}
|
||||||
>
|
>
|
||||||
archive.org {I18NextService.i18n.t("archive_link")}
|
archive.org {I18NextService.i18n.t("archive_link")}
|
||||||
|
@ -386,7 +386,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
href={`${ghostArchiveUrl}/search?term=${encodeURIComponent(
|
href={`${ghostArchiveUrl}/search?term=${encodeURIComponent(
|
||||||
url
|
url
|
||||||
)}`}
|
)}`}
|
||||||
className="me-2 d-inline-block float-right text-muted small font-weight-bold"
|
className="me-2 d-inline-block float-right text-muted small fw-bold"
|
||||||
rel={relTags}
|
rel={relTags}
|
||||||
>
|
>
|
||||||
ghostarchive.org {I18NextService.i18n.t("archive_link")}
|
ghostarchive.org {I18NextService.i18n.t("archive_link")}
|
||||||
|
@ -395,7 +395,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
href={`${archiveTodayUrl}/?run=1&url=${encodeURIComponent(
|
href={`${archiveTodayUrl}/?run=1&url=${encodeURIComponent(
|
||||||
url
|
url
|
||||||
)}`}
|
)}`}
|
||||||
className="me-2 d-inline-block float-right text-muted small font-weight-bold"
|
className="me-2 d-inline-block float-right text-muted small fw-bold"
|
||||||
rel={relTags}
|
rel={relTags}
|
||||||
>
|
>
|
||||||
archive.today {I18NextService.i18n.t("archive_link")}
|
archive.today {I18NextService.i18n.t("archive_link")}
|
||||||
|
@ -419,7 +419,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
)}
|
)}
|
||||||
{this.props.crossPosts && this.props.crossPosts.length > 0 && (
|
{this.props.crossPosts && this.props.crossPosts.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<div className="my-1 text-muted small font-weight-bold">
|
<div className="my-1 text-muted small fw-bold">
|
||||||
{I18NextService.i18n.t("cross_posts")}
|
{I18NextService.i18n.t("cross_posts")}
|
||||||
</div>
|
</div>
|
||||||
<PostListings
|
<PostListings
|
||||||
|
@ -586,7 +586,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
return (
|
return (
|
||||||
suggestedTitle && (
|
suggestedTitle && (
|
||||||
<div
|
<div
|
||||||
className="mt-1 text-muted small font-weight-bold pointer"
|
className="mt-1 text-muted small fw-bold pointer"
|
||||||
role="button"
|
role="button"
|
||||||
onClick={linkEvent(
|
onClick={linkEvent(
|
||||||
{ i: this, suggestedTitle },
|
{ i: this, suggestedTitle },
|
||||||
|
@ -613,7 +613,7 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
|
||||||
suggestedPosts &&
|
suggestedPosts &&
|
||||||
suggestedPosts.length > 0 && (
|
suggestedPosts.length > 0 && (
|
||||||
<>
|
<>
|
||||||
<div className="my-1 text-muted small font-weight-bold">
|
<div className="my-1 text-muted small fw-bold">
|
||||||
{I18NextService.i18n.t("related_posts")}
|
{I18NextService.i18n.t("related_posts")}
|
||||||
</div>
|
</div>
|
||||||
<PostListings
|
<PostListings
|
||||||
|
|
|
@ -547,7 +547,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
)}
|
)}
|
||||||
{post.deleted && (
|
{post.deleted && (
|
||||||
<small
|
<small
|
||||||
className="unselectable pointer ms-2 text-muted font-italic"
|
className="unselectable pointer ms-2 text-muted fst-italic"
|
||||||
data-tippy-content={I18NextService.i18n.t("deleted")}
|
data-tippy-content={I18NextService.i18n.t("deleted")}
|
||||||
>
|
>
|
||||||
<Icon icon="trash" classes="icon-inline text-danger" />
|
<Icon icon="trash" classes="icon-inline text-danger" />
|
||||||
|
@ -555,7 +555,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
)}
|
)}
|
||||||
{post.locked && (
|
{post.locked && (
|
||||||
<small
|
<small
|
||||||
className="unselectable pointer ms-2 text-muted font-italic"
|
className="unselectable pointer ms-2 text-muted fst-italic"
|
||||||
data-tippy-content={I18NextService.i18n.t("locked")}
|
data-tippy-content={I18NextService.i18n.t("locked")}
|
||||||
>
|
>
|
||||||
<Icon icon="lock" classes="icon-inline text-danger" />
|
<Icon icon="lock" classes="icon-inline text-danger" />
|
||||||
|
@ -563,7 +563,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
)}
|
)}
|
||||||
{post.featured_community && (
|
{post.featured_community && (
|
||||||
<small
|
<small
|
||||||
className="unselectable pointer ms-2 text-muted font-italic"
|
className="unselectable pointer ms-2 text-muted fst-italic"
|
||||||
data-tippy-content={I18NextService.i18n.t(
|
data-tippy-content={I18NextService.i18n.t(
|
||||||
"featured_in_community"
|
"featured_in_community"
|
||||||
)}
|
)}
|
||||||
|
@ -574,7 +574,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
)}
|
)}
|
||||||
{post.featured_local && (
|
{post.featured_local && (
|
||||||
<small
|
<small
|
||||||
className="unselectable pointer ms-2 text-muted font-italic"
|
className="unselectable pointer ms-2 text-muted fst-italic"
|
||||||
data-tippy-content={I18NextService.i18n.t("featured_in_local")}
|
data-tippy-content={I18NextService.i18n.t("featured_in_local")}
|
||||||
aria-label={I18NextService.i18n.t("featured_in_local")}
|
aria-label={I18NextService.i18n.t("featured_in_local")}
|
||||||
>
|
>
|
||||||
|
@ -600,7 +600,7 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
<p className="d-flex text-muted align-items-center gap-1 small m-0">
|
<p className="d-flex text-muted align-items-center gap-1 small m-0">
|
||||||
{url && !(hostname(url) === getExternalHost()) && (
|
{url && !(hostname(url) === getExternalHost()) && (
|
||||||
<a
|
<a
|
||||||
className="text-muted font-italic"
|
className="text-muted fst-italic"
|
||||||
href={url}
|
href={url}
|
||||||
title={url}
|
title={url}
|
||||||
rel={relTags}
|
rel={relTags}
|
||||||
|
|
|
@ -140,7 +140,7 @@ export class PrivateMessage extends Component<
|
||||||
dangerouslySetInnerHTML={mdToHtml(this.messageUnlessRemoved)}
|
dangerouslySetInnerHTML={mdToHtml(this.messageUnlessRemoved)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<ul className="list-inline mb-0 text-muted font-weight-bold">
|
<ul className="list-inline mb-0 text-muted fw-bold">
|
||||||
{!this.mine && (
|
{!this.mine && (
|
||||||
<>
|
<>
|
||||||
<li className="list-inline-item">
|
<li className="list-inline-item">
|
||||||
|
|
Loading…
Reference in a new issue