From f45928e608051b1a98e27adcd4bbeab83fd4bd9f Mon Sep 17 00:00:00 2001 From: Gusted Date: Thu, 18 Jul 2024 22:05:02 +0200 Subject: [PATCH] [UI] Replace `vue-bar-graph` with `chart.js` - Backport of #4571 - The usage of the `vue-bar-graph` is complicated, because of the `GSAP` dependency they pull in, the dependency uses a non-free license. - The code is rewritten to use the `chart.js` library, which is already used to draw other charts in the activity tab. Due to the limitation of `chart.js`, we have to create a plugin in order to have images as labels and do click handling for those images. - The chart isn't the same as the previous one, once again simply due to how `chart.js` works, the amount of commits isn't drawn anymore in the bar, you instead have to hover over it or look at the y-axis. - Resolves #4569 (cherry picked from commit a83002679df5c1d72b41f2ca015c5cb3e0c6d10d) --- options/locale/locale_en-US.ini | 1 + package-lock.json | 15 -- package.json | 1 - templates/repo/pulse.tmpl | 2 +- web_src/css/base.css | 4 - web_src/css/repo.css | 4 + .../js/components/RepoActivityTopAuthors.vue | 186 +++++++++++------- 7 files changed, 121 insertions(+), 92 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 95b530f753..9b6bcfb107 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -2089,6 +2089,7 @@ activity.git_stats_addition_n = %d additions activity.git_stats_and_deletions = and activity.git_stats_deletion_1 = %d deletion activity.git_stats_deletion_n = %d deletions +activity.commit = Commit activity contributors.contribution_type.filter_label = Contribution type: contributors.contribution_type.commits = Commits diff --git a/package-lock.json b/package-lock.json index 43e37d278d..f7c4b44d24 100644 --- a/package-lock.json +++ b/package-lock.json @@ -55,7 +55,6 @@ "tributejs": "5.1.3", "uint8-to-base64": "0.2.0", "vue": "3.4.21", - "vue-bar-graph": "2.0.0", "vue-chartjs": "5.3.0", "vue-loader": "17.4.2", "vue3-calendar-heatmap": "2.0.5", @@ -6583,11 +6582,6 @@ "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "dev": true }, - "node_modules/gsap": { - "version": "3.12.5", - "resolved": "https://registry.npmjs.org/gsap/-/gsap-3.12.5.tgz", - "integrity": "sha512-srBfnk4n+Oe/ZnMIOXt3gT605BX9x5+rh/prT2F1SsNJsU1XuMiP0E2aptW481OnonOGACZWBqseH5Z7csHxhQ==" - }, "node_modules/hammerjs": { "version": "2.0.8", "resolved": "https://registry.npmjs.org/hammerjs/-/hammerjs-2.0.8.tgz", @@ -12228,15 +12222,6 @@ } } }, - "node_modules/vue-bar-graph": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/vue-bar-graph/-/vue-bar-graph-2.0.0.tgz", - "integrity": "sha512-IoYP+r5Ggjys6QdUNYFPh7qD41wi/uDOJj9nMawvDgvV6niOz3Dw8O2/98ZnUgjTpcgcGFDaaAaK6qa9x1jgpw==", - "dependencies": { - "gsap": "^3.10.4", - "vue": "^3.2.37" - } - }, "node_modules/vue-chartjs": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/vue-chartjs/-/vue-chartjs-5.3.0.tgz", diff --git a/package.json b/package.json index 6c01c8be63..2380bbf51e 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,6 @@ "tributejs": "5.1.3", "uint8-to-base64": "0.2.0", "vue": "3.4.21", - "vue-bar-graph": "2.0.0", "vue-chartjs": "5.3.0", "vue-loader": "17.4.2", "vue3-calendar-heatmap": "2.0.5", diff --git a/templates/repo/pulse.tmpl b/templates/repo/pulse.tmpl index cfb3ec1d3d..0d293cf81f 100644 --- a/templates/repo/pulse.tmpl +++ b/templates/repo/pulse.tmpl @@ -101,7 +101,7 @@ {{ctx.Locale.TrN .Activity.Code.Deletions "repo.activity.git_stats_deletion_1" "repo.activity.git_stats_deletion_n" .Activity.Code.Deletions}}.
-
+
{{end}} diff --git a/web_src/css/base.css b/web_src/css/base.css index a8f6626457..9832dba523 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -1214,10 +1214,6 @@ overflow-menu .ui.label { color: var(--color-primary-contrast); } -.activity-bar-graph-alt { - color: var(--color-primary-contrast); -} - .archived-icon { color: var(--color-secondary-dark-2) !important; } diff --git a/web_src/css/repo.css b/web_src/css/repo.css index a603218f4a..7295abe927 100644 --- a/web_src/css/repo.css +++ b/web_src/css/repo.css @@ -3105,3 +3105,7 @@ tbody.commit-list { font-size: inherit; line-height: inherit; } + +#repo-activity-top-authors-chart { + height: 150px; /* Pre-allocate the height that will be taken up by the chart, to avoid the container 'jumping'. */ +} diff --git a/web_src/js/components/RepoActivityTopAuthors.vue b/web_src/js/components/RepoActivityTopAuthors.vue index a41fb61d78..52986c0493 100644 --- a/web_src/js/components/RepoActivityTopAuthors.vue +++ b/web_src/js/components/RepoActivityTopAuthors.vue @@ -1,14 +1,36 @@