-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Check disabled workflow when rerun jobs #26535
Check disabled workflow when rerun jobs #26535
Conversation
Co-authored-by: silverwind <[email protected]>
It seems that we have no global fetch post function, maybe we can reuse the code here as a global one. gitea/web_src/js/features/common-global.js Lines 119 to 161 in c6b92c8
|
Yes, I would like to write some fetch wrapper functions eventually which automatically handles CSRF and maybe even redirects etc. |
Just improve the |
We need a generic fetch wrapper in any case. |
I tried to add a general
|
I will try to improve it |
f3e47fc
to
25d1a06
Compare
Made some improvements to "link-action", you can test it on the page http://localhost:3000/devtest/fetch-action I haven't tested the Vue code changes, feel free to ask if there is any problem. |
fetchActionDoRedirect(redirect); | ||
} else { | ||
window.location.reload(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is old code, but shouldn't we use 302 status code and then check resp.redirected and read location from resp.url? I think this is something for a future generic fetch handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope IMO.
Fetch's redirect
could only have 3 behaviors: follow, error, manual.
follow
is the default behavior, it doesn't distinguish 200/302, etc, error
just stops redirection.
If you would like to use "redirect": "manual"
.... IIRC it doesn't work well (the details are too complex)
You could take a try, if it would succeed, feel free to propose a new solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that was implying manual
option, but I guess it'll be hard to distinguish a "content redirect" from an "ui redirect", so I guess I'm fine with leaving it unchanged.
@@ -40,7 +48,7 @@ function initGlobalErrorHandler() { | |||
processWindowErrorEvent(e); | |||
} | |||
// then, change _globalHandlerErrors to an object with push method, to process further error events directly | |||
window._globalHandlerErrors = {'push': (e) => processWindowErrorEvent(e)}; | |||
window._globalHandlerErrors = {_inited: true, push: (e) => processWindowErrorEvent(e)}; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wxiaoguang could you port the Proxy implementation from #25940 here instead of extending this hack further? I think #25940 is not going to land anytime soon, so it's a good extract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I have different opinion. I think this "array" is a right approach. The reasons are:
- The bug you met is not caused by the array, but by duplicate-init. I have added "inited" check in this PR, so you won't see any new problem.
- Array is also widely used by big company products, for example, Google Analytics also uses
ga.push()
, the same method. - Using an object with "push" method is light than using a proxy object, and it doesn't need too much tricky code in the "set" method.
So, I would always prefer this approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does your hack even run in JS strict mode? Try adding "use strict";
to the file 😆.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not hack IMO, it strictly follows JS standard. And, why not run? I don't see any problem.
<script>
window._testGlobal = [];
window._testGlobal.push('foo');
</script>
<script src="{{AssetUrlPrefix}}/test.js"></script>
"use strict";
function test() {
for (const e of window._testGlobal || []) {
console.log(`test (pre): ${e}`);
}
window._testGlobal = {_inited: true, push: (e) => console.log(`test (after): ${e}`)};
}
test();
window._testGlobal.push('bar');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you are right and the problem I've been seeing may be because of that missing init. Still I personally prefer the Proxy method.
BTW, I would like our code to run in strict mode, but don't feel like littering every file with a "use strict". Maybe there are solutions for webpack to automatically inject it into every chunk like https://babeljs.io/docs/babel-plugin-transform-strict-mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to evanw/esbuild#422 (comment) we could use the esbuild banner feature for it.
Let's merge it and do more improvements in following PRs (if necessary) |
* upstream/main: Improve show role (go-gitea#26621) Improve some flex layouts (go-gitea#26649) feat: implement organization secret creation API (go-gitea#26566) Check disabled workflow when rerun jobs (go-gitea#26535)
In GitHub, we can not rerun jobs if the workflow is disabled:
After: