From 77b2346a03e5ff295238d75abe268d3cdcbbb37b Mon Sep 17 00:00:00 2001 From: tarafanlin <35607644+tarafanlin@users.noreply.github.com> Date: Fri, 15 Jan 2021 11:00:33 -0800 Subject: [PATCH] peer & file context menu --- components/core/DataView.js | 70 +++++++++++------ components/core/Profile.js | 147 ++++++++++++++++++++++++------------ 2 files changed, 145 insertions(+), 72 deletions(-) diff --git a/components/core/DataView.js b/components/core/DataView.js index d9d19549..f5cc495f 100644 --- a/components/core/DataView.js +++ b/components/core/DataView.js @@ -539,32 +539,52 @@ export default class DataView extends React.Component { enabled onOutsideRectEvent={this._handleHide} > - this._handleCopy(e, cid), - }, - { - text: "Copy link", - onClick: (e) => - this._handleCopy(e, Strings.getCIDGatewayURL(cid)), - }, - { - text: "Delete", - onClick: (e) => { - e.stopPropagation(); - this.setState({ menu: null }, () => - this._handleDelete(cid, each.id) - ); + {this.props.isOwner ? ( + this._handleCopy(e, cid), }, - }, - ]} - /> + { + text: "Copy link", + onClick: (e) => + this._handleCopy(e, Strings.getCIDGatewayURL(cid)), + }, + { + text: "Delete", + onClick: (e) => { + e.stopPropagation(); + this.setState({ menu: null }, () => + this._handleDelete(cid, each.id) + ); + }, + }, + ]} + /> + ) : ( + this._handleCopy(e, cid), + }, + { + text: "Copy link", + onClick: (e) => + this._handleCopy(e, Strings.getCIDGatewayURL(cid)), + }, + ]} + /> + )} ) : null} diff --git a/components/core/Profile.js b/components/core/Profile.js index c271ac28..5d2730d8 100644 --- a/components/core/Profile.js +++ b/components/core/Profile.js @@ -195,6 +195,12 @@ const STYLES_DIRECTORY_NAME = css` text-overflow: ellipsis; `; +const STYLES_COPY_INPUT = css` + pointer-events: none; + position: absolute; + opacity: 0; +`; + function UserEntry({ user, button, onClick, message }) { return (
@@ -214,7 +220,7 @@ function UserEntry({ user, button, onClick, message }) { } export default class Profile extends React.Component { - _ref; + _ref = null; state = { exploreSlates: [], @@ -330,7 +336,6 @@ export default class Profile extends React.Component { let isOwner = this.props.creator.username === this.props.viewer?.username; console.log(this.props); - console.log(this.state.publicSlates); let following = subscriptions .filter((relation) => { return !!relation.target_user_id; @@ -346,27 +351,45 @@ export default class Profile extends React.Component { enabled onOutsideRectEvent={(e) => this._handleClick(e, relation.id)} > - - this._handleCopy(e, `https://slate.host/${relation.user.username}`), - }, - { - text: this.props.viewer?.subscriptions.filter((subscription) => { - return subscription.target_user_id === relation.target_user_id; - }).length - ? "Unfollow" - : "Follow", - onClick: (e) => this._handleFollow(e, relation.owner.id), - }, - ]} - /> + {relation.target_user_id === this.props.viewer?.id ? ( + + this._handleCopy(e, `https://slate.host/${relation.user.username}`), + }, + ]} + /> + ) : ( + + this._handleCopy(e, `https://slate.host/${relation.user.username}`), + }, + { + text: this.props.viewer?.subscriptions.filter((subscription) => { + return subscription.target_user_id === relation.target_user_id; + }).length + ? "Unfollow" + : "Follow", + onClick: this.props.viewer + ? (e) => this._handleFollow(e, relation.target_user_id) + : () => this.setState({ visible: true }), + }, + ]} + /> + )} ) : null}
@@ -399,27 +422,45 @@ export default class Profile extends React.Component { enabled onOutsideRectEvent={(e) => this._handleClick(e, relation.id)} > - - this._handleCopy(e, `https://slate.host/${relation.owner.username}`), - }, - { - text: this.props.viewer?.subscriptions.filter((subscription) => { - return subscription.target_user_id === relation.owner_user_id; - }).length - ? "Unfollow" - : "Follow", - onClick: (e) => this._handleFollow(e, relation.owner.id), - }, - ]} - /> + {relation.owner_user_id === this.props.viewer?.id ? ( + + this._handleCopy(e, `https://slate.host/${relation.owner.username}`), + }, + ]} + /> + ) : ( + + this._handleCopy(e, `https://slate.host/${relation.owner.username}`), + }, + { + text: subscriptions.filter((subscription) => { + return subscription.target_user_id === relation.owner_user_id; + }).length + ? "Unfollow" + : "Follow", + onClick: this.props.viewer + ? (e) => this._handleFollow(e, relation.owner_user_id) + : () => this.setState({ visible: true }), + }, + ]} + /> + )} ) : null} @@ -525,6 +566,7 @@ export default class Profile extends React.Component { - You can follow any user on the network to be updated on their new uploads and - slates. + Follow any user on the network to be updated on their new uploads and slates. )} @@ -659,11 +703,20 @@ export default class Profile extends React.Component { ) : ( - You don't have any followers yet. + There aren't any followers yet. )} ) : null} + { + this._ref = c; + }} + value={this.state.copyValue} + tabIndex="-1" + css={STYLES_COPY_INPUT} + /> ) : null}