-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Add project column picker to issue and pull request sidebar #37037
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
Open
myers
wants to merge
21
commits into
go-gitea:main
Choose a base branch
from
myers:feat/issue-column-picker
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
537174c
Add project column picker to issue and pull request sidebar
myers 0b1b962
Refactor column picker to use generic combo list rerender
myers eb6d19a
Add error toast to sidebar combo list backend updates
myers 9035a92
Add E2E test for project column picker
myers 8f55cca
Use selection dropdown style for column picker
myers 26c8ed0
Add Go integration tests and improve E2E assertions for column picker
myers 4f73bab
fix
wxiaoguang a6811b0
fix get default column
wxiaoguang 02a328a
prepare support multiple projects
wxiaoguang 198d13d
revert frontend change
wxiaoguang 165b6e4
clean up backend
wxiaoguang 36810b8
Merge branch 'main' into feat/issue-column-picker
wxiaoguang 7762325
reload page partially
wxiaoguang 87cfc38
Merge branch 'main' into feat/issue-column-picker
wxiaoguang c576897
clean up
wxiaoguang ea3db23
fine tune
wxiaoguang eb9f4f1
fix combolist
wxiaoguang 11b96d7
revert unnecessary changes
wxiaoguang 0378a6a
fix ui
wxiaoguang 321643c
Merge branch 'main' into feat/issue-column-picker
wxiaoguang 680437f
fix merge
wxiaoguang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| {{$pageMeta := .}} | ||
| {{$data := .ProjectsData}} | ||
| <div id="sidebar-project-column" | ||
| data-issue-id="{{if $pageMeta.Issue}}{{$pageMeta.Issue.ID}}{{end}}" | ||
| data-update-url="{{if $pageMeta.Issue}}{{$pageMeta.RepoLink}}/issues/projects/column?issue_id={{$pageMeta.Issue.ID}}{{end}}"> | ||
| {{if and $pageMeta.Issue $pageMeta.Issue.Project $data.ProjectColumns (gt (len $data.ProjectColumns) 1)}} | ||
| {{if $pageMeta.CanModifyIssueOrPull}} | ||
| <div class="ui dropdown selection fluid column-selector-dropdown" | ||
| data-update-url="{{$pageMeta.RepoLink}}/issues/projects/column?issue_id={{$pageMeta.Issue.ID}}"> | ||
| <input type="hidden" name="column_id" value="{{$data.SelectedColumnID}}"> | ||
| <div class="default text">{{range $data.ProjectColumns}}{{if eq .ID $data.SelectedColumnID}}{{.Title}}{{end}}{{end}}</div> | ||
| {{svg "octicon-triangle-down" 14 "dropdown icon"}} | ||
| <div class="menu"> | ||
| {{range $data.ProjectColumns}} | ||
| <div class="item {{if eq .ID $data.SelectedColumnID}}active selected{{end}}" data-value="{{.ID}}">{{.Title}}</div> | ||
| {{end}} | ||
| </div> | ||
| </div> | ||
| {{else}} | ||
| {{range $data.ProjectColumns}} | ||
| {{if eq .ID $data.SelectedColumnID}} | ||
| <div class="tw-mt-1"> | ||
| <span class="muted">{{svg "octicon-columns" 16 "tw-mr-1"}}{{.Title}}</span> | ||
| </div> | ||
| {{end}} | ||
| {{end}} | ||
| {{end}} | ||
| {{end}} | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,3 +49,4 @@ | |
| {{end}} | ||
| </div> | ||
| </div> | ||
| {{template "repo/issue/sidebar/project_column" $pageMeta}} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| import {POST} from '../modules/fetch.ts'; | ||
| import type {IssueSidebarComboList} from './repo-issue-sidebar-combolist.ts'; | ||
| import {html, htmlRaw} from '../utils/html.ts'; | ||
| import {createElementFromHTML} from '../utils/dom.ts'; | ||
|
|
||
| type ColumnInfo = { | ||
| id: number; | ||
| title: string; | ||
| }; | ||
|
|
||
| export function initProjectColumnPicker() { | ||
| const columnSection = document.querySelector<HTMLElement>('#sidebar-project-column'); | ||
| if (!columnSection) return; | ||
|
|
||
| initColumnDropdown(columnSection); | ||
|
|
||
| const projectCombo = document.querySelector<HTMLElement>('.issue-sidebar-combo[data-update-url*="/issues/projects?"]'); | ||
| if (!projectCombo) return; | ||
|
|
||
| const comboList = (projectCombo as any)._comboList as IssueSidebarComboList | undefined; | ||
| if (!comboList) return; | ||
|
|
||
| comboList.onAfterUpdate = async (response: Response, _changedValues: string[]): Promise<boolean> => { | ||
| const data = await response.json(); | ||
| const columns: ColumnInfo[] = data.columns || []; | ||
| const selectedColumnID: number = data.selected_column_id || 0; | ||
|
|
||
| comboList.updateUiList(comboList.collectCheckedValues()); | ||
|
|
||
| const updateUrl = columnSection.getAttribute('data-update-url') || ''; | ||
| renderColumnPicker(columnSection, columns, selectedColumnID, updateUrl); | ||
| return true; | ||
| }; | ||
| } | ||
|
|
||
| function initColumnDropdown(section: HTMLElement) { | ||
| const dropdown = section.querySelector<HTMLElement>('.column-selector-dropdown'); | ||
| if (!dropdown) return; | ||
| setupFomanticDropdown(dropdown); | ||
| } | ||
|
|
||
| function setupFomanticDropdown(el: HTMLElement) { | ||
| const updateUrl = el.getAttribute('data-update-url'); | ||
| if (!updateUrl) return; | ||
|
|
||
| $(el).dropdown({ | ||
| onChange(value: string) { | ||
| POST(updateUrl, {data: new URLSearchParams({id: value})}); | ||
wxiaoguang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }, | ||
| }); | ||
| } | ||
|
|
||
| function renderColumnPicker( | ||
| section: HTMLElement, | ||
| columns: ColumnInfo[], | ||
| selectedColumnID: number, | ||
| baseUpdateUrl: string, | ||
| ) { | ||
| section.innerHTML = ''; | ||
|
|
||
| if (columns.length < 2) return; | ||
|
|
||
| const selectedCol = columns.find((c) => c.id === selectedColumnID); | ||
| const selectedTitle = selectedCol ? selectedCol.title : columns[0].title; | ||
|
|
||
| const svgTriangle = document.querySelector('.svg.octicon-triangle-down')?.cloneNode(true) as SVGElement | null; | ||
| const triangleHtml = svgTriangle ? (() => { | ||
| svgTriangle.setAttribute('width', '14'); | ||
| svgTriangle.setAttribute('height', '14'); | ||
| svgTriangle.classList.add('dropdown', 'icon'); | ||
| return svgTriangle.outerHTML; | ||
| })() : ''; | ||
|
|
||
| let menuItemsHtml = ''; | ||
| for (const col of columns) { | ||
| const selectedClass = col.id === selectedColumnID ? ' active selected' : ''; | ||
| menuItemsHtml += html`<div class="item${htmlRaw(selectedClass)}" data-value="${col.id}">${col.title}</div>`; | ||
| } | ||
|
|
||
| const dropdown = createElementFromHTML(html` | ||
| <div class="ui dropdown selection fluid column-selector-dropdown" | ||
| data-update-url="${baseUpdateUrl}"> | ||
| <input type="hidden" name="column_id" value="${selectedColumnID}"> | ||
| <div class="default text">${selectedTitle}</div> | ||
| ${htmlRaw(triangleHtml)} | ||
| <div class="menu">${htmlRaw(menuItemsHtml)}</div> | ||
| </div> | ||
| `); | ||
|
|
||
| section.append(dropdown); | ||
| setupFomanticDropdown(dropdown); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The comment and code was added to wrong place.