Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wip require action feature fail post #30067

Conversation

AvengerMoJo
Copy link

Still a WIP branch and try to implement the #26666

In the earlier commit main...AvengerMoJo:gitea:wip_require_action_feature
I create a table to allow repo workflow to enable as global (org) visible action.
However when I create a form to POST call to try creating the table to keep track of all the require action. Either the repo/setting/actions/require_action/add or repo/setting/actions/require_action in routers/web/web.go able to work. I get 405 or bad request.
Need some tips to connect the bot for my POST request,
web/repo/setting/actions/require_action interface
from templates/shared/actions/require_action_list.tmpl click the add button calling
routes/web/repo/setting/require_action
RequireActionsCreate call shared action
then
from service/actions/require_action
CreateRequireAction call InsertRequireAction in
the model/actions/require_action

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 25, 2024
@pull-request-size pull-request-size bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Mar 25, 2024
@github-actions github-actions bot added modifies/translation modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files labels Mar 25, 2024
@AvengerMoJo AvengerMoJo force-pushed the wip_require_action_feature_fail_post branch from 2eae9a4 to 1136088 Compare April 5, 2024 15:10
@pull-request-size pull-request-size bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 5, 2024
@AvengerMoJo
Copy link
Author

2024/04/06 14:19:45 ...eb/routing/logger.go:102:func1() [I] router: completed POST /org/SUSE/settings/actions/require_action/add for [::1]:62841, 400 Bad Request in 9.4ms @ setting/require_action.go:73(setting.RequireActionCreate)

@pull-request-size pull-request-size bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 8, 2024
@pull-request-size pull-request-size bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Apr 8, 2024
@silverwind
Copy link
Member

Please fix all the lint errors and run make fmt :)

@lunny lunny added the topic/gitea-actions related to the actions of Gitea label Apr 9, 2024
@AvengerMoJo AvengerMoJo force-pushed the wip_require_action_feature_fail_post branch 2 times, most recently from e88e9ad to b7ef3f2 Compare April 11, 2024 05:20
@AvengerMoJo AvengerMoJo force-pushed the wip_require_action_feature_fail_post branch from 6cfbad2 to c10d144 Compare April 11, 2024 05:40
Signed-off-by: Alex Lau(AvengerMoJo) <[email protected]>
@AvengerMoJo
Copy link
Author

@silverwind I fixed up the fmt and added the delete function. So currently you can enable a workflow in the repo to the org global level. Then you can add it into the RequireAction table in the Org->Setting->Actions->RequireAction.
However, I am still missing how to assign them back to all the repo and schedule the runner then the action happen.

require_action.workflow = Workflow Filename
require_action.link = Link
require_action.remove = Remove
require_action.none = No Require Actions Available.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
require_action.none = No Require Actions Available.
require_action.none = No Required Actions Available.

});
});
});
</script>
Copy link
Member

@silverwind silverwind Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script should be in web_src/js and if necessary detect with a fast selector like document.getElementById('add-require-actions-modal') whether this modal is present, and if not abort.

Copy link
Author

@AvengerMoJo AvengerMoJo Apr 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@silverwind does the following make sense? I'm not sure it should be in features or components.
I am also wondering there is any default function allows me to disable and enable the rest of the input based on the selected radio button like what I am trying to do.

Copy link
Member

@silverwind silverwind Apr 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

features is fine, we pile everything into it currently.

Regarding the other question: I'm not sure but please check how it's done on the repo settings page. There is some mechanism there that enables/disables a bunch of fields when radio buttons are clicked.

@AvengerMoJo
Copy link
Author

@silverwind I may need a bit help with the way global require action implementation after being enable .
e.g routers/web/repo/actions/actions.go in List
Should I implement the global actions.ListGlobalWorkflows like the actions.ListWorkflows? ( I have a hard time including the global data model in the actions/workflow.go )
Or should i follow the runners using db.Find[actions_models.RequireAction]

@AvengerMoJo
Copy link
Author

main...AvengerMoJo:gitea:wip_require_action

@silverwind if you could try the above wip branch has a implementation of the RequireAction. The usage and screen capture of steps are located #26666.
Thanks

@AvengerMoJo
Copy link
Author

#31869 replace this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code modifies/js modifies/migrations modifies/templates This PR modifies the template files modifies/translation size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. topic/gitea-actions related to the actions of Gitea
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants