add subcomands for notifications #283

Closed
khmarbaise wants to merge 7 commits from khmarbaise/tea:issue-243-add_subcomands_for_notifications into main
Member

Fix #243

Signed-off-by: Karl Heinz Marbaise kama@soebes.de

Fix #243 Signed-off-by: Karl Heinz Marbaise <kama@soebes.de>
khmarbaise added 1 commit 2020-12-08 19:45:02 +00:00
add subcomands for notifications
Fix #243

Signed-off-by: Karl Heinz Marbaise <kama@soebes.de>
Some checks failed
continuous-integration/drone/pr Build is failing
ce4d69ece9
khmarbaise reviewed 2020-12-08 19:45:49 +00:00
Dismissed
@ -0,0 +1,49 @@
// Copyright 2020 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.
Author
Member

Is this the way to go with common code from cmd/... ? Or should that put into cmd/notifications/ ?

Is this the way to go with common code from cmd/... ? Or should that put into cmd/notifications/ ?
noerw marked this conversation as resolved
noerw added the
kind
feature
label 2020-12-08 19:55:53 +00:00
khmarbaise added 1 commit 2020-12-08 19:59:46 +00:00
Added missing comment on exported function.
Some checks failed
continuous-integration/drone/pr Build is failing
8ce46fe569
khmarbaise added 1 commit 2020-12-08 20:06:37 +00:00
Fixed exported function comments.
Signed-off-by: Karl Heinz Marbaise <kama@soebes.de>
All checks were successful
continuous-integration/drone/pr Build is passing
eb8fd52023
noerw requested changes 2020-12-08 20:08:44 +00:00
Dismissed
@ -0,0 +16,4 @@
Name: "ls",
Aliases: []string{"list"},
Usage: "List notifications....",
Description: `List notification....`,
Member
- 	Usage:       "List notifications....",
+ 	Usage:       "List notifications",
```diff - Usage: "List notifications....", + Usage: "List notifications", ```
noerw marked this conversation as resolved
@ -0,0 +19,4 @@
Description: `List notification....`,
Action: RunNotificationsList,
Flags: append([]cli.Flag{
&cli.BoolFlag{
Member

Please move these common flags into cmd/flags/flags.go as NotificationFlags

Please move these common flags into `cmd/flags/flags.go` as `NotificationFlags`
Author
Member

Good idea not even realized that. Thanks.

Good idea not even realized that. Thanks.
noerw marked this conversation as resolved
@ -0,0 +22,4 @@
&cli.BoolFlag{
Name: "all",
Aliases: []string{"a"},
Usage: "show all notifications of related gitea instance",
Member
- 			Usage:   "show all notifications of related gitea instance",
+ 			Usage:   "Show notifications across all your repos instead of the current repo only",
```diff - Usage: "show all notifications of related gitea instance", + Usage: "Show notifications across all your repos instead of the current repo only", ```
noerw marked this conversation as resolved
@ -0,0 +26,4 @@
},
&cli.StringFlag{
Name: "state",
Usage: "Filter by milestone state (all|open|closed)",
Member
  • Are valid states really called all/open/closed? all/read/unread?
  • Doesn't this flag duplicate functionality from the subcommands read/unread?
  • s/milestone/notification
- Are valid states really called all/open/closed? all/read/unread? - Doesn't this flag duplicate functionality from the subcommands read/unread? - s/milestone/notification
Author
Member

Yes of course.

Yes of course.
noerw marked this conversation as resolved
@ -0,0 +14,4 @@
// CmdNotificationsPinned represents a sub command of notifications to list pinned notifications
var CmdNotificationsPinned = cli.Command{
Name: "pinned",
Aliases: []string{"pin"},
Member

"pin" makes it sound like a verb, not a read list-command.
I'd drop this alias

"pin" makes it sound like a verb, not a read list-command. I'd drop this alias
Author
Member

What about with an alias pd instead?

What about with an alias `pd` instead?
noerw marked this conversation as resolved
@ -0,0 +21,4 @@
listOpts := flags.GetListOptions(ctx)
if listOpts.Page == 0 {
listOpts.Page = 1
}
Member

@6453 ?

@6453 ?
Author
Member

If you take a look into flags.GetListOptions(ctx)

func GetListOptions(ctx *cli.Context) gitea.ListOptions {
	page := ctx.Int("page")
	limit := ctx.Int("limit")
	if limit != 0 && page == 0 {
		page = 1
	}
	return gitea.ListOptions{
		Page:     page,
		PageSize: limit,
	}
}
If you take a look into `flags.GetListOptions(ctx)` ``` func GetListOptions(ctx *cli.Context) gitea.ListOptions { page := ctx.Int("page") limit := ctx.Int("limit") if limit != 0 && page == 0 { page = 1 } return gitea.ListOptions{ Page: page, PageSize: limit, } } ```
Author
Member

After I've played a little bit with it which means removed the lines from notification_list.go I've not seen a difference. May I have missed a thing... Can someone enlighten me ?

After I've played a little bit with it which means removed the lines from notification_list.go I've not seen a difference. May I have missed a thing... Can someone enlighten me ?
Member

I don't understand why, but these lines are needed still, without I get no results for tea notif read

I don't understand why, but these lines are needed still, without I get no results for `tea notif read`
Owner

in short: it enforces paggination

in short: it enforces paggination
6543 marked this conversation as resolved
khmarbaise added 1 commit 2020-12-08 20:31:13 +00:00
Integrated review comments.
Signed-off-by: Karl Heinz Marbaise <kama@soebes.de>
All checks were successful
continuous-integration/drone/pr Build is passing
29212a5d3e
khmarbaise requested review from noerw 2020-12-09 19:44:07 +00:00
noerw approved these changes 2020-12-09 21:45:41 +00:00
Dismissed
6543 reviewed 2020-12-09 22:09:30 +00:00
Dismissed
6543 requested changes 2020-12-09 22:10:14 +00:00
Dismissed
@ -0,0 +23,4 @@
Name: "all",
Aliases: []string{"a"},
Usage: "show all notifications of related gitea instance",
},
Owner

@khmarbaise can you move task.ListNotifications back to cmd/notification module

I dont see a reason to add cli & flag dependency into task module

@khmarbaise can you move task.ListNotifications back to cmd/notification module I dont see a reason to add **cli** & **flag** dependency into task module
Author
Member

So making a file notifications_list.go which contains that. I will do and change it accordingly.

So making a file `notifications_list.go` which contains that. I will do and change it accordingly.
Author
Member

Done as suggested.

Done as suggested.
khmarbaise marked this conversation as resolved
khmarbaise added 1 commit 2020-12-10 07:01:56 +00:00
Moved notifications_list from task into cmd/notifications
Signed-off-by: Karl Heinz Marbaise <kama@soebes.de>
All checks were successful
continuous-integration/drone/pr Build is passing
d350600d81
khmarbaise requested review from 6543 2020-12-10 07:02:54 +00:00
khmarbaise force-pushed issue-243-add_subcomands_for_notifications from d350600d81 to 85c3001e49 2020-12-10 07:06:29 +00:00 Compare
6543 reviewed 2020-12-10 09:53:11 +00:00
Dismissed
@ -79,2 +43,3 @@
print.NotificationsList(news, flags.GlobalOutputValue, ctx.Bool("all"))
func runNotificationsDetails(ctx *cli.Context) error {
log.Fatal("Not yet implemented.")
Owner

I would print use --help to see all options

I would print `use --help to see all options`
6543 reviewed 2020-12-10 10:09:18 +00:00
Dismissed
Owner

I dont get the usage of pin, unpin, read subcommand

they only list stuff as list does?

I expect pin to actualy pin a notification ...

same vor unpin & read

the list should print out the notif id to this actions specific or with or,

  • --all flag for read/pin mark all unread as read
  • --all flag for unpin mark all pined as read

unread should only be used to mark a specific one as "unread"

I dont get the usage of pin, unpin, read subcommand they only list stuff as `list` does? I expect pin to actualy pin a notification ... same vor unpin & read the list should print out the notif id to this actions specific or with or, - `--all` flag for read/pin mark all unread as read - `--all` flag for unpin mark all pined as read unread should only be used to mark a specific one as "unread"
Owner

@khmarbaise can you resolve conflicts?

If you need help just shout out on discord to me

@khmarbaise can you resolve conflicts? If you need help just shout out on discord to me
6543 added this to the v0.7.0 milestone 2020-12-14 11:39:43 +00:00
noerw added the
status/needs-feedback
label 2020-12-15 11:03:33 +00:00
khmarbaise force-pushed issue-243-add_subcomands_for_notifications from 85c3001e49 to abd32a7074 2020-12-16 22:02:00 +00:00 Compare
6543 modified the milestone from v0.7.0 to v0.8.0 2021-03-10 20:29:55 +00:00
Owner

-> #386

-> #386
6543 closed this pull request 2021-08-16 13:22:59 +00:00
Some checks are pending
continuous-integration/drone/pr Build is failing
check-and-test / check-and-test (pull_request)
Required

Pull request closed

Sign in to join this conversation.
No description provided.