Przeglądaj źródła

Add 'Organizations' page to user settings (#3587)

User is now able to view full list of organizations belongs to.
Unknwon 8 lat temu
rodzic
commit
7aa53635fe

+ 6 - 1
cmd/web.go

@@ -247,7 +247,12 @@ func runWeb(ctx *cli.Context) error {
 		m.Combo("/applications").Get(user.SettingsApplications).
 			Post(bindIgnErr(auth.NewAccessTokenForm{}), user.SettingsApplicationsPost)
 		m.Post("/applications/delete", user.SettingsDeleteApplication)
-		m.Get("/organizations", user.SettingsOrganizations)
+
+		m.Group("/organizations", func() {
+			m.Get("", user.SettingsOrganizations)
+			m.Post("/leave", user.SettingsLeaveOrganization)
+		})
+
 		m.Route("/delete", "GET,POST", user.SettingsDelete)
 	}, reqSignIn, func(ctx *context.Context) {
 		ctx.Data["PageIsUserSettings"] = true

+ 3 - 1
conf/locale/locale_en-US.ini

@@ -337,7 +337,9 @@ access_token_deletion = Personal Access Token Deletion
 access_token_deletion_desc = Delete this personal access token will remove all related accesses of application. Do you want to continue?
 delete_token_success = Personal access token has been removed successfully! Don't forget to update your application as well.
 
-orgs_none = You are not a member of any organizations.
+orgs.none = You are not a member of any organizations.
+orgs.leave_title = Leave an organization
+orgs.leave_desc = You will lose access to all repositories and teams after you left the organization. Do you want to continue?
 
 delete_account = Delete Your Account
 delete_prompt = The operation will delete your account permanently, and <strong>CANNOT</strong> be undone!

+ 1 - 1
gogs.go

@@ -16,7 +16,7 @@ import (
 	"github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.9.121.0127"
+const APP_VER = "0.9.122.0127"
 
 func init() {
 	setting.AppVer = APP_VER

Plik diff jest za duży
+ 0 - 0
modules/bindata/bindata.go


+ 10 - 0
public/css/gogs.css

@@ -2658,6 +2658,16 @@ footer .ui.language .menu {
 .user.settings .email.list .item:not(:first-child) .button {
   margin-top: -10px;
 }
+.user.settings .orgs {
+  padding: 0;
+}
+.user.settings .orgs .item {
+  padding: 10px;
+}
+.user.settings .orgs .item .button {
+  margin-top: 5px;
+  margin-right: 8px;
+}
 .user.profile .ui.card .username {
   display: block;
 }

+ 0 - 10
public/less/_form.less

@@ -18,16 +18,6 @@
 	}
 }
 
-ui.attached.segment.orgs {
-	padding: 0px;
-	div .item {
-		padding: 11px;
-		.content {
-			font-weight: bold;
-		}
-	}
-}
-
 @create-page-form-input-padding: 250px !important;
 #create-page-form {
 	form {

+ 10 - 0
public/less/_user.less

@@ -19,6 +19,16 @@
 				}
 			}
 		}
+		.orgs {
+			padding: 0;
+			.item {
+				padding: 10px;
+				.button {
+					margin-top: 5px;
+					margin-right: 8px;
+				}
+			}
+		}
 	}
 
 	&.profile {

+ 12 - 1
routers/user/setting.go

@@ -428,7 +428,7 @@ func SettingsOrganizations(ctx *context.Context) {
 	ctx.Data["Title"] = ctx.Tr("settings")
 	ctx.Data["PageIsSettingsOrganizations"] = true
 
-	orgs, err := models.GetOrgsByUserID(ctx.User.ID, ctx.IsSigned && ctx.User.IsAdmin)
+	orgs, err := models.GetOrgsByUserID(ctx.User.ID, true)
 	if err != nil {
 		ctx.Handle(500, "GetOrgsByUserID", err)
 		return
@@ -438,6 +438,17 @@ func SettingsOrganizations(ctx *context.Context) {
 	ctx.HTML(200, SETTINGS_ORGANIZATIONS)
 }
 
+func SettingsLeaveOrganization(ctx *context.Context) {
+	err := models.RemoveOrgUser(ctx.QueryInt64("id"), ctx.User.ID)
+	if models.IsErrLastOrgOwner(err) {
+		ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
+	}
+
+	ctx.JSON(200, map[string]interface{}{
+		"redirect": setting.AppSubUrl + "/user/settings/organizations",
+	})
+}
+
 func SettingsDelete(ctx *context.Context) {
 	ctx.Data["Title"] = ctx.Tr("settings")
 	ctx.Data["PageIsSettingsDelete"] = true

+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
-0.9.121.0127
+0.9.122.0127

+ 15 - 2
templates/user/settings/organizations.tmpl

@@ -17,7 +17,9 @@
 							{{range .Orgs}}
 							<div class="item">
 								<div class="right floated content">
-									<div class="ui button">Leave</div>
+									<button class="ui red tiny button inline text-thin delete-button" data-url="{{$.Link}}/leave" data-id="{{.ID}}">
+										{{$.i18n.Tr "org.members.leave"}}
+									</button>
 								</div>
 								<img class="ui mini image" src="{{.RelAvatarLink}}">
 								<div class="content">
@@ -27,11 +29,22 @@
 							{{end}}
 						</div>
 					{{else}}
-						{{.i18n.Tr "settings.orgs_none"}}
+						{{.i18n.Tr "settings.orgs.none"}}
 					{{end}}
 				</div>
 			</div>
 		</div>
 	</div>
 </div>
+
+<div class="ui small basic delete modal">
+	<div class="ui icon header">
+		<i class="trash icon"></i>
+		{{.i18n.Tr "settings.orgs.leave_title"}}
+	</div>
+	<div class="content">
+		<p>{{.i18n.Tr "settings.orgs.leave_desc"}}</p>
+	</div>
+	{{template "base/delete_modal_actions" .}}
+</div>
 {{template "base/footer" .}}

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików