Adds ability to promote secrets from repository to organization scope, or from repository/organization to global scope. Includes conflict detection to prevent duplicate names at target scope, permission checks (org owner for repo→org, system admin for →global), and UI buttons with confirmation dialogs. Implements MoveSecret model method and PerformSecretsPromote handler.
411 lines
9.8 KiB
Handlebars
411 lines
9.8 KiB
Handlebars
{{template "base/head" .}}
|
|
<div role="main" aria-label="{{.Title}}" class="page-content repository blog">
|
|
{{template "repo/header" .}}
|
|
<div class="ui container">
|
|
{{template "base/alert" .}}
|
|
|
|
{{if .FeaturedPost}}
|
|
<div class="blog-featured">
|
|
<a href="{{$.RepoLink}}/blog/{{.FeaturedPost.ID}}" class="blog-featured-link">
|
|
{{if .FeaturedPost.FeaturedImage}}
|
|
<div class="blog-featured-image">
|
|
<img src="{{.FeaturedPost.FeaturedImage.DownloadURL}}" alt="{{.FeaturedPost.Title}}">
|
|
</div>
|
|
{{end}}
|
|
<div class="blog-featured-content">
|
|
{{if and (eq .FeaturedPost.Status 0) $.IsWriter}}
|
|
<span class="ui mini label yellow">{{ctx.Locale.Tr "repo.blog.draft"}}</span>
|
|
{{end}}
|
|
<h2 class="blog-featured-title">{{.FeaturedPost.Title}}</h2>
|
|
{{if .FeaturedPost.Subtitle}}
|
|
<p class="blog-featured-subtitle">{{.FeaturedPost.Subtitle}}</p>
|
|
{{end}}
|
|
<div class="blog-featured-meta">
|
|
{{if .FeaturedPost.Author}}
|
|
<img class="blog-avatar" src="{{.FeaturedPost.Author.AvatarLink ctx}}" alt="{{.FeaturedPost.Author.Name}}">
|
|
<span class="blog-author">{{.FeaturedPost.Author.DisplayName}}</span>
|
|
<span class="blog-meta-sep">·</span>
|
|
{{end}}
|
|
<span class="blog-date">{{DateUtils.TimeSince .FeaturedPost.CreatedUnix}}</span>
|
|
</div>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
{{end}}
|
|
|
|
<div class="blog-split-pane">
|
|
<div class="blog-content-pane">
|
|
{{if .Posts}}
|
|
<div class="blog-post-list">
|
|
{{range .Posts}}
|
|
<a href="{{$.RepoLink}}/blog/{{.ID}}" class="blog-post-tile">
|
|
{{if .FeaturedImage}}
|
|
<div class="blog-post-tile-image">
|
|
<img src="{{.FeaturedImage.DownloadURL}}" alt="{{.Title}}" loading="lazy">
|
|
</div>
|
|
{{else}}
|
|
<div class="blog-post-tile-image blog-post-tile-image-placeholder">
|
|
{{svg "octicon-note" 24}}
|
|
</div>
|
|
{{end}}
|
|
<div class="blog-post-tile-content">
|
|
<div class="blog-post-tile-header">
|
|
{{if and (eq .Status 0) $.IsWriter}}
|
|
<span class="ui mini label yellow">{{ctx.Locale.Tr "repo.blog.draft"}}</span>
|
|
{{end}}
|
|
<h3 class="blog-post-tile-title">{{.Title}}</h3>
|
|
</div>
|
|
{{if .Subtitle}}
|
|
<p class="blog-post-tile-subtitle">{{.Subtitle}}</p>
|
|
{{end}}
|
|
<div class="blog-post-tile-meta">
|
|
{{if .Author}}
|
|
<img class="blog-avatar-sm" src="{{.Author.AvatarLink ctx}}" alt="{{.Author.Name}}">
|
|
<span>{{.Author.DisplayName}}</span>
|
|
<span class="blog-meta-sep">·</span>
|
|
{{end}}
|
|
<span>{{DateUtils.TimeSince .CreatedUnix}}</span>
|
|
</div>
|
|
</div>
|
|
</a>
|
|
{{end}}
|
|
</div>
|
|
{{end}}
|
|
|
|
{{if and (not .FeaturedPost) (not .Posts)}}
|
|
<div class="empty-placeholder">
|
|
{{svg "octicon-note" 48}}
|
|
{{if .IsWriter}}
|
|
<h2>{{ctx.Locale.Tr "repo.blog.no_posts_member"}}</h2>
|
|
{{else}}
|
|
<h2>{{ctx.Locale.Tr "repo.blog.no_posts"}}</h2>
|
|
{{end}}
|
|
</div>
|
|
{{end}}
|
|
|
|
{{template "base/paginate" .}}
|
|
</div>
|
|
|
|
<div class="blog-sidebar-pane">
|
|
{{if .IsWriter}}
|
|
<a href="{{.RepoLink}}/blog/new" class="ui primary fluid button tw-mb-4">
|
|
{{svg "octicon-plus" 16}} {{ctx.Locale.Tr "repo.blog.new"}}
|
|
</a>
|
|
{{end}}
|
|
|
|
{{if ctx.Doer}}
|
|
<div class="tw-mb-4">
|
|
{{if .IsSubscribed}}
|
|
<form method="post" action="{{.RepoLink}}/blog/unsubscribe">
|
|
{{.CsrfTokenHtml}}
|
|
<button class="ui fluid button">{{svg "octicon-bell-slash" 16}} {{ctx.Locale.Tr "repo.blog.unsubscribe"}}</button>
|
|
</form>
|
|
{{else}}
|
|
<form method="post" action="{{.RepoLink}}/blog/subscribe">
|
|
{{.CsrfTokenHtml}}
|
|
<button class="ui fluid button">{{svg "octicon-bell" 16}} {{ctx.Locale.Tr "repo.blog.subscribe"}}</button>
|
|
</form>
|
|
{{end}}
|
|
</div>
|
|
{{end}}
|
|
|
|
{{if .CrossPromotedRepos}}
|
|
<div class="blog-sidebar-section">
|
|
<h4 class="blog-sidebar-title">{{ctx.Locale.Tr "repo.cross_promoted"}}</h4>
|
|
<div class="cross-promote-tiles">
|
|
{{range .CrossPromotedRepos}}
|
|
<a class="cross-promote-tile" href="{{.TargetRepo.Link}}">
|
|
<div class="cross-promote-tile-icon">
|
|
{{if .TargetRepo.Avatar}}
|
|
<img src="{{.TargetRepo.RelAvatarLink ctx}}" alt="">
|
|
{{else}}
|
|
{{svg "octicon-repo" 18}}
|
|
{{end}}
|
|
</div>
|
|
<div class="cross-promote-tile-content">
|
|
<div class="cross-promote-tile-name">{{if .TargetRepo.DisplayTitle}}{{.TargetRepo.DisplayTitle}}{{else}}{{.TargetRepo.FullName}}{{end}}</div>
|
|
{{if .TargetRepo.Description}}
|
|
<div class="cross-promote-tile-desc">{{.TargetRepo.Description}}</div>
|
|
{{end}}
|
|
</div>
|
|
<div class="cross-promote-tile-arrow">{{svg "octicon-chevron-right" 14}}</div>
|
|
</a>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
{{end}}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.blog-featured {
|
|
margin-bottom: 24px;
|
|
}
|
|
.blog-featured-link {
|
|
display: flex;
|
|
gap: 24px;
|
|
padding: 20px;
|
|
border-radius: 12px;
|
|
border: 1px solid var(--color-secondary-alpha-40);
|
|
background: var(--color-box-body);
|
|
color: var(--color-text);
|
|
text-decoration: none;
|
|
transition: border-color 0.15s, box-shadow 0.15s;
|
|
}
|
|
.blog-featured-link:hover {
|
|
border-color: var(--color-primary-alpha-60);
|
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
|
|
color: var(--color-text);
|
|
text-decoration: none;
|
|
}
|
|
.blog-featured-image {
|
|
flex-shrink: 0;
|
|
width: 320px;
|
|
height: 200px;
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
background: var(--color-secondary-alpha-20);
|
|
}
|
|
.blog-featured-image img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
}
|
|
.blog-featured-content {
|
|
flex: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
min-width: 0;
|
|
}
|
|
.blog-featured-title {
|
|
font-size: 22px;
|
|
font-weight: 700;
|
|
line-height: 1.3;
|
|
margin: 0 0 6px;
|
|
}
|
|
.blog-featured-subtitle {
|
|
font-size: 14px;
|
|
color: var(--color-text-light);
|
|
margin: 0 0 14px;
|
|
line-height: 1.5;
|
|
display: -webkit-box;
|
|
-webkit-line-clamp: 2;
|
|
-webkit-box-orient: vertical;
|
|
overflow: hidden;
|
|
}
|
|
.blog-featured-meta {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
font-size: 13px;
|
|
color: var(--color-text-light);
|
|
}
|
|
.blog-avatar {
|
|
width: 24px;
|
|
height: 24px;
|
|
border-radius: 50%;
|
|
}
|
|
.blog-avatar-sm {
|
|
width: 18px;
|
|
height: 18px;
|
|
border-radius: 50%;
|
|
}
|
|
.blog-meta-sep {
|
|
color: var(--color-text-light-3);
|
|
}
|
|
.blog-split-pane {
|
|
display: flex;
|
|
gap: 24px;
|
|
}
|
|
.blog-content-pane {
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
.blog-sidebar-pane {
|
|
flex-shrink: 0;
|
|
width: 280px;
|
|
}
|
|
.blog-sidebar-title {
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
margin: 0 0 10px;
|
|
color: var(--color-text-light);
|
|
}
|
|
.blog-sidebar-section {
|
|
margin-bottom: 20px;
|
|
}
|
|
.blog-post-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 12px;
|
|
margin-bottom: 20px;
|
|
}
|
|
.blog-post-tile {
|
|
display: flex;
|
|
gap: 16px;
|
|
padding: 14px;
|
|
border-radius: 10px;
|
|
border: 1px solid var(--color-secondary-alpha-40);
|
|
background: var(--color-box-body);
|
|
color: var(--color-text);
|
|
text-decoration: none;
|
|
transition: border-color 0.15s, box-shadow 0.15s;
|
|
}
|
|
.blog-post-tile:hover {
|
|
border-color: var(--color-primary-alpha-60);
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
|
color: var(--color-text);
|
|
text-decoration: none;
|
|
}
|
|
.blog-post-tile-image {
|
|
flex-shrink: 0;
|
|
width: 120px;
|
|
height: 80px;
|
|
border-radius: 6px;
|
|
overflow: hidden;
|
|
background: var(--color-secondary-alpha-20);
|
|
}
|
|
.blog-post-tile-image img {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
}
|
|
.blog-post-tile-image-placeholder {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: var(--color-text-light-3);
|
|
}
|
|
.blog-post-tile-content {
|
|
flex: 1;
|
|
min-width: 0;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
}
|
|
.blog-post-tile-header {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
.blog-post-tile-title {
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
line-height: 1.3;
|
|
margin: 0 0 2px;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
.blog-post-tile-subtitle {
|
|
font-size: 13px;
|
|
color: var(--color-text-light);
|
|
margin: 0 0 8px;
|
|
line-height: 1.4;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
.blog-post-tile-meta {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 5px;
|
|
font-size: 12px;
|
|
color: var(--color-text-light);
|
|
}
|
|
.cross-promote-tiles {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 6px;
|
|
width: 100%;
|
|
}
|
|
.cross-promote-tile {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
width: 100%;
|
|
min-height: 48px;
|
|
padding: 8px 10px;
|
|
border-radius: 8px;
|
|
border: 1px solid var(--color-secondary-alpha-40);
|
|
background: var(--color-box-body);
|
|
color: var(--color-text);
|
|
text-decoration: none;
|
|
transition: border-color 0.15s, box-shadow 0.15s;
|
|
}
|
|
.cross-promote-tile:hover {
|
|
border-color: var(--color-primary-alpha-60);
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
|
text-decoration: none;
|
|
color: var(--color-text);
|
|
}
|
|
.cross-promote-tile-icon {
|
|
flex-shrink: 0;
|
|
width: 28px;
|
|
height: 28px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: 6px;
|
|
background: var(--color-secondary-alpha-20);
|
|
color: var(--color-text-light);
|
|
}
|
|
.cross-promote-tile-icon img {
|
|
width: 28px;
|
|
height: 28px;
|
|
border-radius: 6px;
|
|
object-fit: contain;
|
|
}
|
|
.cross-promote-tile-content {
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
.cross-promote-tile-name {
|
|
font-weight: 600;
|
|
font-size: 13px;
|
|
line-height: 1.3;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
.cross-promote-tile-desc {
|
|
font-size: 11px;
|
|
color: var(--color-text-light);
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
.cross-promote-tile-arrow {
|
|
flex-shrink: 0;
|
|
color: var(--color-text-light-3);
|
|
opacity: 0;
|
|
transition: opacity 0.15s;
|
|
}
|
|
.cross-promote-tile:hover .cross-promote-tile-arrow {
|
|
opacity: 0.6;
|
|
}
|
|
@media (max-width: 768px) {
|
|
.blog-split-pane {
|
|
flex-direction: column;
|
|
}
|
|
.blog-sidebar-pane {
|
|
width: 100%;
|
|
}
|
|
.blog-featured-link {
|
|
flex-direction: column;
|
|
}
|
|
.blog-featured-image {
|
|
width: 100%;
|
|
height: 180px;
|
|
}
|
|
.blog-post-tile-image {
|
|
width: 80px;
|
|
height: 60px;
|
|
}
|
|
}
|
|
</style>
|
|
{{template "base/footer" .}}
|