UX: puts back share-panel as floating pane on post actions (#7066)
This commit is contained in:
@@ -2,7 +2,6 @@ import PostCooked from "discourse/widgets/post-cooked";
|
||||
import DecoratorHelper from "discourse/widgets/decorator-helper";
|
||||
import { createWidget, applyDecorators } from "discourse/widgets/widget";
|
||||
import { iconNode } from "discourse-common/lib/icon-library";
|
||||
import { nativeShare } from "discourse/lib/pwa-utils";
|
||||
import { transformBasicPost } from "discourse/lib/transform-post";
|
||||
import { postTransformCallbacks } from "discourse/widgets/post-stream";
|
||||
import { h } from "virtual-dom";
|
||||
@@ -14,7 +13,6 @@ import {
|
||||
formatUsername
|
||||
} from "discourse/lib/utilities";
|
||||
import hbs from "discourse/widgets/hbs-compiler";
|
||||
import showModal from "discourse/lib/show-modal";
|
||||
|
||||
function transformWithCallbacks(post) {
|
||||
let transformed = transformBasicPost(post);
|
||||
@@ -221,72 +219,6 @@ function showReplyTab(attrs, siteSettings) {
|
||||
);
|
||||
}
|
||||
|
||||
createWidget("post-date", {
|
||||
tagName: "div.post-info.post-date",
|
||||
|
||||
buildClasses(attrs) {
|
||||
let classes = "post-date";
|
||||
|
||||
const lastWikiEdit =
|
||||
attrs.wiki && attrs.lastWikiEdit && new Date(attrs.lastWikiEdit);
|
||||
|
||||
if (lastWikiEdit) {
|
||||
classes = `${classes} last-wiki-edit`;
|
||||
}
|
||||
|
||||
return classes;
|
||||
},
|
||||
|
||||
html(attrs) {
|
||||
return h(
|
||||
"a",
|
||||
{
|
||||
attributes: {
|
||||
class: "post-date",
|
||||
href: attrs.shareUrl,
|
||||
"data-share-url": attrs.shareUrl,
|
||||
"data-post-number": attrs.post_number
|
||||
}
|
||||
},
|
||||
dateNode(this._date(attrs))
|
||||
);
|
||||
},
|
||||
|
||||
_date(attrs) {
|
||||
const lastWikiEdit =
|
||||
attrs.wiki && attrs.lastWikiEdit && new Date(attrs.lastWikiEdit);
|
||||
const createdAt = new Date(attrs.created_at);
|
||||
return lastWikiEdit ? lastWikiEdit : createdAt;
|
||||
},
|
||||
|
||||
click(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const post = this.findAncestorModel();
|
||||
|
||||
const modalFallback = () => {
|
||||
showModal("share-and-invite", {
|
||||
modalClass: "share-and-invite",
|
||||
panels: [
|
||||
{
|
||||
id: "share",
|
||||
title: "topic.share.extended_title",
|
||||
model: {
|
||||
postNumber: this.attrs.post_number,
|
||||
shareUrl: this.attrs.shareUrl,
|
||||
date: this._date(this.attrs),
|
||||
postId: post.get("id"),
|
||||
topic: post.get("topic")
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
nativeShare({ url: this.attrs.shareUrl }).then(null, modalFallback);
|
||||
}
|
||||
});
|
||||
|
||||
createWidget("post-meta-data", {
|
||||
tagName: "div.topic-meta-data",
|
||||
|
||||
@@ -309,6 +241,21 @@ createWidget("post-meta-data", {
|
||||
);
|
||||
}
|
||||
|
||||
const lastWikiEdit =
|
||||
attrs.wiki && attrs.lastWikiEdit && new Date(attrs.lastWikiEdit);
|
||||
const createdAt = new Date(attrs.created_at);
|
||||
const date = lastWikiEdit ? dateNode(lastWikiEdit) : dateNode(createdAt);
|
||||
const attributes = {
|
||||
class: "post-date",
|
||||
href: attrs.shareUrl,
|
||||
"data-share-url": attrs.shareUrl,
|
||||
"data-post-number": attrs.post_number
|
||||
};
|
||||
|
||||
if (lastWikiEdit) {
|
||||
attributes["class"] += " last-wiki-edit";
|
||||
}
|
||||
|
||||
if (attrs.via_email) {
|
||||
postInfo.push(this.attach("post-email-indicator", attrs));
|
||||
}
|
||||
@@ -329,7 +276,7 @@ createWidget("post-meta-data", {
|
||||
postInfo.push(this.attach("reply-to-tab", attrs));
|
||||
}
|
||||
|
||||
postInfo.push(this.attach("post-date", attrs));
|
||||
postInfo.push(h("div.post-info.post-date", h("a", { attributes }, date)));
|
||||
|
||||
postInfo.push(
|
||||
h(
|
||||
@@ -451,31 +398,6 @@ createWidget("post-contents", {
|
||||
return lastWikiEdit ? lastWikiEdit : createdAt;
|
||||
},
|
||||
|
||||
share() {
|
||||
const post = this.findAncestorModel();
|
||||
|
||||
const modalFallback = () => {
|
||||
showModal("share-and-invite", {
|
||||
modalClass: "share-and-invite",
|
||||
panels: [
|
||||
{
|
||||
id: "share",
|
||||
title: "topic.share.extended_title",
|
||||
model: {
|
||||
postNumber: this.attrs.post_number,
|
||||
shareUrl: this.attrs.shareUrl,
|
||||
date: this._date(this.attrs),
|
||||
postId: post.get("id"),
|
||||
topic: post.get("topic")
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
};
|
||||
|
||||
nativeShare({ url: this.attrs.shareUrl }).then(null, modalFallback);
|
||||
},
|
||||
|
||||
toggleRepliesBelow(goToPost = "false") {
|
||||
if (this.state.repliesBelow.length) {
|
||||
this.state.repliesBelow = [];
|
||||
|
||||
Reference in New Issue
Block a user