From 95841b7b7e8cfb934585f3a994c6a82e00e9110f Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Wed, 9 Aug 2023 14:39:13 +0000 Subject: [PATCH 01/17] add disable workflow feature Signed-off-by: a1012112796 <1012112796@qq.com> --- models/repo/repo.go | 6 +++ models/repo/repo_unit.go | 63 ++++++++++++++++++++++++++++- models/repo/repo_unit_test.go | 30 ++++++++++++++ options/locale/locale_en-US.ini | 6 +++ routers/web/repo/actions/actions.go | 9 +++++ routers/web/repo/actions/view.go | 41 +++++++++++++++++++ routers/web/web.go | 2 + services/actions/notifier_helper.go | 7 ++++ templates/repo/actions/list.tmpl | 12 ++++++ 9 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 models/repo/repo_unit_test.go diff --git a/models/repo/repo.go b/models/repo/repo.go index 3d1f2dcfa8a67..b37948fea77a6 100644 --- a/models/repo/repo.go +++ b/models/repo/repo.go @@ -391,7 +391,13 @@ func (repo *Repository) MustGetUnit(ctx context.Context, tp unit.Type) *RepoUnit Type: tp, Config: new(IssuesConfig), } + } else if tp == unit.TypeActions { + return &RepoUnit{ + Type: tp, + Config: new(ActionsConfig), + } } + return &RepoUnit{ Type: tp, Config: new(UnitConfig), diff --git a/models/repo/repo_unit.go b/models/repo/repo_unit.go index 7c1af95bf0921..97b9697080c1d 100644 --- a/models/repo/repo_unit.go +++ b/models/repo/repo_unit.go @@ -6,6 +6,7 @@ package repo import ( "context" "fmt" + "strings" "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/unit" @@ -162,6 +163,59 @@ func (cfg *PullRequestsConfig) GetDefaultMergeStyle() MergeStyle { return MergeStyleMerge } +type ActionsConfig struct { + DisabledWorkflows []string +} + +func (cfg *ActionsConfig) EnableWrokflow(file string) { + for i, workflow := range cfg.DisabledWorkflows { + if file == workflow { + cfg.DisabledWorkflows = append(cfg.DisabledWorkflows[:i], cfg.DisabledWorkflows[i+1:]...) + break + } + } +} + +func (cfg *ActionsConfig) ToString() string { + result := "" + + for _, workflow := range cfg.DisabledWorkflows { + result += workflow + "," + } + + return strings.TrimSuffix(result, ",") +} + +func (cfg *ActionsConfig) IsWorkflowDisabled(file string) bool { + for _, workflow := range cfg.DisabledWorkflows { + if file == workflow { + return true + } + } + + return false +} + +func (cfg *ActionsConfig) DisableWrokflow(file string) { + for _, workflow := range cfg.DisabledWorkflows { + if file == workflow { + return + } + } + + cfg.DisabledWorkflows = append(cfg.DisabledWorkflows, file) +} + +// FromDB fills up a ActionsConfig from serialized format. +func (cfg *ActionsConfig) FromDB(bs []byte) error { + return json.UnmarshalHandleDoubleEncode(bs, &cfg) +} + +// ToDB exports a ActionsConfig to a serialized format. +func (cfg *ActionsConfig) ToDB() ([]byte, error) { + return json.Marshal(cfg) +} + // BeforeSet is invoked from XORM before setting the value of a field of this object. func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) { switch colName { @@ -175,7 +229,9 @@ func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) { r.Config = new(PullRequestsConfig) case unit.TypeIssues: r.Config = new(IssuesConfig) - case unit.TypeCode, unit.TypeReleases, unit.TypeWiki, unit.TypeProjects, unit.TypePackages, unit.TypeActions: + case unit.TypeActions: + r.Config = new(ActionsConfig) + case unit.TypeCode, unit.TypeReleases, unit.TypeWiki, unit.TypeProjects, unit.TypePackages: fallthrough default: r.Config = new(UnitConfig) @@ -218,6 +274,11 @@ func (r *RepoUnit) ExternalTrackerConfig() *ExternalTrackerConfig { return r.Config.(*ExternalTrackerConfig) } +// ActionsConfig returns config for unit.ActionsConfig +func (r *RepoUnit) ActionsConfig() *ActionsConfig { + return r.Config.(*ActionsConfig) +} + func getUnitsByRepoID(ctx context.Context, repoID int64) (units []*RepoUnit, err error) { var tmpUnits []*RepoUnit if err := db.GetEngine(ctx).Where("repo_id = ?", repoID).Find(&tmpUnits); err != nil { diff --git a/models/repo/repo_unit_test.go b/models/repo/repo_unit_test.go new file mode 100644 index 0000000000000..4576893815a8b --- /dev/null +++ b/models/repo/repo_unit_test.go @@ -0,0 +1,30 @@ +// Copyright 2023 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package repo + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestActionsConfig(t *testing.T) { + cfg := &ActionsConfig{} + cfg.DisableWrokflow("test1.yaml") + assert.EqualValues(t, []string{"test1.yaml"}, cfg.DisabledWorkflows) + + cfg.DisableWrokflow("test1.yaml") + assert.EqualValues(t, []string{"test1.yaml"}, cfg.DisabledWorkflows) + + cfg.EnableWrokflow("test1.yaml") + assert.EqualValues(t, []string{}, cfg.DisabledWorkflows) + + cfg.EnableWrokflow("test1.yaml") + assert.EqualValues(t, []string{}, cfg.DisabledWorkflows) + + cfg.DisableWrokflow("test1.yaml") + cfg.DisableWrokflow("test2.yaml") + cfg.DisableWrokflow("test3.yaml") + assert.EqualValues(t, "test1.yaml,test2.yaml,test3.yaml", cfg.ToString()) +} diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 2023dade3fa46..caacc5385380c 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -95,6 +95,9 @@ enabled = Enabled disabled = Disabled locked = Locked +enable = Enable +disable = Disable + copy = Copy copy_url = Copy URL copy_content = Copy content @@ -3488,6 +3491,9 @@ runs.status_no_select = All status runs.no_results = No results matched. runs.no_runs = The workflow has no runs yet. +workflow.disable_success = The workflow '%s' has been disabled successfully! +workflow.enable_success = The workflow '%s' has been enabled successfully! + need_approval_desc = Need approval to run workflows for fork pull request. variables = Variables diff --git a/routers/web/repo/actions/actions.go b/routers/web/repo/actions/actions.go index 5a12f52dcd142..b0f4b6f8971da 100644 --- a/routers/web/repo/actions/actions.go +++ b/routers/web/repo/actions/actions.go @@ -137,6 +137,15 @@ func List(ctx *context.Context) { actorID := ctx.FormInt64("actor") status := ctx.FormInt("status") ctx.Data["CurWorkflow"] = workflow + + actionsConfig := ctx.Repo.Repository.MustGetUnit(ctx, unit.TypeActions).ActionsConfig() + ctx.Data["ActionsConfig"] = actionsConfig + + if len(workflow) > 0 && ctx.Repo.IsAdmin() { + ctx.Data["AllowDisableOrEnableWorkflow"] = true + ctx.Data["CurWorkflowDisabled"] = actionsConfig.IsWorkflowDisabled(workflow) + } + // if status or actor query param is not given to frontend href, (href="//actions") // they will be 0 by default, which indicates get all status or actors ctx.Data["CurActor"] = actorID diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index abb1f6b66b979..2f452e521d6e3 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -17,6 +17,7 @@ import ( actions_model "code.gitea.io/gitea/models/actions" "code.gitea.io/gitea/models/db" + repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/modules/actions" "code.gitea.io/gitea/modules/base" @@ -572,3 +573,43 @@ func ArtifactsDownloadView(ctx *context_module.Context) { } } } + +func DisableWorkflowFile(ctx *context_module.Context) { + disableOrEnableWorkflowFile(false, ctx) +} + +func EnableWorkflowFile(ctx *context_module.Context) { + disableOrEnableWorkflowFile(true, ctx) +} + +func disableOrEnableWorkflowFile(isEnable bool, ctx *context_module.Context) { + workflow := ctx.FormString("workflow") + if len(workflow) == 0 { + ctx.ServerError("workflow", nil) + return + } + + cfgUnit := ctx.Repo.Repository.MustGetUnit(ctx, unit.TypeActions) + cfg := cfgUnit.ActionsConfig() + + if isEnable { + cfg.EnableWrokflow(workflow) + } else { + cfg.DisableWrokflow(workflow) + } + + if err := repo_model.UpdateRepoUnit(cfgUnit); err != nil { + ctx.ServerError("UpdateRepoUnit", err) + return + } + + if isEnable { + ctx.Flash.Success(ctx.Tr("actions.workflow.enable_success", workflow)) + } else { + ctx.Flash.Success(ctx.Tr("actions.workflow.disable_success", workflow)) + } + + redirectURL := fmt.Sprintf("%s/actions?workflow=%s&actor=%s&status=%s", ctx.Repo.RepoLink, workflow, + ctx.FormString("actor"), ctx.FormString("status")) + ctx.Redirect(redirectURL) +} diff --git a/routers/web/web.go b/routers/web/web.go index 2c2309e827f82..e73a9f2a48417 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -1200,6 +1200,8 @@ func registerRoutes(m *web.Route) { m.Group("/actions", func() { m.Get("", actions.List) + m.Post("/disable", reqRepoAdmin, actions.DisableWorkflowFile) + m.Post("/enable", reqRepoAdmin, actions.EnableWorkflowFile) m.Group("/runs/{run}", func() { m.Combo(""). diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index 0cc2d17f4ef44..75c99ff19cd2b 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -150,7 +150,14 @@ func notify(ctx context.Context, input *notifyInput) error { if len(workflows) == 0 { log.Trace("repo %s with commit %s couldn't find workflows", input.Repo.RepoPath(), commit.ID) } else { + actionsConfig := input.Repo.MustGetUnit(ctx, unit_model.TypeActions).ActionsConfig() + for _, wf := range workflows { + if actionsConfig.IsWorkflowDisabled(wf.EntryName) { + log.Trace("repo %s has disable workflows %s", input.Repo.RepoPath(), wf.EntryName) + continue + } + if wf.TriggerEvent != actions_module.GithubEventPullRequestTarget { detectedWorkflows = append(detectedWorkflows, wf) } diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl index f4f0aa9d6d957..3800ffbbc7309 100644 --- a/templates/repo/actions/list.tmpl +++ b/templates/repo/actions/list.tmpl @@ -13,6 +13,10 @@ {{svg "octicon-alert" 16 "text red"}} {{end}} + + {{if $.ActionsConfig.IsWorkflowDisabled .Entry.Name}} +
{{$.locale.Tr "disabled"}}
+ {{end}} {{end}} @@ -57,6 +61,14 @@ {{end}} + + {{if .AllowDisableOrEnableWorkflow}} +
+ {{.CsrfTokenHtml}} + +
+ {{end}} + {{template "repo/actions/runs_list" .}} From 5951e46b19df57ccc7f7cb34f963917f74b07a38 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Thu, 10 Aug 2023 22:52:23 +0800 Subject: [PATCH 02/17] Apply suggestions from code review Co-authored-by: Jason Song --- models/repo/repo_unit.go | 8 +------- routers/web/repo/actions/view.go | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/models/repo/repo_unit.go b/models/repo/repo_unit.go index 97b9697080c1d..db045bbd07f6f 100644 --- a/models/repo/repo_unit.go +++ b/models/repo/repo_unit.go @@ -177,13 +177,7 @@ func (cfg *ActionsConfig) EnableWrokflow(file string) { } func (cfg *ActionsConfig) ToString() string { - result := "" - - for _, workflow := range cfg.DisabledWorkflows { - result += workflow + "," - } - - return strings.TrimSuffix(result, ",") + return strings.Join(cfg.DisabledWorkflows, ",") } func (cfg *ActionsConfig) IsWorkflowDisabled(file string) bool { diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index 2f452e521d6e3..919a7ec64ee75 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -582,7 +582,7 @@ func EnableWorkflowFile(ctx *context_module.Context) { disableOrEnableWorkflowFile(true, ctx) } -func disableOrEnableWorkflowFile(isEnable bool, ctx *context_module.Context) { +func disableOrEnableWorkflowFile(ctx *context_module.Context, isEnable bool) { workflow := ctx.FormString("workflow") if len(workflow) == 0 { ctx.ServerError("workflow", nil) From 19f0a9d9a71d36c27346d8dd58d6801506439f01 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Thu, 10 Aug 2023 15:00:53 +0000 Subject: [PATCH 03/17] fix build Signed-off-by: a1012112796 <1012112796@qq.com> --- routers/web/repo/actions/view.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index 919a7ec64ee75..a82464198c28e 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -575,11 +575,11 @@ func ArtifactsDownloadView(ctx *context_module.Context) { } func DisableWorkflowFile(ctx *context_module.Context) { - disableOrEnableWorkflowFile(false, ctx) + disableOrEnableWorkflowFile(ctx, false) } func EnableWorkflowFile(ctx *context_module.Context) { - disableOrEnableWorkflowFile(true, ctx) + disableOrEnableWorkflowFile(ctx, true) } func disableOrEnableWorkflowFile(ctx *context_module.Context, isEnable bool) { From c176633c50cb7b4ddebcad121c115b9fd601e062 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 11 Aug 2023 07:25:24 +0200 Subject: [PATCH 04/17] vertically center button --- templates/repo/actions/list.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl index b6ab126b03acf..351398a68e973 100644 --- a/templates/repo/actions/list.tmpl +++ b/templates/repo/actions/list.tmpl @@ -22,7 +22,7 @@
- diff --git a/web_src/js/features/repo-actions.js b/web_src/js/features/repo-actions.js new file mode 100644 index 0000000000000..c48cb153e1cc8 --- /dev/null +++ b/web_src/js/features/repo-actions.js @@ -0,0 +1,8 @@ +export function initRepoActionList() { + const disableWorkflowBtn = document.getElementById('disable-workflow-btn'); + if (disableWorkflowBtn) { + disableWorkflowBtn.addEventListener('click', async () => { + document.getElementById('disable-workflow-form').submit(); + }); + } +} diff --git a/web_src/js/index.js b/web_src/js/index.js index 8bd219bbe1576..e0ef497da27c8 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -58,6 +58,7 @@ import {initSshKeyFormParser} from './features/sshkey-helper.js'; import {initUserSettings} from './features/user-settings.js'; import {initRepoArchiveLinks} from './features/repo-common.js'; import {initRepoMigrationStatusChecker} from './features/repo-migrate.js'; +import {initRepoActionList} from './features/repo-actions.js'; import { initRepoSettingGitHook, initRepoSettingsCollaboration, @@ -166,6 +167,7 @@ onDomReady(() => { initRepoSettingsCollaboration(); initRepoTemplateSearch(); initRepoTopicBar(); + initRepoActionList(); initRepoWikiForm(); initRepository(); initRepositoryActionView(); From 75221474b4d58f626a91a064f8c5376d2a5e6e5e Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 11 Aug 2023 08:09:42 +0200 Subject: [PATCH 06/17] classname cleanup --- templates/repo/actions/list.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl index 488c043f6ab30..24c94377dd249 100644 --- a/templates/repo/actions/list.tmpl +++ b/templates/repo/actions/list.tmpl @@ -70,7 +70,7 @@
-
+ {{.CsrfTokenHtml}}
{{end}} From 9538f45311633a44cd241ffa5d98cbc4cd574f86 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 11 Aug 2023 08:28:42 +0200 Subject: [PATCH 07/17] fix template lint --- templates/repo/actions/list.tmpl | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl index 24c94377dd249..af97ecb59f975 100644 --- a/templates/repo/actions/list.tmpl +++ b/templates/repo/actions/list.tmpl @@ -67,7 +67,6 @@ {{svg "octicon-kebab-horizontal"}}
From 665f1c0abfad51cb68a3edea41b2c74ec123c959 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Fri, 11 Aug 2023 20:55:20 +0800 Subject: [PATCH 08/17] Apply suggestions from code review Co-authored-by: silverwind --- options/locale/locale_en-US.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index c1a5d91662762..f689e1a5c499d 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -3492,9 +3492,9 @@ runs.no_results = No results matched. runs.no_runs = The workflow has no runs yet. workflow.disable = Disable Workflow -workflow.disable_success = The workflow '%s' has been disabled successfully! +workflow.disable_success = Workflow '%s' disabled successfully. workflow.enable = Enable Workflow -workflow.enable_success = The workflow '%s' has been enabled successfully! +workflow.enable_success = Workflow '%s' enabled successfully. need_approval_desc = Need approval to run workflows for fork pull request. From 00df673ac9ca7d900d1aa8043287e46af83d08ec Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 11 Aug 2023 14:59:05 +0200 Subject: [PATCH 09/17] use a instead of div for menu item --- templates/repo/actions/list.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl index af97ecb59f975..d7cf555d1f2ea 100644 --- a/templates/repo/actions/list.tmpl +++ b/templates/repo/actions/list.tmpl @@ -66,7 +66,7 @@ From 1fd8b6d9da98884af5227048b28528b1b380c362 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 11 Aug 2023 15:00:43 +0200 Subject: [PATCH 10/17] remove unused translations --- options/locale/locale_en-US.ini | 3 --- 1 file changed, 3 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index f689e1a5c499d..85541529ac787 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -95,9 +95,6 @@ enabled = Enabled disabled = Disabled locked = Locked -enable = Enable -disable = Disable - copy = Copy copy_url = Copy URL copy_content = Copy content From 3e758a8e1840d8b518613091578511d4c6564696 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Fri, 11 Aug 2023 12:59:35 +0000 Subject: [PATCH 11/17] fix typo Signed-off-by: a1012112796 <1012112796@qq.com> --- models/repo/repo_unit.go | 4 ++-- models/repo/repo_unit_test.go | 14 +++++++------- routers/web/repo/actions/view.go | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/models/repo/repo_unit.go b/models/repo/repo_unit.go index db045bbd07f6f..62e76583c1c36 100644 --- a/models/repo/repo_unit.go +++ b/models/repo/repo_unit.go @@ -167,7 +167,7 @@ type ActionsConfig struct { DisabledWorkflows []string } -func (cfg *ActionsConfig) EnableWrokflow(file string) { +func (cfg *ActionsConfig) EnableWorkflow(file string) { for i, workflow := range cfg.DisabledWorkflows { if file == workflow { cfg.DisabledWorkflows = append(cfg.DisabledWorkflows[:i], cfg.DisabledWorkflows[i+1:]...) @@ -190,7 +190,7 @@ func (cfg *ActionsConfig) IsWorkflowDisabled(file string) bool { return false } -func (cfg *ActionsConfig) DisableWrokflow(file string) { +func (cfg *ActionsConfig) DisableWorkflow(file string) { for _, workflow := range cfg.DisabledWorkflows { if file == workflow { return diff --git a/models/repo/repo_unit_test.go b/models/repo/repo_unit_test.go index 4576893815a8b..a760594013859 100644 --- a/models/repo/repo_unit_test.go +++ b/models/repo/repo_unit_test.go @@ -11,20 +11,20 @@ import ( func TestActionsConfig(t *testing.T) { cfg := &ActionsConfig{} - cfg.DisableWrokflow("test1.yaml") + cfg.DisableWorkflow("test1.yaml") assert.EqualValues(t, []string{"test1.yaml"}, cfg.DisabledWorkflows) - cfg.DisableWrokflow("test1.yaml") + cfg.DisableWorkflow("test1.yaml") assert.EqualValues(t, []string{"test1.yaml"}, cfg.DisabledWorkflows) - cfg.EnableWrokflow("test1.yaml") + cfg.EnableWorkflow("test1.yaml") assert.EqualValues(t, []string{}, cfg.DisabledWorkflows) - cfg.EnableWrokflow("test1.yaml") + cfg.EnableWorkflow("test1.yaml") assert.EqualValues(t, []string{}, cfg.DisabledWorkflows) - cfg.DisableWrokflow("test1.yaml") - cfg.DisableWrokflow("test2.yaml") - cfg.DisableWrokflow("test3.yaml") + cfg.DisableWorkflow("test1.yaml") + cfg.DisableWorkflow("test2.yaml") + cfg.DisableWorkflow("test3.yaml") assert.EqualValues(t, "test1.yaml,test2.yaml,test3.yaml", cfg.ToString()) } diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index a82464198c28e..76dfed71ccf2a 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -593,9 +593,9 @@ func disableOrEnableWorkflowFile(ctx *context_module.Context, isEnable bool) { cfg := cfgUnit.ActionsConfig() if isEnable { - cfg.EnableWrokflow(workflow) + cfg.EnableWorkflow(workflow) } else { - cfg.DisableWrokflow(workflow) + cfg.DisableWorkflow(workflow) } if err := repo_model.UpdateRepoUnit(cfgUnit); err != nil { From f0cfff2daf33a75f071f8f0c737faecc5ec428a1 Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 11 Aug 2023 15:02:08 +0200 Subject: [PATCH 12/17] remove useless async --- web_src/js/features/repo-actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/js/features/repo-actions.js b/web_src/js/features/repo-actions.js index c48cb153e1cc8..225aa722edbcd 100644 --- a/web_src/js/features/repo-actions.js +++ b/web_src/js/features/repo-actions.js @@ -1,7 +1,7 @@ export function initRepoActionList() { const disableWorkflowBtn = document.getElementById('disable-workflow-btn'); if (disableWorkflowBtn) { - disableWorkflowBtn.addEventListener('click', async () => { + disableWorkflowBtn.addEventListener('click', () => { document.getElementById('disable-workflow-form').submit(); }); } From b2a5c22c88be5de5675a9460375ac520f648b87b Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 12 Aug 2023 12:10:42 +0200 Subject: [PATCH 13/17] remove unnecessary button classes --- templates/repo/actions/list.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl index d7cf555d1f2ea..da883bc028952 100644 --- a/templates/repo/actions/list.tmpl +++ b/templates/repo/actions/list.tmpl @@ -63,7 +63,7 @@ {{if .AllowDisableOrEnableWorkflow}} - - - {{.CsrfTokenHtml}} - {{end}} {{template "repo/actions/runs_list" .}} diff --git a/web_src/js/features/repo-actions.js b/web_src/js/features/repo-actions.js deleted file mode 100644 index 225aa722edbcd..0000000000000 --- a/web_src/js/features/repo-actions.js +++ /dev/null @@ -1,8 +0,0 @@ -export function initRepoActionList() { - const disableWorkflowBtn = document.getElementById('disable-workflow-btn'); - if (disableWorkflowBtn) { - disableWorkflowBtn.addEventListener('click', () => { - document.getElementById('disable-workflow-form').submit(); - }); - } -} diff --git a/web_src/js/index.js b/web_src/js/index.js index e0ef497da27c8..8bd219bbe1576 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -58,7 +58,6 @@ import {initSshKeyFormParser} from './features/sshkey-helper.js'; import {initUserSettings} from './features/user-settings.js'; import {initRepoArchiveLinks} from './features/repo-common.js'; import {initRepoMigrationStatusChecker} from './features/repo-migrate.js'; -import {initRepoActionList} from './features/repo-actions.js'; import { initRepoSettingGitHook, initRepoSettingsCollaboration, @@ -167,7 +166,6 @@ onDomReady(() => { initRepoSettingsCollaboration(); initRepoTemplateSearch(); initRepoTopicBar(); - initRepoActionList(); initRepoWikiForm(); initRepository(); initRepositoryActionView(); From 0ac99a21422264451df4375e1e9f4b529cdc5989 Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 14 Aug 2023 14:45:38 +0200 Subject: [PATCH 16/17] use gap for item spacing in secondary menu, remove clearfix --- web_src/css/base.css | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/web_src/css/base.css b/web_src/css/base.css index 10ac580ed2db0..9b191bb7ad199 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -653,9 +653,16 @@ a.label, color: var(--color-text); } +/* replace item margin on secondary menu items with gap and remove both the + negative margins on the menu as well as margin on the items */ .ui.secondary.menu { margin-left: 0; margin-right: 0; + gap: .35714286em; +} +.ui.secondary.menu .item { + margin-left : 0; + margin-right : 0; } .ui.secondary.menu .dropdown.item:hover, @@ -675,6 +682,11 @@ a.label, padding-right: 0.85714286em; } +/* remove the menu clearfix so that it won't add undesired gaps when using "gap" */ +.ui.menu::after { + content: normal; +} + .ui.menu .dropdown.item .menu { background: var(--color-body); } From 6abdd1ac03bb09574aca5dffe8dfe98112d1310b Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 14 Aug 2023 14:50:56 +0200 Subject: [PATCH 17/17] fix whitespace --- web_src/css/base.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_src/css/base.css b/web_src/css/base.css index 9b191bb7ad199..eca08fa1b910a 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -661,8 +661,8 @@ a.label, gap: .35714286em; } .ui.secondary.menu .item { - margin-left : 0; - margin-right : 0; + margin-left: 0; + margin-right: 0; } .ui.secondary.menu .dropdown.item:hover,