Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
* upstream/main:
  Display owner of a runner as a tooltip instead of static text (go-gitea#24377)
  Remove highlight in repo list (go-gitea#24675)
  Update pin and add pin-slash (go-gitea#24669)
  Improve empty notifications display (go-gitea#24668)
  • Loading branch information
zjjhot committed May 12, 2023
2 parents 39754d7 + 4980813 commit f53b33b
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 31 deletions.
22 changes: 17 additions & 5 deletions models/actions/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/shared/types"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/timeutil"
"code.gitea.io/gitea/modules/translation"
Expand All @@ -28,7 +29,7 @@ type ActionRunner struct {
Version string `xorm:"VARCHAR(64)"`
OwnerID int64 `xorm:"index"` // org level runner, 0 means system
Owner *user_model.User `xorm:"-"`
RepoID int64 `xorm:"index"` // repo level runner, if orgid also is zero, then it's a global
RepoID int64 `xorm:"index"` // repo level runner, if OwnerID also is zero, then it's a global
Repo *repo_model.Repository `xorm:"-"`
Description string `xorm:"TEXT"`
Base int // 0 native 1 docker 2 virtual machine
Expand All @@ -52,14 +53,25 @@ type ActionRunner struct {
Deleted timeutil.TimeStamp `xorm:"deleted"`
}

func (r *ActionRunner) OwnType() string {
// BelongsToOwnerName before calling, should guarantee that all attributes are loaded
func (r *ActionRunner) BelongsToOwnerName() string {
if r.RepoID != 0 {
return fmt.Sprintf("Repo(%s)", r.Repo.FullName())
return r.Repo.FullName()
}
if r.OwnerID != 0 {
return fmt.Sprintf("Org(%s)", r.Owner.Name)
return r.Owner.Name
}
return "Global"
return ""
}

func (r *ActionRunner) BelongsToOwnerType() types.OwnerType {
if r.RepoID != 0 {
return types.OwnerTypeRepository
}
if r.OwnerID != 0 {
return types.OwnerTypeOrganization
}
return types.OwnerTypeSystemGlobal
}

func (r *ActionRunner) Status() runnerv1.RunnerStatus {
Expand Down
29 changes: 29 additions & 0 deletions models/shared/types/ownertype.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT

package types

import "code.gitea.io/gitea/modules/translation"

type OwnerType string

const (
OwnerTypeSystemGlobal = "system-global"
OwnerTypeIndividual = "individual"
OwnerTypeRepository = "repository"
OwnerTypeOrganization = "organization"
)

func (o OwnerType) LocaleString(locale translation.Locale) string {
switch o {
case OwnerTypeSystemGlobal:
return locale.Tr("concept_system_global")
case OwnerTypeIndividual:
return locale.Tr("concept_user_individual")
case OwnerTypeRepository:
return locale.Tr("concept_code_repository")
case OwnerTypeOrganization:
return locale.Tr("concept_user_organization")
}
return locale.Tr("unknown")
}
5 changes: 5 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ unknown = Unknown

rss_feed = RSS Feed

concept_system_global = Global
concept_user_individual = Individual
concept_code_repository = Repository
concept_user_organization = Organization

[aria]
navbar = Navigation Bar
footer = Footer
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@github/relative-time-element": "4.3.0",
"@github/text-expander-element": "2.3.0",
"@mcaptcha/vanilla-glue": "0.1.0-alpha-3",
"@primer/octicons": "18.3.0",
"@primer/octicons": "19.1.0",
"@vue/compiler-sfc": "3.2.47",
"@webcomponents/custom-elements": "1.6.0",
"add-asset-webpack-plugin": "2.0.1",
Expand Down
1 change: 1 addition & 0 deletions public/img/svg/octicon-devices.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/img/svg/octicon-move-to-top.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/img/svg/octicon-pin-slash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion public/img/svg/octicon-pin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion templates/projects/view.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
data-modal-default-project-board-header="{{$.locale.Tr "repo.projects.column.unset_default"}}"
data-modal-default-project-board-content="{{$.locale.Tr "repo.projects.column.unset_default_desc"}}"
data-url="{{$.Link}}/{{.ID}}/unsetdefault">
{{svg "octicon-pin"}}
{{svg "octicon-pin-slash"}}
{{$.locale.Tr "repo.projects.column.unset_default"}}
</a>
{{end}}
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/projects/view.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
data-modal-default-project-board-content="{{$.locale.Tr "repo.projects.column.unset_default_desc"}}"
data-type="unset_default"
data-url="{{$.Link}}/{{.ID}}/unsetdefault">
{{svg "octicon-pin"}}
{{svg "octicon-pin-slash"}}
{{$.locale.Tr "repo.projects.column.unset_default"}}
</a>
{{end}}
Expand Down
10 changes: 5 additions & 5 deletions templates/shared/actions/runner_edit.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@
{{template "base/disable_form_autofill"}}
{{.CsrfTokenHtml}}
<div class="runner-basic-info">
<div class="field gt-dib gt-mr-4 disabled">
<div class="field gt-dib gt-mr-4">
<label>{{.locale.Tr "actions.runners.status"}}</label>
<span class="runner-status-{{if .Runner.IsOnline}}online{{else}}offline{{end}}">{{.Runner.StatusLocaleName $.locale}}</span>
</div>
<div class="field gt-dib gt-mr-4 disabled">
<div class="field gt-dib gt-mr-4">
<label>{{.locale.Tr "actions.runners.last_online"}}</label>
<span>{{if .LastOnline}}{{TimeSinceUnix .LastOnline $.locale}}{{else}}{{$.locale.Tr "never"}}{{end}}</span>
</div>
<div class="field gt-dib gt-mr-4 disabled">
<div class="field gt-dib gt-mr-4">
<label>{{.locale.Tr "actions.runners.agent_labels"}}</label>
<span>
{{range .Runner.AgentLabels}}
<span>{{.}}</span>
{{end}}
</span>
</div>
<div class="field gt-dib gt-mr-4 disabled">
<div class="field gt-dib gt-mr-4">
<label>{{.locale.Tr "actions.runners.owner_type"}}</label>
<span>{{.Runner.OwnType}}</span>
<span data-tooltip-content="{{.Runner.BelongsToOwnerName}}">{{.Runner.BelongsToOwnerType.LocaleString $.locale}}</span>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion templates/shared/actions/runner_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<td>{{.ID}}</td>
<td><p data-tooltip-content="{{.Description}}">{{.Name}}</p></td>
<td>{{if .Version}}{{.Version}}{{else}}{{$.locale.Tr "unknown"}}{{end}}</td>
<td>{{.OwnType}}</td>
<td><span data-tooltip-content="{{.BelongsToOwnerName}}">{{.BelongsToOwnerType.LocaleString $.locale}}<span></td>
<td class="runner-tags">
{{range .AllLabels}}<span class="ui label">{{.}}</span>{{end}}
</td>
Expand Down
18 changes: 12 additions & 6 deletions templates/user/notification/notification_div.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<div role="main" aria-label="{{.Title}}" class="page-content user notification" id="notification_div" data-params="{{.Page.GetParams}}" data-sequence-number="{{.SequenceNumber}}">
<div class="ui container">
<h1 class="ui dividing header">{{.locale.Tr "notification.notifications"}}</h1>
<h1 class="ui header gt-df gt-ac">
{{svg "octicon-bell" 28 "gt-mr-3 gt-mt-1"}}
{{.locale.Tr "notification.notifications"}}
</h1>
<div class="ui top attached tabular menu">
{{$notificationUnreadCount := call .NotificationUnreadCount}}
<a href="{{AppSubUrl}}/notifications?q=unread" class="{{if eq .Status 1}}active {{end}}item">
Expand All @@ -23,11 +26,14 @@
</div>
<div class="ui bottom attached active tab segment gt-p-3">
{{if eq (len .Notifications) 0}}
{{if eq .Status 1}}
{{.locale.Tr "notification.no_unread"}}
{{else}}
{{.locale.Tr "notification.no_read"}}
{{end}}
<div class="gt-df gt-ac gt-fc gt-p-4">
{{svg "octicon-inbox" 56 "gt-mb-4"}}
{{if eq .Status 1}}
{{.locale.Tr "notification.no_unread"}}
{{else}}
{{.locale.Tr "notification.no_read"}}
{{end}}
</div>
{{else}}
<table class="ui unstackable very compact small table" id="notification_table">
<tbody>
Expand Down
4 changes: 0 additions & 4 deletions web_src/css/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,6 @@
border-bottom: 1px solid var(--color-secondary);
}

.feeds .list ul li.private {
background-color: var(--color-box-body-highlight);
}

.feeds .list ul li .repo-list-link {
padding: 6px 1em;
display: block;
Expand Down
2 changes: 1 addition & 1 deletion web_src/js/components/DashboardRepoList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</div>
<div v-if="repos.length" class="ui attached table segment gt-rounded-bottom">
<ul class="repo-owner-name-list">
<li v-for="repo in repos" :class="{'private': repo.private || repo.internal}" :key="repo.id">
<li v-for="repo in repos" :key="repo.id">
<a class="repo-list-link gt-df gt-ac gt-sb" :href="repo.link">
<div class="item-name gt-df gt-ac gt-f1">
<svg-icon :name="repoIcon(repo)" :size="16" class-name="gt-mr-2"/>
Expand Down

0 comments on commit f53b33b

Please sign in to comment.