Skip to content

Commit 5f21e0f

Browse files
authored
Automatically select the org when click create repo from org dashboard (#24325)
![image](https://user-images.githubusercontent.com/18380374/234209941-d661b07f-e963-427b-a673-78c46043a792.png) In org dashboard, the create repo link will be `repo/create?org={orgId}`
1 parent 2ec2d06 commit 5f21e0f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

templates/user/dashboard/repolist.tmpl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ data.teamId = {{.Team.ID}};
4444
{{if not .ContextUser.IsOrganization}}
4545
data.organizations = [{{range .Orgs}}{'name': {{.Name}}, 'num_repos': {{.NumRepos}}},{{end}}];
4646
data.isOrganization = false;
47-
data.organizationsTotalCount = {{.UserOrgsCount}}
48-
data.canCreateOrganization = {{.SignedUser.CanCreateOrganization}}
47+
data.organizationsTotalCount = {{.UserOrgsCount}};
48+
data.canCreateOrganization = {{.SignedUser.CanCreateOrganization}};
49+
{{else}}
50+
data.organizationId = {{.ContextUser.ID}};
4951
{{end}}
5052

5153
window.config.pageData.dashboardRepoList = data;

web_src/js/components/DashboardRepoList.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{{ textMyRepos }}
1111
<span class="ui grey label gt-ml-3">{{ reposTotalCount }}</span>
1212
</div>
13-
<a :href="subUrl + '/repo/create'" :data-tooltip-content="textNewRepo">
13+
<a :href="subUrl + '/repo/create' + (isOrganization ? '?org=' + organizationId : '')" :data-tooltip-content="textNewRepo">
1414
<svg-icon name="octicon-plus"/>
1515
<span class="sr-only">{{ textNewRepo }}</span>
1616
</a>
@@ -199,6 +199,7 @@ const sfc = {
199199
isOrganization: true,
200200
canCreateOrganization: false,
201201
organizationsTotalCount: 0,
202+
organizationId: 0,
202203
203204
subUrl: appSubUrl,
204205
...pageData.dashboardRepoList,

0 commit comments

Comments
 (0)