From: Dessalines Date: Mon, 14 Feb 2022 17:27:43 +0000 (-0500) Subject: Don't allow transfer site. (#551) X-Git-Url: http://these/git/readmes/%24%7B%60data:application/README.md?a=commitdiff_plain;h=399149b2784d6d281fd8017b2b09bcb57a77d924;p=lemmy-ui.git Don't allow transfer site. (#551) * Don't allow transfer site. * Updating translations. * Adding leave admin team. --- diff --git a/lemmy-translations b/lemmy-translations index b18bfc1..0d63b5a 160000 --- a/lemmy-translations +++ b/lemmy-translations @@ -1 +1 @@ -Subproject commit b18bfc1a8d512d081056cf5aa1f422e4710ef683 +Subproject commit 0d63b5affe2273bb88b3593cdc13e4bb0f4d2d5d diff --git a/package.json b/package.json index 4a20581..63ddad7 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "husky": "^7.0.4", "import-sort-style-module": "^6.0.0", "iso-639-1": "^2.1.10", - "lemmy-js-client": "0.15.0", + "lemmy-js-client": "0.15.1-rc.1", "lint-staged": "^12.1.2", "mini-css-extract-plugin": "^2.4.5", "node-fetch": "^2.6.1", diff --git a/src/shared/components/comment/comment-node.tsx b/src/shared/components/comment/comment-node.tsx index f40aa0a..1af8e11 100644 --- a/src/shared/components/comment/comment-node.tsx +++ b/src/shared/components/comment/comment-node.tsx @@ -18,7 +18,6 @@ import { RemoveComment, SaveComment, TransferCommunity, - TransferSite, } from "lemmy-js-client"; import moment from "moment"; import { i18n } from "../../i18next"; @@ -686,51 +685,6 @@ export class CommentNode extends Component { ))} )} - {/* Site Creator can transfer to another admin */} - {this.amSiteCreator && - this.isAdmin && - cv.creator.local && - (!this.state.showConfirmTransferSite ? ( - - ) : ( - <> - - - - - ))} )} @@ -1339,16 +1293,6 @@ export class CommentNode extends Component { i.setState(i.state); } - handleTransferSite(i: CommentNode) { - let form: TransferSite = { - person_id: i.props.node.comment_view.creator.id, - auth: authField(), - }; - WebSocketService.Instance.send(wsClient.transferSite(form)); - i.state.showConfirmTransferSite = false; - i.setState(i.state); - } - get isCommentNew(): boolean { let now = moment.utc().subtract(10, "minutes"); let then = moment.utc(this.props.node.comment_view.comment.published); diff --git a/src/shared/components/home/admin-settings.tsx b/src/shared/components/home/admin-settings.tsx index ed56e15..284805b 100644 --- a/src/shared/components/home/admin-settings.tsx +++ b/src/shared/components/home/admin-settings.tsx @@ -39,6 +39,7 @@ interface AdminSettingsState { loading: boolean; banned: PersonViewSafe[]; siteConfigLoading: boolean; + leaveAdminTeamLoading: boolean; } export class AdminSettings extends Component { @@ -57,6 +58,7 @@ export class AdminSettings extends Component { banned: [], loading: true, siteConfigLoading: null, + leaveAdminTeamLoading: null, }; constructor(props: any, context: any) { @@ -159,10 +161,26 @@ export class AdminSettings extends Component { ))} + {this.leaveAdmin()} ); } + leaveAdmin() { + return ( + + ); + } + bannedUsers() { return ( <> @@ -230,6 +248,12 @@ export class AdminSettings extends Component { i.setState(i.state); } + handleLeaveAdminTeam(i: AdminSettings) { + i.state.leaveAdminTeamLoading = true; + WebSocketService.Instance.send(wsClient.leaveAdmin({ auth: authField() })); + i.setState(i.state); + } + parseMessage(msg: any) { let op = wsUserOp(msg); console.log(msg); @@ -257,6 +281,14 @@ export class AdminSettings extends Component { this.setState(this.state); var textarea: any = document.getElementById(this.siteConfigTextAreaId); autosize(textarea); + } else if (op == UserOperation.LeaveAdmin) { + let data = wsJsonToRes(msg).data; + this.state.siteRes.site_view = data.site_view; + this.setState(this.state); + this.state.leaveAdminTeamLoading = false; + toast(i18n.t("left_admin_team")); + this.setState(this.state); + this.context.router.history.push("/"); } else if (op == UserOperation.SaveSiteConfig) { let data = wsJsonToRes(msg).data; this.state.siteConfigRes = data; diff --git a/src/shared/components/post/post-listing.tsx b/src/shared/components/post/post-listing.tsx index 61a0930..1608d41 100644 --- a/src/shared/components/post/post-listing.tsx +++ b/src/shared/components/post/post-listing.tsx @@ -18,7 +18,6 @@ import { SavePost, StickyPost, TransferCommunity, - TransferSite, } from "lemmy-js-client"; import { externalHost } from "../../env"; import { i18n } from "../../i18next"; @@ -937,44 +936,6 @@ export class PostListing extends Component { )} )} - {/* Site Creator can transfer to another admin */} - {this.amSiteCreator && - this.creatorIsAdmin && - (!this.state.showConfirmTransferSite ? ( - - ) : ( - <> - - - - - ))} ) ); @@ -1617,16 +1578,6 @@ export class PostListing extends Component { i.setState(i.state); } - handleTransferSite(i: PostListing) { - let form: TransferSite = { - person_id: i.props.post_view.creator.id, - auth: authField(), - }; - WebSocketService.Instance.send(wsClient.transferSite(form)); - i.state.showConfirmTransferSite = false; - i.setState(i.state); - } - handleImageExpandClick(i: PostListing, event: any) { event.preventDefault(); i.state.imageExpanded = !i.state.imageExpanded; diff --git a/src/shared/components/post/post.tsx b/src/shared/components/post/post.tsx index dcc9871..4ae1cc5 100644 --- a/src/shared/components/post/post.tsx +++ b/src/shared/components/post/post.tsx @@ -645,7 +645,7 @@ export class Post extends Component { p => p.post.id != Number(this.props.match.params.id) ); this.setState(this.state); - } else if (op == UserOperation.TransferSite) { + } else if (op == UserOperation.LeaveAdmin) { let data = wsJsonToRes(msg).data; this.state.siteRes = data; this.setState(this.state); diff --git a/yarn.lock b/yarn.lock index 1e7fd8d..824c1a8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4629,10 +4629,10 @@ lcid@^1.0.0: dependencies: invert-kv "^1.0.0" -lemmy-js-client@0.15.0: - version "0.15.0" - resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.15.0.tgz#984aadbfb2c8e7cebb61d429f0cf576245876a0b" - integrity sha512-BWeI0cQOdjxDLHShyNGjYCMxdZf08sJnKKg2DNe9Js/sgMpv9OY9ZDiDOvV8R1QatqdAbwPv8HOgVQRAV6SYDQ== +lemmy-js-client@0.15.1-rc.1: + version "0.15.1-rc.1" + resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.15.1-rc.1.tgz#9d914098eefc25834f077c4690d4e3e2ab4f2c57" + integrity sha512-rs80HTzwayt2EpjQ+ruQM82bZydjk9kZUUjZidYzwmy1FBkWpG5+OBnW3X6YQ5ebswiobL8HraNfnWMm0zqvjQ== levn@^0.4.1: version "0.4.1"