From e68b9d00a6e05b3a941f63ffb696f91e554ac5ec Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 18 Oct 2024 20:33:49 +0200 Subject: Adding upstream version 9.0.3. Signed-off-by: Daniel Baumann --- web_src/js/components/.eslintrc.yaml | 21 + web_src/js/components/ActionRunStatus.vue | 39 + web_src/js/components/ActivityHeatmap.vue | 83 ++ web_src/js/components/ContextPopup.test.js | 163 ++++ web_src/js/components/ContextPopup.vue | 130 +++ web_src/js/components/DashboardRepoList.vue | 537 ++++++++++++ web_src/js/components/DiffCommitSelector.vue | 306 +++++++ web_src/js/components/DiffFileList.vue | 58 ++ web_src/js/components/DiffFileTree.vue | 144 ++++ web_src/js/components/DiffFileTreeItem.vue | 97 +++ web_src/js/components/PullRequestMergeForm.test.js | 34 + web_src/js/components/PullRequestMergeForm.vue | 252 ++++++ web_src/js/components/RepoActionView.test.js | 105 +++ web_src/js/components/RepoActionView.vue | 905 +++++++++++++++++++++ web_src/js/components/RepoActivityTopAuthors.vue | 164 ++++ web_src/js/components/RepoBranchTagSelector.vue | 357 ++++++++ web_src/js/components/RepoCodeFrequency.vue | 172 ++++ web_src/js/components/RepoContributors.vue | 431 ++++++++++ web_src/js/components/RepoRecentCommits.vue | 149 ++++ .../js/components/ScopedAccessTokenSelector.vue | 115 +++ 20 files changed, 4262 insertions(+) create mode 100644 web_src/js/components/.eslintrc.yaml create mode 100644 web_src/js/components/ActionRunStatus.vue create mode 100644 web_src/js/components/ActivityHeatmap.vue create mode 100644 web_src/js/components/ContextPopup.test.js create mode 100644 web_src/js/components/ContextPopup.vue create mode 100644 web_src/js/components/DashboardRepoList.vue create mode 100644 web_src/js/components/DiffCommitSelector.vue create mode 100644 web_src/js/components/DiffFileList.vue create mode 100644 web_src/js/components/DiffFileTree.vue create mode 100644 web_src/js/components/DiffFileTreeItem.vue create mode 100644 web_src/js/components/PullRequestMergeForm.test.js create mode 100644 web_src/js/components/PullRequestMergeForm.vue create mode 100644 web_src/js/components/RepoActionView.test.js create mode 100644 web_src/js/components/RepoActionView.vue create mode 100644 web_src/js/components/RepoActivityTopAuthors.vue create mode 100644 web_src/js/components/RepoBranchTagSelector.vue create mode 100644 web_src/js/components/RepoCodeFrequency.vue create mode 100644 web_src/js/components/RepoContributors.vue create mode 100644 web_src/js/components/RepoRecentCommits.vue create mode 100644 web_src/js/components/ScopedAccessTokenSelector.vue (limited to 'web_src/js/components') diff --git a/web_src/js/components/.eslintrc.yaml b/web_src/js/components/.eslintrc.yaml new file mode 100644 index 0000000..0d23344 --- /dev/null +++ b/web_src/js/components/.eslintrc.yaml @@ -0,0 +1,21 @@ +plugins: + - eslint-plugin-vue + - eslint-plugin-vue-scoped-css + +extends: + - ../../../.eslintrc.yaml + - plugin:vue/vue3-recommended + - plugin:vue-scoped-css/vue3-recommended + +parserOptions: + sourceType: module + ecmaVersion: latest + +env: + browser: true + +rules: + vue/attributes-order: [0] + vue/html-closing-bracket-spacing: [2, {startTag: never, endTag: never, selfClosingTag: never}] + vue/max-attributes-per-line: [0] + vue-scoped-css/enforce-style-type: [0] diff --git a/web_src/js/components/ActionRunStatus.vue b/web_src/js/components/ActionRunStatus.vue new file mode 100644 index 0000000..7ada543 --- /dev/null +++ b/web_src/js/components/ActionRunStatus.vue @@ -0,0 +1,39 @@ + + + diff --git a/web_src/js/components/ActivityHeatmap.vue b/web_src/js/components/ActivityHeatmap.vue new file mode 100644 index 0000000..be0841e --- /dev/null +++ b/web_src/js/components/ActivityHeatmap.vue @@ -0,0 +1,83 @@ + + diff --git a/web_src/js/components/ContextPopup.test.js b/web_src/js/components/ContextPopup.test.js new file mode 100644 index 0000000..2726567 --- /dev/null +++ b/web_src/js/components/ContextPopup.test.js @@ -0,0 +1,163 @@ +import {flushPromises, mount} from '@vue/test-utils'; +import ContextPopup from './ContextPopup.vue'; + +async function assertPopup(popupData, expectedIconColor, expectedIcon) { + const date = new Date('2024-07-13T22:00:00Z'); + + vi.spyOn(global, 'fetch').mockResolvedValue({ + json: vi.fn().mockResolvedValue({ + ok: true, + created_at: date.toISOString(), + repository: {full_name: 'user2/repo1'}, + ...popupData, + }), + ok: true, + }); + + const popup = mount(ContextPopup); + popup.vm.$el.dispatchEvent(new CustomEvent('ce-load-context-popup', { + detail: {owner: 'user2', repo: 'repo1', index: popupData.number}, + })); + await flushPromises(); + + expect(popup.get('p:nth-of-type(1)').text()).toEqual(`user2/repo1 on ${date.toLocaleDateString(undefined, {year: 'numeric', month: 'short', day: 'numeric'})}`); + expect(popup.get('p:nth-of-type(2)').text()).toEqual(`${popupData.title} #${popupData.number}`); + expect(popup.get('p:nth-of-type(3)').text()).toEqual(popupData.body); + + expect(popup.get('svg').classes()).toContain(expectedIcon); + expect(popup.get('svg').classes()).toContain(expectedIconColor); + + for (const l of popupData.labels) { + expect(popup.findAll('.ui.label').map((x) => x.text())).toContain(l.name); + } +} + +test('renders an open issue popup', async () => { + await assertPopup({ + title: 'Open Issue', + body: 'Open Issue Body', + number: 1, + labels: [{color: 'd21b1fff', name: 'Bug'}, {color: 'aaff00', name: 'Confirmed'}], + state: 'open', + pull_request: null, + }, 'green', 'octicon-issue-opened'); +}); + +test('renders a closed issue popup', async () => { + await assertPopup({ + title: 'Closed Issue', + body: 'Closed Issue Body', + number: 1, + labels: [{color: 'd21b1fff', name: 'Bug'}, {color: 'aaff00', name: 'Confirmed'}], + state: 'closed', + pull_request: null, + }, 'red', 'octicon-issue-closed'); +}); + +test('renders an open PR popup', async () => { + await assertPopup({ + title: 'Open PR', + body: 'Open PR Body', + number: 1, + labels: [{color: 'd21b1fff', name: 'Bug'}, {color: 'aaff00', name: 'Confirmed'}], + state: 'open', + pull_request: {merged: false, draft: false}, + }, 'green', 'octicon-git-pull-request'); +}); + +test('renders an open WIP PR popup', async () => { + await assertPopup({ + title: 'WIP: Open PR', + body: 'WIP Open PR Body', + number: 1, + labels: [{color: 'd21b1fff', name: 'Bug'}, {color: 'aaff00', name: 'Confirmed'}], + state: 'open', + pull_request: {merged: false, draft: true}, + }, 'grey', 'octicon-git-pull-request-draft'); +}); + +test('renders a closed PR popup', async () => { + await assertPopup({ + title: 'Closed PR', + body: 'Closed PR Body', + number: 1, + labels: [{color: 'd21b1fff', name: 'Bug'}, {color: 'aaff00', name: 'Confirmed'}], + state: 'closed', + pull_request: {merged: false, draft: false}, + }, 'red', 'octicon-git-pull-request-closed'); +}); + +test('renders a closed WIP PR popup', async () => { + await assertPopup({ + title: 'WIP: Closed PR', + body: 'WIP Closed PR Body', + number: 1, + labels: [{color: 'd21b1fff', name: 'Bug'}, {color: 'aaff00', name: 'Confirmed'}], + state: 'closed', + pull_request: {merged: false, draft: true}, + }, 'red', 'octicon-git-pull-request-closed'); +}); + +test('renders a merged PR popup', async () => { + await assertPopup({ + title: 'Merged PR', + body: 'Merged PR Body', + number: 1, + labels: [{color: 'd21b1fff', name: 'Bug'}, {color: 'aaff00', name: 'Confirmed'}], + state: 'closed', + pull_request: {merged: true, draft: false}, + }, 'purple', 'octicon-git-merge'); +}); + +test('renders an issue popup with escaped HTML', async () => { + const evil = ''; + + vi.spyOn(global, 'fetch').mockResolvedValue({ + json: vi.fn().mockResolvedValue({ + ok: true, + created_at: '2024-07-13T22:00:00Z', + repository: {full_name: evil}, + title: evil, + body: evil, + labels: [{color: '000666', name: evil}], + state: 'open', + pull_request: null, + }), + ok: true, + }); + + const popup = mount(ContextPopup); + popup.vm.$el.dispatchEvent(new CustomEvent('ce-load-context-popup', { + detail: {owner: evil, repo: evil, index: 1}, + })); + await flushPromises(); + + expect(() => popup.get('.evil')).toThrowError(); + expect(popup.get('p:nth-of-type(1)').text()).toContain(evil); + expect(popup.get('p:nth-of-type(2)').text()).toContain(evil); + expect(popup.get('p:nth-of-type(3)').text()).toContain(evil); +}); + +test('renders an issue popup with emojis', async () => { + vi.spyOn(global, 'fetch').mockResolvedValue({ + json: vi.fn().mockResolvedValue({ + ok: true, + created_at: '2024-07-13T22:00:00Z', + repository: {full_name: 'user2/repo1'}, + title: 'Title', + body: 'Body', + labels: [{color: '000666', name: 'Tag :+1:'}], + state: 'open', + pull_request: null, + }), + ok: true, + }); + + const popup = mount(ContextPopup); + popup.vm.$el.dispatchEvent(new CustomEvent('ce-load-context-popup', { + detail: {owner: 'user2', repo: 'repo1', index: 1}, + })); + await flushPromises(); + + expect(popup.get('.ui.label').text()).toEqual('Tag 👍'); +}); diff --git a/web_src/js/components/ContextPopup.vue b/web_src/js/components/ContextPopup.vue new file mode 100644 index 0000000..752a9a1 --- /dev/null +++ b/web_src/js/components/ContextPopup.vue @@ -0,0 +1,130 @@ + + diff --git a/web_src/js/components/DashboardRepoList.vue b/web_src/js/components/DashboardRepoList.vue new file mode 100644 index 0000000..e587413 --- /dev/null +++ b/web_src/js/components/DashboardRepoList.vue @@ -0,0 +1,537 @@ + + + diff --git a/web_src/js/components/DiffCommitSelector.vue b/web_src/js/components/DiffCommitSelector.vue new file mode 100644 index 0000000..3f6e4e4 --- /dev/null +++ b/web_src/js/components/DiffCommitSelector.vue @@ -0,0 +1,306 @@ + + + diff --git a/web_src/js/components/DiffFileList.vue b/web_src/js/components/DiffFileList.vue new file mode 100644 index 0000000..916780d --- /dev/null +++ b/web_src/js/components/DiffFileList.vue @@ -0,0 +1,58 @@ + + diff --git a/web_src/js/components/DiffFileTree.vue b/web_src/js/components/DiffFileTree.vue new file mode 100644 index 0000000..cddfee1 --- /dev/null +++ b/web_src/js/components/DiffFileTree.vue @@ -0,0 +1,144 @@ + + + diff --git a/web_src/js/components/DiffFileTreeItem.vue b/web_src/js/components/DiffFileTreeItem.vue new file mode 100644 index 0000000..0f6e543 --- /dev/null +++ b/web_src/js/components/DiffFileTreeItem.vue @@ -0,0 +1,97 @@ + + + diff --git a/web_src/js/components/PullRequestMergeForm.test.js b/web_src/js/components/PullRequestMergeForm.test.js new file mode 100644 index 0000000..7b856e0 --- /dev/null +++ b/web_src/js/components/PullRequestMergeForm.test.js @@ -0,0 +1,34 @@ +// Copyright 2024 The Forgejo Authors. All rights reserved. +// SPDX-License-Identifier: MIT +import {flushPromises, mount} from '@vue/test-utils'; +import PullRequestMergeForm from './PullRequestMergeForm.vue'; + +async function renderMergeForm(branchName) { + window.config.pageData.pullRequestMergeForm = { + textDeleteBranch: `Delete branch "${branchName}"`, + textDoMerge: 'Merge', + defaultMergeStyle: 'merge', + isPullBranchDeletable: true, + canMergeNow: true, + mergeStyles: [{ + 'name': 'merge', + 'allowed': true, + 'textDoMerge': 'Merge', + 'mergeTitleFieldText': 'Merge PR', + 'mergeMessageFieldText': 'Description', + 'hideAutoMerge': 'Hide this message', + }], + }; + const mergeform = mount(PullRequestMergeForm); + mergeform.get('.merge-button').trigger('click'); + await flushPromises(); + return mergeform; +} + +test('renders escaped branch name', async () => { + let mergeform = await renderMergeForm('evil'); + expect(mergeform.get('label[for="delete-branch-after-merge"]').text()).toBe('Delete branch "evil"'); + + mergeform = await renderMergeForm(''); + expect(mergeform.get('label[for="delete-branch-after-merge"]').text()).toBe('Delete branch ""'); +}); diff --git a/web_src/js/components/PullRequestMergeForm.vue b/web_src/js/components/PullRequestMergeForm.vue new file mode 100644 index 0000000..bd0901a --- /dev/null +++ b/web_src/js/components/PullRequestMergeForm.vue @@ -0,0 +1,252 @@ + +