Skip to content
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

Kanban board #8346

Merged
merged 379 commits into from
Aug 17, 2020
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
379 commits
Select commit Hold shift + click to select a range
9336664
fix bug where project gear button never shows in repo sidebar
adelowo Apr 12, 2020
d35fb3e
Make sure uncategorized board always have the projectID
adelowo Apr 13, 2020
4367f22
make sure project boards can be edited
adelowo Apr 13, 2020
7edfedc
close modal on success
adelowo Apr 13, 2020
63ea2af
reload on name change
adelowo Apr 13, 2020
41cebe6
format template properly
adelowo Apr 13, 2020
a87c8ca
delete projects
adelowo Apr 13, 2020
4ce64a1
Fix MergeConflict relicts and fronted Lint (#6)
6543 Apr 13, 2020
d7b1e8c
tiny updates
adelowo Apr 15, 2020
0d4d957
Merge branch 'master' of github.com:go-gitea/gitea into kanban_board
adelowo Apr 17, 2020
93863ba
fix button translation
adelowo Apr 17, 2020
6e24ab1
add new board column to a project
adelowo Apr 17, 2020
7a04527
fix trash icon
adelowo Apr 17, 2020
e6f710a
fix merge conflict relicts
6543 Apr 17, 2020
31bc3a3
fix js lint issues
6543 Apr 17, 2020
bd2868d
remove inrelated code change
6543 Apr 17, 2020
b3ddc58
beautify
6543 Apr 17, 2020
d99c577
migrate octicons
6543 Apr 17, 2020
9b9cd05
Merge branch 'master' into kanban_board
6543 Apr 17, 2020
36c2d2d
remove <span class="badge">{{svg "octicon..."}}</span>
6543 Apr 17, 2020
3d6d0c7
Merge branch 'master' into kanban_board
6543 Apr 20, 2020
5fc69c2
fix Board Menue
6543 Apr 20, 2020
c68b70f
Merge branch master into kanban_board
6543 Apr 20, 2020
adb8405
rm deadcode (merge conflict relicts)
6543 Apr 20, 2020
4ee5212
fix some lint errors
6543 Apr 20, 2020
d3a3006
Merge branch 'master' into kanban_board
6543 Apr 20, 2020
eeee1d6
...
6543 Apr 20, 2020
2d37d70
Merge branch 'master' into kanban_board
6543 Apr 20, 2020
b024482
dont split add direct
6543 Apr 20, 2020
147dd90
remove merge conflict relicts
6543 Apr 20, 2020
c75e62f
code refactor
6543 Apr 20, 2020
55bd9e7
fix Issue Sidebar
6543 Apr 20, 2020
4fd1c22
FIX
6543 Apr 20, 2020
c4be71d
smal ui fix
6543 Apr 20, 2020
eedbd98
addopt new style
6543 Apr 21, 2020
248e030
addopt unit disable/enable ...
6543 Apr 21, 2020
4d6ca62
Update modules/setting/repository.go
6543 Apr 21, 2020
c5466c2
hide Project related Comments if Disabled
6543 Apr 21, 2020
db4d342
fix octicons
6543 Apr 21, 2020
755a178
code format
6543 Apr 21, 2020
26c96d2
reformat template
6543 Apr 21, 2020
2b4ac5c
fix only on issue on a board, refactor, move logic into models
6543 Apr 21, 2020
ea4bddf
remove template debug stuff
6543 Apr 21, 2020
b6df0dc
fix things after cleanup
6543 Apr 21, 2020
3c862f8
refactor & lints
6543 Apr 21, 2020
069983c
lint & refactor & fix
6543 Apr 21, 2020
d686a1d
name convention and split
6543 Apr 21, 2020
3068438
ChangeProjectStatus & ChangeMilestonStatus are similar but combining …
6543 Apr 21, 2020
2f660d0
typo fix & convince revive
6543 Apr 21, 2020
5822bc5
Merge branch 'master' into kanban_board
6543 Apr 21, 2020
31c2b9d
fix css
6543 Apr 21, 2020
2d5ae7b
fix lint
6543 Apr 21, 2020
3104c1b
format template
6543 Apr 21, 2020
9329913
make it look nicer and make it work
6543 Apr 21, 2020
95ebbb6
remove projects from profile page
adelowo Apr 21, 2020
c738c04
Draft ONE
6543 Apr 21, 2020
c84b888
Fix Find: Error 1066: Not unique table/alias: issue_project
6543 Apr 21, 2020
6134e77
handle edge casses
6543 Apr 21, 2020
e40d51d
GroupBy act wrong - rm
6543 Apr 21, 2020
7f9f277
remove db schema change relicts
6543 Apr 21, 2020
5a05ac8
Merge branch 'master' into kanban_board
6543 Apr 21, 2020
1319962
fix, imprufe, refactor
6543 Apr 21, 2020
3521fc6
impruve board card look
6543 Apr 22, 2020
b2fc19b
RENAME: IssueProject -> ProjectIssues
6543 Apr 22, 2020
9bac2d1
smal renames and imprufements
6543 Apr 22, 2020
8c992c8
canf find error but fix lint
6543 Apr 22, 2020
60efc5f
fix & extend migration
6543 Apr 22, 2020
d4f118b
Fix migration - creat tables outside a session
6543 Apr 22, 2020
8a20acd
fix js thanks @jaqra
6543 Apr 22, 2020
3e80ee1
import fromat ...
6543 Apr 22, 2020
ac1557a
Merge branch 'master' into kanban_board
6543 Apr 22, 2020
18113eb
fix milestone color
6543 Apr 22, 2020
2e086fa
Merge branch 'master' into kanban_board
6543 Apr 23, 2020
7b8c70e
Merge branch 'master' into kanban_board
6543 Apr 24, 2020
f2f2086
Merge branch 'master' into kanban_board
adelowo Apr 25, 2020
4a329be
Merge branch 'master' into kanban_board
adelowo Apr 26, 2020
ad0e040
Update web_src/js/features/projects.js
6543 Apr 26, 2020
1ed3636
Merge branch 'master' into kanban_board
6543 Apr 26, 2020
a228324
Add enable/disable project unit for repository and global unit check
metiftikci Apr 26, 2020
e10ba6b
Add enable/disable project unit for repository and global unit check
6543 Apr 26, 2020
589662e
Show/Hide Project section on issue view sidebar according to permission
metiftikci Apr 26, 2020
82f5740
Add modal confir for deleting a board
metiftikci Apr 26, 2020
6380431
use Upercase - looks nicer
6543 Apr 26, 2020
ad49c9e
Fix models/project_issues.go
6543 Apr 26, 2020
604119f
let project-unit enable/disable via API
6543 Apr 26, 2020
e69f38b
let Projects disabled on old Repos (migration)
6543 Apr 26, 2020
eeb0d4b
fix lint
6543 Apr 26, 2020
c44cf5b
Merge branch 'master' into kanban_board
6543 Apr 27, 2020
aceae47
Merge branch 'master' into kanban_board
adelowo Apr 27, 2020
311494d
Merge branch 'master' of github.com:go-gitea/gitea into kanban_board
adelowo Apr 27, 2020
1b32f58
add tests for Projects
adelowo Apr 28, 2020
31db0fc
update copyright year
adelowo Apr 28, 2020
d745b5b
Merge branch 'master' of github.com:go-gitea/gitea into kanban_board
adelowo Apr 28, 2020
edb2602
remove debug printing
adelowo Apr 28, 2020
6c75e70
Merge branch 'master' into kanban_board
6543 Apr 28, 2020
8928a0d
dont use x.AllCols.Update
6543 Apr 28, 2020
6c4a933
update fixtures, add link checks
6543 Apr 29, 2020
f487f9b
correct fixtures & test
6543 Apr 29, 2020
5bbf647
fix
6543 Apr 29, 2020
b88499d
add files repo4
6543 Apr 29, 2020
e1effa1
Merge branch 'master' into kanban_board
6543 Apr 29, 2020
bd40920
this was no comment & translate
6543 Apr 29, 2020
36acce9
Apply suggestions from code review
6543 Apr 29, 2020
1981eb4
Merge branch 'master' into kanban_board
6543 Apr 29, 2020
4fb2106
Merge branch 'master' into kanban_board
6543 Apr 30, 2020
3a7181c
repoID can be NUL & is Inexed; Only RepoistoryType is valid
6543 May 1, 2020
0001370
Rename ProjectType Names & count functions take care of ProjectType
6543 May 1, 2020
5eba1c9
Merge branch 'master' into kanban_board
6543 May 1, 2020
e0eab4d
fix TEST
6543 May 1, 2020
15e39d0
change ProjectType names - follow convention
6543 May 1, 2020
8eed2bb
use only id and check access via repo on router functions
6543 May 1, 2020
1d06f8e
Merge branch 'master' into kanban_board
6543 May 1, 2020
d46ce37
fix tests
6543 May 1, 2020
87ed7fe
fix fixtures
6543 May 1, 2020
4a78ffc
dont forget the migrations
6543 May 1, 2020
d34c4ff
Update routers/repo/issue.go
6543 May 2, 2020
675f52f
Merge branch 'master' into kanban_board
6543 May 2, 2020
9fc9ffb
Merge branch 'master' into kanban_board
adelowo May 2, 2020
3d1570f
kanban: add a minimum height for droppable area of project boards (#9)
kevans91 May 3, 2020
61d7445
Merge branch 'master' into kanban_board
adelowo May 3, 2020
b95fb53
Merge branch 'master' into kanban_board
6543 May 4, 2020
b27c731
adds some css to cards and board-cards (see commit description for mo…
May 4, 2020
ee404ec
hide template field for project edit
6543 May 4, 2020
5da0cd9
Merge branch 'master' into kanban_board
6543 May 4, 2020
8fa6ccb
Merge branch 'master' into kanban_board
6543 May 5, 2020
52691e3
Kanban board (#11)
May 5, 2020
4e585b0
Fixes error 500 when trying to create a User or na Organization project
DefinitelyADev May 4, 2020
6ab3e4b
Fix for create a User or na Organization project showing
DefinitelyADev May 4, 2020
2fe798b
Revents 7eb8846
DefinitelyADev May 4, 2020
0ee13f7
Revert "Fix for create a User or na Organization project showing"
DefinitelyADev May 5, 2020
686b2f2
Fixes "When creating and issue, after selecting a project the project…
DefinitelyADev May 5, 2020
e3b4ed3
Merge branch 'master' into kanban_board
6543 May 5, 2020
aed1a56
Merge branch 'master' into kanban_board
6543 May 9, 2020
a0dd2f3
Merge branch 'master' into kanban_board
6543 May 9, 2020
957412a
Added English localization for filter_projects (#13)
May 9, 2020
7399758
Merge branch 'master' into kanban_board
6543 May 10, 2020
888dc65
Merge branch 'master' into kanban_board
6543 May 11, 2020
17b3a7a
Merge branch 'master' into kanban_board
adelowo May 12, 2020
c346d22
Merge branch 'master' into kanban_board
adelowo May 14, 2020
d7ff2bd
Merge branch 'master' into kanban_board
6543 May 15, 2020
b1421c7
Merge branch 'master' into kanban_board
lunny May 16, 2020
72c6b51
Merge branch 'master' into kanban_board
adelowo May 16, 2020
3620489
Merge branch 'master' into kanban_board
6543 May 19, 2020
21ace77
Merge branch 'master' into kanban_board
6543 May 20, 2020
19b348a
Merge branch 'master' into kanban_board
6543 May 20, 2020
e889da7
Merge branch 'master' into kanban_board
6543 May 20, 2020
cf8e783
Merge branch 'master' into kanban_board
6543 May 21, 2020
4442037
Merge branch 'master' into kanban_board
6543 May 23, 2020
a67aedf
Merge branch 'master' into kanban_board
adelowo May 24, 2020
13bf054
Merge branch 'master' into kanban_board
6543 May 29, 2020
6f49097
delete Projects and related correctly on RepoDeletion -> adapt change…
6543 May 29, 2020
e4a48f9
fix lint
6543 May 29, 2020
1ababcf
Merge branch 'master' into kanban_board
6543 May 29, 2020
55b9431
Merge branch 'master' into kanban_board
6543 Jun 1, 2020
140e5bd
fix lint
6543 Jun 2, 2020
8b99fdc
Merge branch 'master' into kanban_board
6543 Jun 2, 2020
52db2e1
Merge branch 'master' into kanban_board
6543 Jun 3, 2020
4eef37c
Apply suggestions from code review
6543 Jun 3, 2020
50852ce
Apply suggestions from code review
6543 Jun 3, 2020
b1794de
Merge branch 'master' into kanban_board
6543 Jun 3, 2020
cbeba0f
Update web_src/js/features/projects.js
6543 Jun 4, 2020
f1e6b80
Merge branch 'master' into kanban_board
6543 Jun 4, 2020
07b9597
add silverwind tweeks
6543 Jun 4, 2020
4c7072e
add Index
6543 Jun 4, 2020
fecec01
Update web_src/js/features/projects.js
6543 Jun 4, 2020
caa40cb
stylistic tweak
6543 Jun 4, 2020
aeab76c
Merge branch 'master' into kanban_board
6543 Jun 8, 2020
d483e96
as per @zeripath
6543 Jun 16, 2020
c06ba4b
Apply suggestions from code review
6543 Jun 16, 2020
2a8a987
suggestions form code review
6543 Jun 16, 2020
c74f87a
a nit
6543 Jun 16, 2020
3992506
Merge branch 'master' into kanban_board
6543 Jun 16, 2020
d7fb97b
BugFix: save ClosedDate on Close
6543 Jun 16, 2020
dce5077
Merge branch 'master' into kanban_board
6543 Jun 18, 2020
16e44e8
Merge branch 'master' into kanban_board
adelowo Jun 18, 2020
50cb3b0
Merge branch 'master' into kanban_board
6543 Jun 19, 2020
08be11c
Merge branch 'master' into kanban_board
6543 Jun 22, 2020
474a965
Merge branch 'master' into kanban_board
6543 Jun 23, 2020
0f4a7ad
Merge branch 'master' into kanban_board
6543 Jun 24, 2020
a3eae2a
new PROJECT section in Settings
6543 Jun 24, 2020
b11c766
Merge branch 'master' into kanban_board
6543 Jun 25, 2020
9221a39
correct Default field
6543 Jun 25, 2020
67692d7
fix DeleteProj Bug
6543 Jun 25, 2020
0d11332
Merge branch 'master' into kanban_board
6543 Jun 26, 2020
391f760
rename ProjectBorardType enum
6543 Jun 26, 2020
7f1d860
apply @silverwind suggestions
6543 Jul 1, 2020
dbe5b96
Merge branch 'master' into kanban_board
6543 Jul 1, 2020
5810613
Merge branch 'master' into kanban_board
adelowo Jul 4, 2020
6bf75ee
Merge branch 'master' into kanban_board
6543 Jul 4, 2020
24731ef
Merge branch 'master' into kanban_board
zeripath Jul 6, 2020
693d8b9
Multiple fixes
zeripath Jul 6, 2020
59650ee
Update web_src/js/features/projects.js
6543 Jul 8, 2020
1f25a5a
sort order package.json
6543 Jul 8, 2020
f0101b0
Merge branch 'master' into kanban_board
6543 Jul 8, 2020
429a5c2
complete @silverwind suggestion
6543 Jul 8, 2020
18674e5
rm current unused
6543 Jul 8, 2020
2c55136
Merge branch 'master' into kanban_board
6543 Jul 9, 2020
1749e58
Merge branch 'master' into kanban_board
6543 Jul 10, 2020
9e94db0
Merge branch 'master' into kanban_board
6543 Jul 13, 2020
585ba57
fix lint
6543 Jul 13, 2020
b27415e
project_issues.go -> project_issue.go
6543 Jul 13, 2020
24d6e1e
dedub code
6543 Jul 13, 2020
0c7391a
update Count each in single SQL
6543 Jul 13, 2020
b4432d5
fix lint
6543 Jul 13, 2020
b5e53d0
Apply suggestions from code review
6543 Jul 13, 2020
0f55178
Update ToDo in web_src/js/features/projects.js
6543 Jul 13, 2020
23eed99
Merge branch 'master' into kanban_board
6543 Jul 13, 2020
d6ecb55
Apply suggestions from code review
6543 Jul 14, 2020
c90bd69
Merge branch 'master' into kanban_board
6543 Jul 15, 2020
9a2a583
Merge branch 'master' into kanban_board
adelowo Jul 15, 2020
7a668ff
Merge branch 'master' into kanban_board
6543 Jul 17, 2020
f24c8f5
remove ToDo note and move it as proposal to #12270
6543 Jul 18, 2020
3f435a2
Docs: Update Comparison
6543 Jul 18, 2020
a692b18
Merge branch 'master' into kanban_board
6543 Jul 22, 2020
1d3371e
if backend respond with an error move issue to old bord back
6543 Jul 22, 2020
5cc83dc
Merge branch 'master' into kanban_board
6543 Jul 23, 2020
2bb433c
Merge branch 'master' into kanban_board
techknowlogick Jul 23, 2020
d851614
Merge branch 'master' into kanban_board
6543 Jul 24, 2020
6fa272a
as per @lunny
6543 Jul 24, 2020
5438aee
Merge branch 'master' into kanban_board
6543 Jul 25, 2020
c884473
fix templates/repo/projects/view.tmpl
6543 Jul 25, 2020
aa0fa1d
Merge branch 'master' into kanban_board
6543 Jul 27, 2020
127d69b
EditBoardTitle: dont reload
6543 Jul 27, 2020
1b191e0
Merge branch 'master' into kanban_board
6543 Jul 27, 2020
d171fa3
Merge branch 'master' into kanban_board
adelowo Jul 28, 2020
4d6d0b7
Merge branch 'master' into kanban_board
adelowo Jul 30, 2020
adba43f
Merge branch 'master' into kanban_board
6543 Jul 31, 2020
7f2059e
Merge branch 'master' into kanban_board
6543 Aug 1, 2020
3519413
addapt #12383
6543 Aug 1, 2020
7c54db3
Merge branch 'master' into kanban_board
6543 Aug 1, 2020
26d850d
Merge branch 'master' into kanban_board
6543 Aug 2, 2020
f058723
Merge branch 'master' into kanban_board
6543 Aug 2, 2020
1fc91cd
Merge branch 'master' into kanban_board
lunny Aug 4, 2020
915ab60
Merge branch 'master' into kanban_board
6543 Aug 4, 2020
a923160
Merge branch 'master' into kanban_board
adelowo Aug 5, 2020
20eed58
Merge branch 'master' into kanban_board
zeripath Aug 7, 2020
4a5ea56
Merge branch 'master' into kanban_board
6543 Aug 8, 2020
ab633e1
Merge branch 'master' into kanban_board
6543 Aug 8, 2020
46d5173
Merge branch 'master' into kanban_board
6543 Aug 9, 2020
caa68dc
Merge branch 'master' into kanban_board
zeripath Aug 10, 2020
d3ef729
Merge branch 'master' into kanban_board
6543 Aug 11, 2020
b840634
Merge branch 'master' into kanban_board
6543 Aug 11, 2020
60c99f8
Merge branch 'master' into kanban_board
6543 Aug 12, 2020
6fcdc41
Merge branch 'master' into kanban_board
6543 Aug 13, 2020
a470c71
Merge branch 'master' into kanban_board
adelowo Aug 13, 2020
a70ff2f
Merge branch 'master' into kanban_board
6543 Aug 13, 2020
ea14063
Merge branch 'master' into kanban_board
6543 Aug 13, 2020
fcec5f3
Merge branch 'master' into kanban_board
adelowo Aug 14, 2020
a48f839
Merge branch 'master' into kanban_board
6543 Aug 16, 2020
16af23e
Merge branch 'master' into kanban_board
techknowlogick Aug 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ globals:
Dropzone: false
u2fApi: false
hljs: false
Sortable: false
adelowo marked this conversation as resolved.
Show resolved Hide resolved

rules:
no-unused-vars: [error, {args: all, argsIgnorePattern: ^_, varsIgnorePattern: ^_, ignoreRestSiblings: true}]
Expand Down
2 changes: 2 additions & 0 deletions custom/conf/app.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ REPO_INDEXER_EXCLUDE =
[admin]
; Disallow regular (non-admin) users from creating organizations.
DISABLE_REGULAR_ORG_CREATION = false
; Enable the kanban board feature system wide.
ENABLE_KANBAN_BOARD = true
; Default configuration for email notifications for users (user configurable). Options: enabled, onmention, disabled
DEFAULT_EMAIL_NOTIFICATIONS = enabled

Expand Down
39 changes: 39 additions & 0 deletions models/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,45 @@ func (err ErrLabelNotExist) Error() string {
return fmt.Sprintf("label does not exist [label_id: %d, repo_id: %d]", err.LabelID, err.RepoID)
}

// __________ __ __
// \______ \_______ ____ |__| ____ _____/ |_ ______
// | ___/\_ __ \/ _ \ | |/ __ \_/ ___\ __\/ ___/
// | | | | \( <_> ) | \ ___/\ \___| | \___ \
// |____| |__| \____/\__| |\___ >\___ >__| /____ >
// \______| \/ \/ \/

// ErrProjectNotExist represents a "ProjectNotExist" kind of error.
type ErrProjectNotExist struct {
ID int64
RepoID int64
}

// IsErrProjectNotExist checks if an error is a ErrProjectNotExist
func IsErrProjectNotExist(err error) bool {
_, ok := err.(ErrProjectNotExist)
return ok
}

func (err ErrProjectNotExist) Error() string {
return fmt.Sprintf("projects does not exist [id: %d, repo_id: %d]", err.ID, err.RepoID)
}

type ErrProjectBoardNotExist struct {
BoardID int64
RepoID int64
ProjectID int64
}

// IsErrProjectBoardNotExist checks if an error is a ErrProjectBoardNotExist
func IsErrProjectBoardNotExist(err error) bool {
_, ok := err.(ErrProjectBoardNotExist)
return ok
}

func (err ErrProjectBoardNotExist) Error() string {
return fmt.Sprintf("project board does not exist [board_id: %d, repo_id: %d, project_id: %d]", err.BoardID, err.RepoID, err.ProjectID)
}

// _____ .__.__ __
// / \ |__| | ____ _______/ |_ ____ ____ ____
// / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
Expand Down
34 changes: 25 additions & 9 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,19 @@ type Issue struct {
Labels []*Label `xorm:"-"`
MilestoneID int64 `xorm:"INDEX"`
Milestone *Milestone `xorm:"-"`
Priority int
AssigneeID int64 `xorm:"-"`
Assignee *User `xorm:"-"`
IsClosed bool `xorm:"INDEX"`
IsRead bool `xorm:"-"`
IsPull bool `xorm:"INDEX"` // Indicates whether is a pull request or not.
PullRequest *PullRequest `xorm:"-"`
NumComments int
Ref string
ProjectID int64 `xorm:"INDEX"`
// If 0, then it has not been added to a specific board in the project
ProjectBoardID int64 `xorm:"INDEX"`
Project *Project `xorm:"-"`
Priority int
AssigneeID int64 `xorm:"-"`
Assignee *User `xorm:"-"`
IsClosed bool `xorm:"INDEX"`
IsRead bool `xorm:"-"`
IsPull bool `xorm:"INDEX"` // Indicates whether is a pull request or not.
PullRequest *PullRequest `xorm:"-"`
NumComments int
Ref string

DeadlineUnix timeutil.TimeStamp `xorm:"INDEX"`

Expand Down Expand Up @@ -258,6 +262,13 @@ func (issue *Issue) loadAttributes(e Engine) (err error) {
}
}

if issue.ProjectID > 0 && issue.Project == nil {
issue.Project, err = getProjectByRepoID(e, issue.RepoID, issue.ProjectID)
if err != nil && !IsErrProjectNotExist(err) {
return fmt.Errorf("getProjectByRepoID [repo_id: %d, milestone_id: %d]: %v", issue.RepoID, issue.ProjectID, err)
}
}

if err = issue.loadAssignees(e); err != nil {
return
}
Expand Down Expand Up @@ -1247,6 +1258,7 @@ type IssuesOptions struct {
PosterID int64
MentionedID int64
MilestoneID int64
ProjectID int64
Page int
PageSize int
IsClosed util.OptionalBool
Expand Down Expand Up @@ -1327,6 +1339,10 @@ func (opts *IssuesOptions) setupSession(sess *xorm.Session) {
sess.And("issue.milestone_id=?", opts.MilestoneID)
}

if opts.ProjectID > 0 {
sess.And("issue.project_id=?", opts.ProjectID)
}

switch opts.IsPull {
case util.OptionalBoolTrue:
sess.And("issue.is_pull=?", true)
Expand Down
49 changes: 49 additions & 0 deletions models/issue_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ const (
CommentTypeLock
// Unlocks a previously locked issue
CommentTypeUnlock
// Project changed
CommentTypeProject
// Project board changed
CommentTypeProjectBoard
)

// CommentTag defines comment tag type
Expand All @@ -107,6 +111,10 @@ type Comment struct {
Issue *Issue `xorm:"-"`
LabelID int64
Label *Label `xorm:"-"`
OldProjectID int64
ProjectID int64
OldProject *Project `xorm:"-"`
Project *Project `xorm:"-"`
OldMilestoneID int64
MilestoneID int64
OldMilestone *Milestone `xorm:"-"`
Expand Down Expand Up @@ -314,6 +322,32 @@ func (c *Comment) LoadLabel() error {
return nil
}

// LoadProject if comment.Type is CommentTypeProject, then load project.
func (c *Comment) LoadProject() error {

if c.OldProjectID > 0 {
var oldProject Project
has, err := x.ID(c.OldProjectID).Get(&oldProject)
if err != nil {
return err
} else if has {
c.OldProject = &oldProject
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else OldProject is deleted and cant be loaded so leave it nil

}

if c.ProjectID > 0 {
var project Project
has, err := x.ID(c.ProjectID).Get(&project)
if err != nil {
return err
} else if has {
c.Project = &project
}
}

return nil
}

// LoadMilestone if comment.Type is CommentTypeMilestone, then load milestone
func (c *Comment) LoadMilestone() error {
if c.OldMilestoneID > 0 {
Expand Down Expand Up @@ -505,6 +539,8 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
LabelID: LabelID,
OldMilestoneID: opts.OldMilestoneID,
MilestoneID: opts.MilestoneID,
OldProjectID: opts.OldProjectID,
ProjectID: opts.ProjectID,
RemovedAssignee: opts.RemovedAssignee,
AssigneeID: opts.AssigneeID,
CommitID: opts.CommitID,
Expand Down Expand Up @@ -659,6 +695,17 @@ func createLabelComment(e *xorm.Session, doer *User, repo *Repository, issue *Is
})
}

func createProjectComment(e *xorm.Session, doer *User, repo *Repository, issue *Issue, oldProjectID, projectID int64) (*Comment, error) {
return createComment(e, &CreateCommentOptions{
Type: CommentTypeProject,
Doer: doer,
Repo: repo,
Issue: issue,
OldProjectID: oldProjectID,
ProjectID: projectID,
})
}

func createMilestoneComment(e *xorm.Session, doer *User, repo *Repository, issue *Issue, oldMilestoneID, milestoneID int64) (*Comment, error) {
return createComment(e, &CreateCommentOptions{
Type: CommentTypeMilestone,
Expand Down Expand Up @@ -781,6 +828,8 @@ type CreateCommentOptions struct {
DependentIssueID int64
OldMilestoneID int64
MilestoneID int64
OldProjectID int64
ProjectID int64
AssigneeID int64
RemovedAssignee bool
OldTitle string
Expand Down
2 changes: 2 additions & 0 deletions models/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ var migrations = []Migration{
NewMigration("add task table and status column for repository table", addTaskTable),
// v100 -> v101
NewMigration("update migration repositories' service type", updateMigrationServiceTypes),
// v101 -> v102
NewMigration("add projects info to repository table", addProjectsInfo),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Add ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NewMigration("add projects info to repository table", addProjectsInfo),
NewMigration("Add projects info to repository table", addProjectsInfo),

}

// Migrate database to current version
Expand Down
91 changes: 91 additions & 0 deletions models/migrations/v101.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package migrations

import (
"code.gitea.io/gitea/modules/timeutil"

"github.com/go-xorm/xorm"
)

func addProjectsInfo(x *xorm.Engine) error {

sess := x.NewSession()
defer sess.Close()

type (
ProjectType uint8
ProjectBoardType uint8
)

type Project struct {
ID int64 `xorm:"pk autoincr"`
Title string `xorm:"INDEX NOT NULL"`
Description string `xorm:"TEXT"`
RepoID int64 `xorm:"NOT NULL"`
CreatorID int64 `xorm:"NOT NULL"`
IsClosed bool `xorm:"INDEX"`
NumIssues int
NumClosedIssues int

BoardType ProjectBoardType
Type ProjectType

ClosedDateUnix timeutil.TimeStamp
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
}

if err := sess.Sync2(new(Project)); err != nil {
return err
}

type Comment struct {
OldProjectID int64
ProjectID int64
}

if err := sess.Sync2(new(Comment)); err != nil {
return err
}

type Repository struct {
NumProjects int `xorm:"NOT NULL DEFAULT 0"`
NumClosedProjects int `xorm:"NOT NULL DEFAULT 0"`
NumOpenProjects int `xorm:"-"`
}

if err := sess.Sync2(new(Repository)); err != nil {
return err
}

type Issue struct {
ProjectID int64 `xorm:"INDEX"`
ProjectBoardID int64 `xorm:"INDEX"`
}

if err := sess.Sync2(new(Issue)); err != nil {
return err
}

type ProjectBoard struct {
ID int64 `xorm:"pk autoincr"`
ProjectID int64 `xorm:"INDEX NOT NULL"`
Title string
RepoID int64 `xorm:"INDEX NOT NULL"`

// Not really needed but helpful
CreatorID int64 `xorm:"NOT NULL"`

CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
}

if err := sess.Sync2(new(ProjectBoard)); err != nil {
return err
}

return sess.Commit()
}
9 changes: 2 additions & 7 deletions models/migrations/v96.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,8 @@ func deleteOrphanedAttachments(x *xorm.Engine) error {
return err
}

_, err := sess.ID(attachment.ID).NoAutoCondition().Delete(attachment)
_, err := x.ID(attachment.ID).NoAutoCondition().Delete(attachment)
return err
})

if err != nil {
return err
adelowo marked this conversation as resolved.
Show resolved Hide resolved
}

return sess.Commit()
return err
}
2 changes: 2 additions & 0 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ func init() {
new(OAuth2AuthorizationCode),
new(OAuth2Grant),
new(Task),
new(Project),
new(ProjectBoard),
)

gonicNames := []string{"SSL", "UID"}
Expand Down
Loading