-
Notifications
You must be signed in to change notification settings - Fork 21
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
[GH-47] [FIX] Agenda item number should get updated if the items of the agenda are deleted #88
Conversation
Codecov Report
@@ Coverage Diff @@
## master #88 +/- ##
==========================================
- Coverage 26.03% 21.19% -4.84%
==========================================
Files 7 7
Lines 315 453 +138
==========================================
+ Hits 82 96 +14
- Misses 216 339 +123
- Partials 17 18 +1
Continue to review full report at Codecov.
|
|
||
_, appErr = p.API.CreatePost(&model.Post{ | ||
if today.Year() <= formattedDate.Year() && today.YearDay() < formattedDate.YearDay() { | ||
return responsef("We don't support re-queuing future items, only available for present and past items.") |
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.
I think you should make it more short. Something like Re-queing future items are not supported.
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.
Sure, thanks.
// Default to town square if there is no current channel (i.e., if Mattermost has not yet loaded) | ||
if (!currentChannel) { | ||
currentChannel = await Client4.getChannelByName(currentTeamId, 'town-square'); |
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.
Might be best to move the town-square
into a variable. I remember this pattern being followed in some of the other plugins. @mickmister what do you suggest ?
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.
If we are using a post dropdown item to requeue this agenda item, Mattermost has indeed loaded and we can assume currentChannel
is already a valid channel. We don't need this if block
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.
All right.
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.
Great work @sanjaydemansol 👍
I have some requests regarding the implementation, and removing code related to other PRs
<select | ||
name='format' | ||
value={this.state.dateFormat} | ||
onChange={this.handleDateFormat} | ||
style={{height: '35px', border: '1px solid #ced4da'}} | ||
className='form-select' | ||
> | ||
<option value='Jan 2'>{'Month_day'}</option> | ||
<option value='2 Jan'>{'day_Month'}</option> | ||
<option value='1 2'>{'month_day'}</option> | ||
<option value='2 1'>{'day_month'}</option> | ||
<option value='2006 1 2'>{'year_month_day'}</option> | ||
|
||
</select> |
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.
Is this code supposed to be for a different PR?
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.
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.
@sanjaydemansol, I'd prefer them as separate PR's in the future so we can view the code in isolation to the requested issue.
registry.registerPostDropdownMenuAction('Re-queue', (params) => { | ||
store.dispatch(requeueItem(params)); | ||
}); |
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.
We should only show this if the post has an agenda item right? We can use the third argument to registerPostDropdownMenuAction here.
Is it feasible to read the post's message and determine that way? We may not have the channel's agenda settings readily available. We may need to start putting something in the post's props to signal that this post is an agenda item if this isn't possible.
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.
we could make channel's agenda settings readily available but 2/5 in my opinion we should go with your other suggestion i.e props in message. It would solve multiple issues like in current implementation we can't locate agenda messages if user change hashtag format multiple times. Also, backwards compatibility could be added after this.
I am not sure if that's possible, would be great if we could store something like this in props:
{ isAgendaItem:true, hastagDateFormat: "dd/mm/yy", hashtagPrefix:"myprefix", eventDate:"isoDate" }
@mickmister thoughts?
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.
@sanjaydemansol Yeah in the props we can do something like:
{
"agendaSettings": {
"hasftagDateFormat": "dd/mm/yy",
"hashtagPrefix": "myprefix",
"eventDate": "isoDate"
}
}
Then we just need to check post.props.agendaSettings
. If that's not in the props, don't show the requeue button.
What is the eventDate
you're thinking of? Is that something we'll need to keep up to date in the post's props? When will we reference the props instead of the channel's agenda settings and vise versa?
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.
It will be the date the even is supposed to happen on, since hashtag format may be changed any time. Also user may change format after scheduling a meeting rendering old items unparsable. Ex, #1_2_2021 could mean any of two dates. So, either we must have old hashtag format(which was used at the time of creation of this hashtag) or better eventDate
.
// Default to town square if there is no current channel (i.e., if Mattermost has not yet loaded) | ||
if (!currentChannel) { | ||
currentChannel = await Client4.getChannelByName(currentTeamId, 'town-square'); |
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.
If we are using a post dropdown item to requeue this agenda item, Mattermost has indeed loaded and we can assume currentChannel
is already a valid channel. We don't need this if block
export function requeueItem(itemId) { | ||
return async (dispatch, getState) => { | ||
const command = `/agenda requeue ${itemId}`; |
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.
What is itemId
? It seems requeueItem
is called like this:
registry.registerPostDropdownMenuAction('Re-queue', (params) => {
store.dispatch(requeueItem(params));
});
which would mean params
is an itemId
?
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.
Will the user ever run /agenda requeue
manually? If not, we should use an http endpoint for this feature and create a slash command. If the user would use this command manually, what would they supply for the itemId
?
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.
Sure will refactor params
to itemId
.
Made /agenda requeue
to support future options like
/agenda requeue all
# meeting canceled, I want to requeue all items to next meeting.
/agenda requeue last
# requeue last items
/agenda requeue last n
# requeue last n items
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.
Okay if this is the case, then maybe we should have a /agenda requeue item (itemId)
command, and use that for the current programmatic case. Also what is itemId
? Is it the post ID? Let's use postId
as the identifier instead of itemId
if this is the case. And so we would also change the command to /agenda requeue post (postId)
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.
Right, will change it to postId
and change command as well.
@@ -138,7 +138,7 @@ func TestPlugin_GenerateHashtag(t *testing.T) { | |||
jsonMeeting, err := json.Marshal(tt.args.meeting) | |||
tAssert.Nil(err) | |||
api.On("KVGet", tt.args.meeting.ChannelID).Return(jsonMeeting, nil) | |||
got, err := mPlugin.GenerateHashtag(tt.args.meeting.ChannelID, tt.args.nextWeek, -1) | |||
got, err := mPlugin.GenerateHashtag(tt.args.meeting.ChannelID, tt.args.nextWeek, -1, false, time.Now().Weekday()) // last parameter doesn't matter unless requeue |
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.
Can we change the last parameter to not rely on time.Now()
. Tests should have completely static data if possible. The comment here can be removed too.
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.
Not sure about the best way to do same, since go lang doesn't support default values for parameters.
any ideas?
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.
Just use some random hardcoded day as the test data, and assert expected output based on that static input
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.
yes, did same in new PR.
return responsef("We don't support re-queuing future items, only available for present and past items.") | ||
} | ||
|
||
hashtag, error := p.GenerateHashtag(args.ChannelId, false, -1, true, formattedDate.Weekday()) |
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.
hashtag, error := p.GenerateHashtag(args.ChannelId, false, -1, true, formattedDate.Weekday()) | |
hashtag, err := p.GenerateHashtag(args.ChannelId, false, -1, true, formattedDate.Weekday()) |
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.
Okay.
} | ||
return &model.CommandResponse{Text: fmt.Sprintf("Item has been Re-queued to %v", hashtag), ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL} |
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.
We should use responsef
here instead of &model.CommandResponse
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.
sure, will update.
prefix = matchGroups[1] | ||
hashtagDateFormat = strings.TrimSpace(matchGroups[2]) | ||
} else { | ||
return "", ParsedMeetingMessage{}, responsef("Error 267") |
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.
What is Error 267
?
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.
Will make it friendly @maisnamrajusingh @mickmister .
} | ||
|
||
var ( | ||
messageRegexFormat = regexp.MustCompile(fmt.Sprintf(`(?m)^#### #%s(?P<date>.*) ([0-9]+)\) (?P<message>.*)?$`, prefix)) |
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.
Can this string be defined as a constant at the top of the file?
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.
sure.
I accidentally reviewed the code for requeueing items because that is the majority of the PR. Please remove any code not related to changing the existing meeting items. |
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.
Blocking until the re-queue changes have been removed
@sanjaydemansol, can you pull the code into 3 separate PRs, one for each issue? #66, #12, and #47. |
Co-authored-by: Michael Kochell <[email protected]>
@hanzei hii, you added the invalid label but i don't understand the label is for Dev or Qa, should i need to test this PR? |
@dipak-demansol No, there is nothing to test here |
Summary
Fixes #47
Now, Whenever we add new agenda item. Plugin searches for old messages for that hashtag.
If some item is missing(deleted), it fixes numbering for all items.
Testing
Ensure that the agenda plugin is installed and enabled.
Go to a channel header and edit the agenda settings to update the prefix and
Use command /agenda queue to queue at least 3 items as following:
/agenda queue item 1
/agenda queue item 2
/agenda queue item 3
Click on the agenda hashtag to open up the agenda list on the RHS.
On the RHS, click the post menu for item 1 (or the first item that was queued) and delete the agenda item.
Ensure that now there are only 2 items for that agenda hashtag: item 2 and item 3 on the RHS.
Add a new agenda item: /agenda queue new item.
Click on the hashtag to refresh the RHS.
Outcome: The RHS has 3 agenda items numbered 1), 2) and 3)
Ticket Link
#47