]> Untitled Git - lemmy-ui.git/commitdiff
Don't allow transfer site. (#551)
authorDessalines <dessalines@users.noreply.github.com>
Mon, 14 Feb 2022 17:27:43 +0000 (12:27 -0500)
committerGitHub <noreply@github.com>
Mon, 14 Feb 2022 17:27:43 +0000 (12:27 -0500)
* Don't allow transfer site.

* Updating translations.

* Adding leave admin team.

lemmy-translations
package.json
src/shared/components/comment/comment-node.tsx
src/shared/components/home/admin-settings.tsx
src/shared/components/post/post-listing.tsx
src/shared/components/post/post.tsx
yarn.lock

index b18bfc1a8d512d081056cf5aa1f422e4710ef683..0d63b5affe2273bb88b3593cdc13e4bb0f4d2d5d 160000 (submodule)
@@ -1 +1 @@
-Subproject commit b18bfc1a8d512d081056cf5aa1f422e4710ef683
+Subproject commit 0d63b5affe2273bb88b3593cdc13e4bb0f4d2d5d
index 4a20581370e4ca731ccd566c4367abc8a8115506..63ddad7e424a96966588520940d8e8730b14e464 100644 (file)
@@ -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",
index f40aa0ac4b91dd2ec37396a1f411a09039edceed..1af8e11716b5b1767caa5a811e3e62efaf43626b 100644 (file)
@@ -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<CommentNodeProps, CommentNodeState> {
                                 ))}
                             </>
                           )}
-                          {/* Site Creator can transfer to another admin */}
-                          {this.amSiteCreator &&
-                            this.isAdmin &&
-                            cv.creator.local &&
-                            (!this.state.showConfirmTransferSite ? (
-                              <button
-                                class="btn btn-link btn-animate text-muted"
-                                onClick={linkEvent(
-                                  this,
-                                  this.handleShowConfirmTransferSite
-                                )}
-                                aria-label={i18n.t("transfer_site")}
-                              >
-                                {i18n.t("transfer_site")}
-                              </button>
-                            ) : (
-                              <>
-                                <button
-                                  class="btn btn-link btn-animate text-muted"
-                                  aria-label={i18n.t("are_you_sure")}
-                                >
-                                  {i18n.t("are_you_sure")}
-                                </button>
-                                <button
-                                  class="btn btn-link btn-animate text-muted"
-                                  onClick={linkEvent(
-                                    this,
-                                    this.handleTransferSite
-                                  )}
-                                  aria-label={i18n.t("yes")}
-                                >
-                                  {i18n.t("yes")}
-                                </button>
-                                <button
-                                  class="btn btn-link btn-animate text-muted"
-                                  onClick={linkEvent(
-                                    this,
-                                    this.handleCancelShowConfirmTransferSite
-                                  )}
-                                  aria-label={i18n.t("no")}
-                                >
-                                  {i18n.t("no")}
-                                </button>
-                              </>
-                            ))}
                         </>
                       )}
                     </>
@@ -1339,16 +1293,6 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
     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);
index ed56e15a1c9c035557a4fd694571c9765d18a1d1..284805bf7ab898cccd984a007093d591356df88b 100644 (file)
@@ -39,6 +39,7 @@ interface AdminSettingsState {
   loading: boolean;
   banned: PersonViewSafe[];
   siteConfigLoading: boolean;
+  leaveAdminTeamLoading: boolean;
 }
 
 export class AdminSettings extends Component<any, AdminSettingsState> {
@@ -57,6 +58,7 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
     banned: [],
     loading: true,
     siteConfigLoading: null,
+    leaveAdminTeamLoading: null,
   };
 
   constructor(props: any, context: any) {
@@ -159,10 +161,26 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
             </li>
           ))}
         </ul>
+        {this.leaveAdmin()}
       </>
     );
   }
 
+  leaveAdmin() {
+    return (
+      <button
+        onClick={linkEvent(this, this.handleLeaveAdminTeam)}
+        class="btn btn-danger mb-2"
+      >
+        {this.state.leaveAdminTeamLoading ? (
+          <Spinner />
+        ) : (
+          i18n.t("leave_admin_team")
+        )}
+      </button>
+    );
+  }
+
   bannedUsers() {
     return (
       <>
@@ -230,6 +248,12 @@ export class AdminSettings extends Component<any, AdminSettingsState> {
     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<any, AdminSettingsState> {
       this.setState(this.state);
       var textarea: any = document.getElementById(this.siteConfigTextAreaId);
       autosize(textarea);
+    } else if (op == UserOperation.LeaveAdmin) {
+      let data = wsJsonToRes<GetSiteResponse>(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<GetSiteConfigResponse>(msg).data;
       this.state.siteConfigRes = data;
index 61a0930289d0a0cb2fa26271d835147d51e38626..1608d41075a5a077efc73eb48f773c4d7b1bfa0c 100644 (file)
@@ -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<PostListingProps, PostListingState> {
               )}
             </>
           )}
-          {/* Site Creator can transfer to another admin */}
-          {this.amSiteCreator &&
-            this.creatorIsAdmin &&
-            (!this.state.showConfirmTransferSite ? (
-              <button
-                class="btn btn-link btn-animate text-muted py-0"
-                onClick={linkEvent(this, this.handleShowConfirmTransferSite)}
-                aria-label={i18n.t("transfer_site")}
-              >
-                {i18n.t("transfer_site")}
-              </button>
-            ) : (
-              <>
-                <button
-                  class="btn btn-link btn-animate text-muted py-0 d-inline-block mr-1"
-                  aria-label={i18n.t("are_you_sure")}
-                >
-                  {i18n.t("are_you_sure")}
-                </button>
-                <button
-                  class="btn btn-link btn-animate text-muted py-0 d-inline-block mr-1"
-                  onClick={linkEvent(this, this.handleTransferSite)}
-                  aria-label={i18n.t("yes")}
-                >
-                  {i18n.t("yes")}
-                </button>
-                <button
-                  class="btn btn-link btn-animate text-muted py-0 d-inline-block"
-                  onClick={linkEvent(
-                    this,
-                    this.handleCancelShowConfirmTransferSite
-                  )}
-                  aria-label={i18n.t("no")}
-                >
-                  {i18n.t("no")}
-                </button>
-              </>
-            ))}
         </>
       )
     );
@@ -1617,16 +1578,6 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
     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;
index dcc9871fcd3b08927931c6ec5ae95fd4734d5e20..4ae1cc5a5fcc6ecfef08cacb364db76d599a0291 100644 (file)
@@ -645,7 +645,7 @@ export class Post extends Component<any, PostState> {
         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<GetSiteResponse>(msg).data;
       this.state.siteRes = data;
       this.setState(this.state);
index 1e7fd8d034ed545b5068b1dc9a694fcd6f693ce1..824c1a8dd0216d146bb350eced83cc925da31df5 100644 (file)
--- 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"