aboutsummaryrefslogtreecommitdiffstats
path: root/templates/user/settings/applications.tmpl
blob: 501f238c7a3775611019e4a668dacdd0df509824 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings applications")}}
	<div class="user-setting-content">
		<h4 class="ui top attached header">
			{{ctx.Locale.Tr "settings.manage_access_token"}}
		</h4>
		<div class="ui attached segment">
			<div class="flex-list">
				<div class="flex-item">
					{{ctx.Locale.Tr "settings.tokens_desc"}}
				</div>
				{{range .Tokens}}
					<div class="flex-item">
						<div class="flex-item-leading">
							<span class="text {{if .HasRecentActivity}}green{{end}}" {{if .HasRecentActivity}}data-tooltip-content="{{ctx.Locale.Tr "settings.token_state_desc"}}"{{end}}>
								{{svg "fontawesome-send" 32}}
							</span>
						</div>
						<div class="flex-item-main">
							<details>
								<summary><span class="flex-item-title">{{.Name}}</span></summary>
								<p class="tw-my-1">
									{{ctx.Locale.Tr "settings.repo_and_org_access"}}:
									{{if .DisplayPublicOnly}}
										{{ctx.Locale.Tr "settings.permissions_public_only"}}
									{{else}}
										{{ctx.Locale.Tr "settings.permissions_access_all"}}
									{{end}}
								</p>
								<p class="tw-my-1">{{ctx.Locale.Tr "settings.permissions_list"}}</p>
								<ul class="tw-my-1">
								{{range .Scope.StringSlice}}
									{{if (ne . $.AccessTokenScopePublicOnly)}}
										<li>{{.}}</li>
									{{end}}
								{{end}}
								</ul>
							</details>
							<div class="flex-item-body">
								<i>{{ctx.Locale.Tr "settings.added_on" (DateUtils.AbsoluteShort .CreatedUnix)}} — {{svg "octicon-info"}} {{if .HasUsed}}{{ctx.Locale.Tr "settings.last_used"}} <span {{if .HasRecentActivity}}class="text green"{{end}}>{{DateUtils.AbsoluteShort .UpdatedUnix}}</span>{{else}}{{ctx.Locale.Tr "settings.no_activity"}}{{end}}</i>
							</div>
						</div>
						<div class="flex-item-trailing">
								<button class="ui red tiny button delete-button" data-modal-id="delete-token" data-url="{{$.Link}}/delete" data-id="{{.ID}}">
									{{svg "octicon-trash" 16 "tw-mr-1"}}
									{{ctx.Locale.Tr "settings.delete_token"}}
								</button>
						</div>
					</div>
				{{end}}
			</div>
		</div>
		<div class="ui bottom attached segment">
			<details {{if or .name (not .Tokens)}}open{{end}}>
				<summary><h4 class="ui header tw-inline-block tw-my-2">{{ctx.Locale.Tr "settings.generate_new_token"}}</h4></summary>
				<form class="ui form ignore-dirty" action="{{.Link}}" method="post">
					{{.CsrfTokenHtml}}
					<div class="field {{if .Err_Name}}error{{end}}">
						<label for="name">{{ctx.Locale.Tr "settings.token_name"}}</label>
						<input id="name" name="name" value="{{.name}}" required maxlength="255">
					</div>
					<div class="field">
						<div class="tw-my-2">{{ctx.Locale.Tr "settings.repo_and_org_access"}}</div>
						<label class="gt-checkbox">
							<input type="radio" name="scope-public-only" value="{{$.AccessTokenScopePublicOnly}}"> {{ctx.Locale.Tr "settings.permissions_public_only"}}
						</label>
						<label class="gt-checkbox">
							<input type="radio" name="scope-public-only" value="" checked> {{ctx.Locale.Tr "settings.permissions_access_all"}}
						</label>
					</div>
					<div>
						<div class="tw-my-2">{{ctx.Locale.Tr "settings.access_token_desc" (HTMLFormat `href="%s/api/swagger" target="_blank"` AppSubUrl) (`href="https://docs.gitea.com/development/oauth2-provider#scopes" target="_blank"`|SafeHTML)}}</div>
						<table class="ui table unstackable tw-my-2">
						{{range $category := .TokenCategories}}
							<tr>
								<td>{{$category}}</td>
								<td><label class="gt-checkbox"><input type="radio" name="scope-{{$category}}" value="" checked> {{ctx.Locale.Tr "settings.permission_no_access"}}</label></td>
								<td><label class="gt-checkbox"><input type="radio" name="scope-{{$category}}" value="read:{{$category}}"> {{ctx.Locale.Tr "settings.permission_read"}}</label></td>
								<td><label class="gt-checkbox"><input type="radio" name="scope-{{$category}}" value="write:{{$category}}"> {{ctx.Locale.Tr "settings.permission_write"}}</label></td>
							</tr>
						{{end}}
						</table>
					</div>
					<button class="ui primary button">
						{{ctx.Locale.Tr "settings.generate_token"}}
					</button>
				</form>
			</details>
		</div>

		{{if .EnableOAuth2}}
			{{template "user/settings/grants_oauth2" .}}
			{{template "user/settings/applications_oauth2" .}}
		{{end}}
	</div>

<div class="ui g-modal-confirm delete modal" id="delete-token">
	<div class="header">
		{{svg "octicon-trash"}}
		{{ctx.Locale.Tr "settings.access_token_deletion"}}
	</div>
	<div class="content">
		<p>{{ctx.Locale.Tr "settings.access_token_deletion_desc"}}</p>
	</div>
	{{template "base/modal_actions_confirm"}}
</div>

{{template "user/settings/layout_footer" .}}