aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/utils
Commit message (Collapse)AuthorAgeFilesLines
* Enable Typescript `strictFunctionTypes` (#32911)silverwind2024-12-221-1/+2
| | | | | | | | 1. Enable [strictFunctionTypes](https://www.typescriptlang.org/tsconfig/#strictFunctionTypes) 2. Introduce `DOMEvent` helper type which sets `e.target`. Surely not totally correct with that `Partial` but seems to work. 3. Various type-related refactors, change objects in `eventsource.sharedworker.ts` to `Map`.
* Rearrange Clone Panel (#31142)Blender Defender2024-12-112-1/+33
| | | | | | | | | | | | | Rearrange the clone panel to use less horizontal space. The following changes have been made to achieve this: - Moved everything into the dropdown menu - Moved the HTTPS/SSH Switch to a separate line - Moved the "Clone in VS Code"-Button up and added a divider - Named the dropdown button "Code", added appropriate icon --------- Co-authored-by: techknowlogick <techknowlogick@gitea.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Change typescript `module` to `nodenext` (#32757)silverwind2024-12-101-1/+1
| | | | | | | | | | | | | | | | | Typescript 5.7 changed semantics around JSON imports and `nodenext` is now [treated differently](https://devblogs.microsoft.com/typescript/announcing-typescript-5-7-beta/#validated-json-imports-in---module-nodenext) than `node16` for JSON imports and it requires the import attribute, so change the value to that and add the attribute to eliminate this typescript error. [`moduleResolution`](https://www.typescriptlang.org/tsconfig/#moduleResolution) is treated as an alias when `module` is `nodenext`, so we don't need to specify it. Also see https://github.com/microsoft/TypeScript/issues/60589. It appears the next Typescript release will fix this for `node16`, but I guess it'll still be good to switch to `nodenext`.
* Fix typescript errors in Vue files, fix regression in "Recent Commits" chart ↵silverwind2024-12-081-1/+5
| | | | | | | | | | | (#32649) - Fix all typescript errors in `.vue` files - Fix regression from https://github.com/go-gitea/gitea/pull/32329 where "Recent Commits" chart would not render. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Make frontend unit test code could know it is in testing (#32656)wxiaoguang2024-11-282-3/+10
| | | See the comment of isInFrontendUnitTest
* Refactor some frontend problems (#32646)wxiaoguang2024-11-261-1/+1
| | | | | | | | | | | 1. correct the modal usage on "admin email list" page (then `web_src/js/features/admin/emails.ts` is removed) 2. use `addDelegatedEventListener` instead of `jQuery().on` 3. more jQuery related changes and remove jQuery from `web_src/js/features/common-button.ts` 4. improve `confirmModal` to make it support header, and remove incorrect double-escaping 5. fix more typescript related types 6. fine tune devtest pages and add more tests
* Bypass vitest bug (#32647)wxiaoguang2024-11-262-1/+12
|
* Fixed Issue of Review Menu Shown Behind (#32631)Kerwin Bryant2024-11-261-2/+2
| | | | | | | Fixed #31144 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix PR diff review form submit (#32596)wxiaoguang2024-11-212-3/+19
| | | | Fix #31622, there is a longstanding bug in #19612, it doesn't handle submit event, correctly.
* Fix some typescript issues (#32586)silverwind2024-11-211-1/+1
| | | Fixes around 30 or so typescript errors. No runtime changes.
* Refactor sidebar label selector (#32460)wxiaoguang2024-11-101-5/+5
| | | Introduce `issueSidebarLabelsData` to handle all sidebar labels related data.
* Refactor language menu and dom utils (#32450)wxiaoguang2024-11-081-10/+13
| | | | | 1. Make `queryElem*` functions could correctly handle TS types 2. Remove some legacy jQuery $ calls (introduce fomanticQuery for Fomantic UI only) 3. Fix some TS typing problems
* Correctly query the primary button in a form (#32438)wxiaoguang2024-11-072-3/+19
| | | | | | | | | | | | | | | | | The "primary button" is used at many places, but sometimes they might conflict (due to button switch, hidden panel, dropdown menu, etc). Sometimes we could add a special CSS class for the buttons, but sometimes not (see the comment of QuickSubmit) This PR introduces `querySingleVisibleElem` to help to get the correct primary button (the only visible one), and prevent from querying the wrong buttons. Fix #32437 --------- Co-authored-by: silverwind <me@silverwind.io>
* Fix a number of typescript issues (#32308)silverwind2024-10-311-1/+1
| | | | | | | | | | | | | | - Prefer [window.location.assign](https://developer.mozilla.org/en-US/docs/Web/API/Location/assign) over assigning to [window.location](https://developer.mozilla.org/en-US/docs/Web/API/Window/location) which typescript does not like. This works in all browsers including PaleMoon. - Fix all typescript issues in `web_src/js/webcomponents`, no behaviour changes. - ~~Workaround bug in `@typescript-eslint/no-unnecessary-type-assertion` rule.~~ - Omit vendored file from type checks. - `tsc` error count is reduce by 53 with these changes.
* Update JS and PY dependencies (#32388)silverwind2024-10-311-2/+2
| | | | | | | | | | | | | - Update all JS dependencies excluding stylelint (because of https://github.com/AndyOGo/stylelint-declaration-strict-value/issues/379). - Update all PY dependencies. - Replace `eslint-plugin-deprecation` with `@typescript-eslint/no-deprecated` rule. - Enabled `unicorn/prefer-math-min-max` and autofixed issues. - Tested all dependencies. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix suggestions for issues (#32380)wxiaoguang2024-10-303-11/+13
|
* Suggestions for issues (#32327)Anbraten2024-10-291-3/+16
| | | closes #16872
* Migrate vue components to setup (#32329)Anbraten2024-10-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Migrated a handful Vue components to the `setup` syntax using composition api as it has better Typescript support and is becoming the new default in the Vue ecosystem. - [x] ActionRunStatus.vue - [x] ActivityHeatmap.vue - [x] ContextPopup.vue - [x] DiffFileList.vue - [x] DiffFileTree.vue - [x] DiffFileTreeItem.vue - [x] PullRequestMergeForm.vue - [x] RepoActivityTopAuthors.vue - [x] RepoCodeFrequency.vue - [x] RepoRecentCommits.vue - [x] ScopedAccessTokenSelector.vue Left some larger components untouched for now to not go to crazy in this single PR: - [ ] DiffCommitSelector.vue - [ ] RepoActionView.vue - [ ] RepoContributors.vue - [ ] DashboardRepoList.vue - [ ] RepoBranchTagSelector.vue
* Fix a number of Typescript issues (#31877)silverwind2024-08-286-25/+41
| | | | Typescript error count is reduced from 633 to 540 with this. No runtime changes except in test code.
* Add types to various low-level functions (#31781)silverwind2024-08-102-36/+50
| | | | | | | | Adds types to various low-level modules. All changes are type-only, no runtime changes. `tsc` now reports 38 less errors. One problem was that `@types/sortablejs` does not accept promise return in its functions which triggered the linter, so I disabled the rules on those line.
* Fix createElementFromAttrs bug (#31751)wxiaoguang2024-08-012-2/+4
| | | | | The "false" value was not handled correctly, it would cause bugs in the future (fortunately, this behavior is not used in code yet).
* Convert frontend code to typescript (#31559)silverwind2024-07-0712-7/+7
| | | | | | | | | | | None of the frontend js/ts files was touched besides these two commands (edit: no longer true, I touched one file in https://github.com/go-gitea/gitea/pull/31559/commits/61105d0618e285d97e95044bfb64415f364a4526 because of a deprecation that was not showing before the rename). `tsc` currently reports 778 errors, so I have disabled it in CI as planned. Everything appears to work fine.
* Add typescript guideline and typescript-specific eslint plugins and fix ↵silverwind2024-07-031-1/+1
| | | | | | | | issues (#31521) 1. Add some general guidelines how to write our typescript code 2. Add `@typescript-eslint/eslint-plugin`, general typescript rules 3. Add `eslint-plugin-deprecation` to detect deprecated code 4. Fix all new lint issues that came up
* Make toast support preventDuplicates (#31501)wxiaoguang2024-06-271-0/+11
| | | | | | | | | | make preventDuplicates default to true, users get a clear UI feedback and know that "a new message appears". Fixes: https://github.com/go-gitea/gitea/issues/26651 --------- Co-authored-by: silverwind <me@silverwind.io>
* Improve attachment upload methods (#30513)Tyrone Yeh2024-06-273-15/+5
| | | | | | | | | | | | * Use dropzone to handle file uploading for all cases, including pasting and dragging * Merge duplicate code, use consistent behavior for link generating Close #20130 --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor dropzone (#31482)wxiaoguang2024-06-272-1/+26
| | | Refactor the legacy code and remove some jQuery calls.
* Fix and clean up `ConfirmModal` (#31283)silverwind2024-06-072-0/+12
| | | | | | | | | | | | | | | | Bug: orange button color was removed in https://github.com/go-gitea/gitea/pull/30475, replaced with red Bug: translation text was not html-escaped Refactor: Replaced as much jQuery as possible, added useful `createElementFromHTML` Refactor: Remove colors checks that don't exist on `.link-action` <img width="381" alt="image" src="https://github.com/go-gitea/gitea/assets/115237/5900bf6a-8a86-4a86-b368-0559cbfea66e"> --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
* Have time.js use UTC-related getters/setters (#30857)Kemal Zebari2024-05-061-14/+19
| | | | | | | | | | | | | | | | | | | | | Before this patch, we were using `Date` getter/setter methods that worked with local time to get a list of Sundays that are in the range of some start date and end date. The problem with this was that the Sundays are in Unix epoch time and when we changed the "startDate" argument that was passed to make sure it is on a Sunday, this change would be reflected when we convert it to Unix epoch time. More specifically, I observed that we may get different Unix epochs depending on your timezone when the returned list should rather be timezone-agnostic. This led to issues in US timezones that caused the contributor, code frequency, and recent commit charts to not show any chart data. This fix resolves this by using getter/setter methods that work with UTC since it isn't dependent on timezones. Fixes #30851. --------- Co-authored-by: Sam Fisher <fisher@3echelon.local>
* Refactor and fix archive link bug (#30535)wxiaoguang2024-04-191-0/+4
| | | | | | | | Regression of #29920 Fixes: #30569 Also this is a rewriting to eliminate the remaining jQuery usages from code. Co-authored-by: Giteabot <teabot@gitea.io>
* Fix and rewrite contrast color calculation, fix project-related bugs (#30237)silverwind2024-04-072-35/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | 1. The previous color contrast calculation function was incorrect at least for the `#84b6eb` where it output low-contrast white instead of black. I've rewritten these functions now to accept hex colors and to match GitHub's calculation and to output pure white/black for maximum contrast. Before and after: <img width="94" alt="Screenshot 2024-04-02 at 01 53 46" src="https://github.com/go-gitea/gitea/assets/115237/00b39e15-a377-4458-95cf-ceec74b78228"><img width="90" alt="Screenshot 2024-04-02 at 01 51 30" src="https://github.com/go-gitea/gitea/assets/115237/1677067a-8d8f-47eb-82c0-76330deeb775"> 2. Fix project-related issues: - Expose the new `ContrastColor` function as template helper and use it for project cards, replacing the previous JS solution which eliminates a flash of wrong color on page load. - Fix a bug where if editing a project title, the counter would get lost. - Move `rgbToHex` function to color utils. @HesterG fyi --------- Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Giteabot <teabot@gitea.io>
* Remove most jQuery function calls from the repository topic box (#30191)Yarden Shoham2024-03-311-2/+16
| | | | | | | | | Remove most jQuery function calls --------- Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Remove jQuery class from the diff view (#30176)Yarden Shoham2024-03-291-1/+1
| | | | | | | | | - Switched from jQuery class functions to plain JavaScript `classList` - Tested the diff view functionality and it works as before --------- Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: silverwind <me@silverwind.io>
* Migrate `gt-hidden` to `tw-hidden` (#30046)silverwind2024-03-241-4/+4
| | | | | | | | | | | | We have to define this one in helpers.css because tailwind only generates a single class but certain things rely on this being double-class. Command ran: ```sh perl -p -i -e 's#gt-hidden#tw-hidden#g' web_src/js/**/* templates/**/* models/**/* web_src/css/**/* --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Enforce trailing comma in JS on multiline (#30002)silverwind2024-03-221-1/+1
| | | | | | | | To keep blame info accurate and to avoid [changes like this](https://github.com/go-gitea/gitea/pull/29977/files#diff-c3422631a14edbe1e508c4b22f0c718db318be08a6e889427802f9b6165d88d6R359), it's good to always have a trailing comma, so let's enforce it in JS. This rule is completely automatically fixable with `make lint-js-fix` and that's what I did here.
* Support pasting URLs over markdown text (#29566)silverwind2024-03-083-1/+56
| | | | | | | | | | | | | | | | | Support pasting URLs over selection text in the textarea editor. Does not work in EasyMDE and I don't intend to support it. Image paste works as usual in both Textarea and EasyMDE. The new `replaceTextareaSelection` function changes textarea content via [`insertText`](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand#using_inserttext) command, which preserves history, e.g. `CTRL-Z` works and is also demostrated below. We should later refactor the image paste code to use the same function because it currently destroys history. Overriding the formatting via `Shift` key is supported as well, e.g. `Ctrl+Shift+V` will insert the URL as-is, like on GitHub. ![urlpaste](https://github.com/go-gitea/gitea/assets/115237/522b1023-6797-401c-9e4a-498570adfc88)
* Set user's 24h preference from their current OS locale (#29651)silverwind2024-03-081-0/+21
| | | | | | | | | | | | | | Fixes: https://github.com/go-gitea/gitea/issues/28371 Fixed by using a JS solution that formats according to `lang`, but alters the 24h format setting as per user's locale. This will work for all tooltips: <img width="243" alt="Screenshot 2024-03-07 at 23 03 35" src="https://github.com/go-gitea/gitea/assets/115237/6d16c71c-6786-4eda-8cdc-50ec68ba62c6"> <img width="250" alt="Screenshot 2024-03-07 at 23 03 17" src="https://github.com/go-gitea/gitea/assets/115237/4e26bbb7-12df-4b81-bd37-14705e87e8f7"> <img width="310" alt="Screenshot 2024-03-07 at 23 14 34" src="https://github.com/go-gitea/gitea/assets/115237/1ef599f0-6401-4e19-b1da-59cdfc09b0f6"> I think there is only one other place in the UI where we render such absolute dates, which is in the actions view and which I've also fixed: <img width="275" alt="Screenshot 2024-03-07 at 23 04 00" src="https://github.com/go-gitea/gitea/assets/115237/df0fbe1f-96ee-4338-ab5e-2b10e215005d">
* Remove jQuery from the Unicode escape button (#29369)Yarden Shoham2024-02-241-0/+4
| | | | | | | | | | | | | - Switched to plain JavaScript - Tested the Unicode escape button functionality and it works as before # Demo using JavaScript without jQuery ![action](https://github.com/go-gitea/gitea/assets/20454870/664f0ced-876b-4cb7-a668-bd62169fc843) --------- Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Implement code frequency graph (#29191)Şahin Akkaya2024-02-231-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Overview This is the implementation of Code Frequency page. This feature was mentioned on these issues: #18262, #7392. It adds another tab to Activity page called Code Frequency. Code Frequency tab shows additions and deletions over time since the repository existed. Before: <img width="1296" alt="image" src="https://github.com/go-gitea/gitea/assets/32161460/2603504f-aee7-4929-a8c4-fb3412a7a0f6"> After: <img width="1296" alt="image" src="https://github.com/go-gitea/gitea/assets/32161460/58c03721-729f-4536-a663-9f337f240963"> --- #### Features - See additions deletions over time since repository existed - Click on "Additions" or "Deletions" legend to show only one type of contribution - Use the same cache from Contributors page so that the loading of data will be fast once it is cached by visiting either one of the pages --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Remove jQuery from repo wiki creation page (#29271)Yarden Shoham2024-02-201-0/+12
| | | | | | | | | | | | | - Switched to plain JavaScript - Tested the wiki creation form functionality and it works as before # Demo using JavaScript without jQuery ![action](https://github.com/go-gitea/gitea/assets/20454870/2dfc95fd-40cc-4ffb-9ae6-50f798fddd67) --------- Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: silverwind <me@silverwind.io>
* Downscale pasted PNG images based on metadata (#29123)silverwind2024-02-192-0/+76
| | | | | | | | | | | | | | | | Some images like MacOS screenshots contain [pHYs](http://www.libpng.org/pub/png/book/chapter11.html#png.ch11.div.8) data which we can use to downscale uploaded images so they render in the same dppx ratio in which they were taken. Before: <img width="584" alt="image" src="https://github.com/go-gitea/gitea/assets/115237/50979e3a-5d5a-40dc-a0a4-36eb6e28f14a"> After: <img width="329" alt="image" src="https://github.com/go-gitea/gitea/assets/115237/0690902a-f2fe-4c6b-97b3-6fdd67c21bad">
* Make submit event code work with both jQuery event and native event (#29223)wxiaoguang2024-02-171-0/+1
| | | | | Partially related to #29200 and fix other potential bugs. Co-authored-by: Giteabot <teabot@gitea.io>
* Implement contributors graph (#27882)Şahin Akkaya2024-02-152-0/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Continuation of https://github.com/go-gitea/gitea/pull/25439. Fixes #847 Before: <img width="1296" alt="image" src="https://github.com/go-gitea/gitea/assets/32161460/24571ac8-b254-43c9-b178-97340f0dc8a9"> ---- After: <img width="1296" alt="image" src="https://github.com/go-gitea/gitea/assets/32161460/c60b2459-9d10-4d42-8d83-d5ef0f45bf94"> --- #### Overview This is the implementation of a requested feature: Contributors graph (#847) It makes Activity page a multi-tab page and adds a new tab called Contributors. Contributors tab shows the contribution graphs over time since the repository existed. It also shows per user contribution graphs for top 100 contributors. Top 100 is calculated based on the selected contribution type (commits, additions or deletions). --- #### Demo (The demo is a bit old but still a good example to show off the main features) <video src="https://github.com/go-gitea/gitea/assets/32161460/9f68103f-8145-4cc2-94bc-5546daae7014" controls width="320" height="240"> <a href="https://github.com/go-gitea/gitea/assets/32161460/9f68103f-8145-4cc2-94bc-5546daae7014">Download</a> </video> #### Features: - Select contribution type (commits, additions or deletions) - See overall and per user contribution graphs for the selected contribution type - Zoom and pan on graphs to see them in detail - See top 100 contributors based on the selected contribution type and selected time range - Go directly to users' profile by clicking their name if they are registered gitea users - Cache the results so that when the same repository is visited again fetching data will be faster --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: hiifong <i@hiif.ong> Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: yp05327 <576951401@qq.com>
* Avoid showing unnecessary JS errors when there are elements with different ↵wxiaoguang2024-02-081-0/+11
| | | | | origin on the page (#29081) Try to fix #29080
* Polyfill SubmitEvent for PaleMoon (#28441)wxiaoguang2023-12-151-0/+21
|
* Replace ajax with fetch, improve image diff (#27267)silverwind2023-10-111-0/+11
| | | | | | | | | | | 1. Dropzone attachment removal, pretty simple replacement 2. Image diff: The previous code fetched every image twice, once via `img[src]` and once via `$.ajax`. Now it's only fetched once and a second time only when necessary. The image diff code was partially rewritten. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Use vitest globals (#27102)silverwind2023-09-273-3/+0
| | | | Enable [globals](https://vitest.dev/config/#globals) in vitest, reducing the noise in test files.
* Avoiding accessing undefined mentionValues (#26461)wxiaoguang2023-08-121-1/+1
| | | | | | | | | The `window.config.mentionValues` might be undefined: ``` {{if or .Participants .Assignees .MentionableTeams}} mentionValues: ... {{end}} ```
* Always pass 6-digit hex color to monaco (#25780)silverwind2023-07-092-34/+1
| | | | | | | | | | | | Monaco can not deal with color formats other than 6-digit hex, so we convert the colors for it via new [`tinycolor2`](https://github.com/bgrins/TinyColor) dependency (5kB minzipped). Also, with the addition of the module, we can replace the existing `hexToRGBColor` usage, I verified it is compatible with the current tests before removing the function. Fixes: https://github.com/go-gitea/gitea/issues/25770
* Update emoji set to Unicode 15 (#25595)isla w2023-06-291-0/+4
| | | | | | | | | | | Update emoji set to Unicode 15 which was added upstream here: https://github.com/github/gemoji/commit/cb5c514d472daf9b312c963987f4d7ee865c28fe <img width="854" alt="Screenshot 2023-06-29 at 11 02 56 AM" src="https://github.com/go-gitea/gitea/assets/1669571/7bfb663d-0804-4d23-a62d-f585a6783ca6"> --------- Co-authored-by: silverwind <me@silverwind.io>
* rename tributeValues to mentionValues (#25375)silverwind2023-06-202-3/+3
| | | | Very simple change, just rename this variable so it does not feature the name of the module.