-
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-66] Improve date format selection UI. Fixes #66 #86
Changes from 4 commits
3395a30
69ef21a
066a6ef
177bcb9
40c77e0
fc2be62
dbca404
eec7368
080b4d8
13865c0
2edb8c8
d6dad99
0156f0b
e407281
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,9 +55,9 @@ func TestPlugin_GenerateHashtag(t *testing.T) { | |
meeting: &Meeting{ | ||
ChannelID: "QA", | ||
Schedule: []time.Weekday{time.Wednesday}, | ||
HashtagFormat: "{{Jan02}}", | ||
HashtagFormat: "{{Jan 2}}", | ||
}}, | ||
want: "#" + assertNextWeekdayDate(time.Wednesday, true).Format("Jan02"), | ||
want: "#" + strings.ReplaceAll(assertNextWeekdayDate(time.Wednesday, true).Format("Jan 2"), " ", "_"), | ||
wantErr: false, | ||
}, | ||
{ | ||
|
@@ -67,9 +67,9 @@ func TestPlugin_GenerateHashtag(t *testing.T) { | |
meeting: &Meeting{ | ||
ChannelID: "QA Backend", | ||
Schedule: []time.Weekday{time.Monday}, | ||
HashtagFormat: "QA-{{January 02 2006}}", | ||
HashtagFormat: "QA_{{January 02 2006}}", | ||
}}, | ||
want: "#QA-" + assertNextWeekdayDate(time.Monday, true).Format("January 02 2006"), | ||
want: "#QA_" + strings.ReplaceAll(assertNextWeekdayDate(time.Monday, true).Format("January 02 2006"), " ", "_"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like a big drive of certain changes involve avoiding dashes and using underscores instead, which is an opinionated approach that is not backwards compatible with existing agenda settings. Why is this change required? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
wantErr: false, | ||
}, | ||
{ | ||
|
@@ -81,7 +81,7 @@ func TestPlugin_GenerateHashtag(t *testing.T) { | |
Schedule: []time.Weekday{time.Monday}, | ||
HashtagFormat: "{{January 02 2006}}.vue", | ||
}}, | ||
want: "#" + assertNextWeekdayDate(time.Monday, false).Format("January 02 2006") + ".vue", | ||
want: "#" + strings.ReplaceAll(assertNextWeekdayDate(time.Monday, false).Format("January 02 2006"), " ", "_") + ".vue", | ||
wantErr: false, | ||
}, | ||
{ | ||
|
@@ -93,7 +93,7 @@ func TestPlugin_GenerateHashtag(t *testing.T) { | |
Schedule: []time.Weekday{time.Monday}, | ||
HashtagFormat: "React {{January 02 2006}} Born", | ||
}}, | ||
want: "#React " + assertNextWeekdayDate(time.Monday, false).Format("January 02 2006") + " Born", | ||
want: "#React " + strings.ReplaceAll(assertNextWeekdayDate(time.Monday, false).Format("January 02 2006"), " ", "_") + " Born", | ||
wantErr: false, | ||
}, | ||
{ | ||
|
@@ -105,7 +105,7 @@ func TestPlugin_GenerateHashtag(t *testing.T) { | |
Schedule: []time.Weekday{time.Monday}, | ||
HashtagFormat: "January 02 2006 {{January 02 2006}} January 02 2006", | ||
}}, | ||
want: "#January 02 2006 " + assertNextWeekdayDate(time.Monday, false).Format("January 02 2006") + " January 02 2006", | ||
want: "#January 02 2006 " + strings.ReplaceAll(assertNextWeekdayDate(time.Monday, false).Format("January 02 2006"), " ", "_") + " January 02 2006", | ||
wantErr: false, | ||
}, | ||
{ | ||
|
@@ -117,7 +117,7 @@ func TestPlugin_GenerateHashtag(t *testing.T) { | |
Schedule: []time.Weekday{time.Monday}, | ||
HashtagFormat: "{{ January 02 2006 }}", | ||
}}, | ||
want: "#" + assertNextWeekdayDate(time.Monday, false).Format("January 02 2006"), | ||
want: "#" + strings.ReplaceAll(assertNextWeekdayDate(time.Monday, false).Format("January 02 2006"), " ", "_"), | ||
wantErr: false, | ||
}, | ||
{ | ||
|
@@ -129,7 +129,7 @@ func TestPlugin_GenerateHashtag(t *testing.T) { | |
Schedule: []time.Weekday{time.Monday}, | ||
HashtagFormat: "{{ Mon Jan _2 }}", | ||
}}, | ||
want: "#" + assertNextWeekdayDate(time.Monday, false).Format("Mon Jan _2"), | ||
want: "#" + strings.ReplaceAll(assertNextWeekdayDate(time.Monday, false).Format("Mon Jan _2"), " ", "_"), | ||
wantErr: false, | ||
}, | ||
} | ||
|
@@ -176,7 +176,7 @@ func TestPlugin_GetMeeting(t *testing.T) { | |
}, | ||
want: &Meeting{ | ||
Schedule: []time.Weekday{time.Thursday}, | ||
HashtagFormat: "Short-{{ Jan02 }}", | ||
HashtagFormat: "Short_{{ Jan 2 }}", | ||
ChannelID: "#short.name.channel", | ||
}, | ||
wantErr: false, | ||
|
@@ -190,7 +190,7 @@ func TestPlugin_GetMeeting(t *testing.T) { | |
}, | ||
want: &Meeting{ | ||
Schedule: []time.Weekday{time.Thursday}, | ||
HashtagFormat: "Very Long Chann-{{ Jan02 }}", | ||
HashtagFormat: "Very Long Chann_{{ Jan 2 }}", | ||
ChannelID: "#long.name.channel", | ||
}, | ||
wantErr: false, | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -17,8 +17,9 @@ export default class MeetingSettingsModal extends React.PureComponent { | |||||
super(props); | ||||||
|
||||||
this.state = { | ||||||
hashtag: '{{Jan02}}', | ||||||
hashtagPrefix: 'Prefix', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we have a way for the user to define their own date format that is used, like the feature currently works? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, as per issue. IMO it is end goal to limit that. |
||||||
weekdays: [1], | ||||||
dateFormat: '1-2', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great catch, seems like I missed this while separating commits, will fix this. |
||||||
}; | ||||||
} | ||||||
|
||||||
|
@@ -28,20 +29,30 @@ export default class MeetingSettingsModal extends React.PureComponent { | |||||
} | ||||||
|
||||||
if (this.props.meeting && this.props.meeting !== prevProps.meeting) { | ||||||
const splitResult = this.props.meeting.hashtagFormat.split('{{');// we know, date Format is preceded by {{ | ||||||
const hashtagPrefix = splitResult[0]; | ||||||
const dateFormat = splitResult[1].substring(0, splitResult[1].length - 2); // remove trailing }} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we trust that Also if it's an existing agenda setting that is made before this PR, do we know that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the new ones, yes. Since we are assigning value from controlled values. |
||||||
// eslint-disable-next-line react/no-did-update-set-state | ||||||
this.setState({ | ||||||
hashtag: this.props.meeting.hashtagFormat, | ||||||
hashtagPrefix, | ||||||
dateFormat, | ||||||
weekdays: this.props.meeting.schedule || [], | ||||||
}); | ||||||
} | ||||||
} | ||||||
|
||||||
handleHashtagChange = (e) => { | ||||||
this.setState({ | ||||||
hashtag: e.target.value, | ||||||
hashtagPrefix: e.target.value, | ||||||
}); | ||||||
} | ||||||
|
||||||
handleDateFormat = (event) => { | ||||||
this.setState({ | ||||||
dateFormat: event.target.value, | ||||||
}); | ||||||
}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we be consistent and use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure, will do that. |
||||||
|
||||||
handleCheckboxChanged = (e) => { | ||||||
const changeday = Number(e.target.value); | ||||||
let changedWeekdays = Object.assign([], this.state.weekdays); | ||||||
|
@@ -62,7 +73,7 @@ export default class MeetingSettingsModal extends React.PureComponent { | |||||
onSave = () => { | ||||||
this.props.saveMeetingSettings({ | ||||||
channelId: this.props.channelId, | ||||||
hashtagFormat: this.state.hashtag, | ||||||
hashtagFormat: `${this.state.hashtagPrefix}{{${this.state.dateFormat}}}`, | ||||||
schedule: this.state.weekdays.sort(), | ||||||
}); | ||||||
|
||||||
|
@@ -118,19 +129,50 @@ export default class MeetingSettingsModal extends React.PureComponent { | |||||
</div> | ||||||
</div> | ||||||
<div className='form-group'> | ||||||
<label className='control-label'>{'Hashtag Format'}</label> | ||||||
<input | ||||||
onChange={this.handleHashtagChange} | ||||||
className='form-control' | ||||||
value={this.state.hashtag ? this.state.hashtag : ''} | ||||||
/> | ||||||
<p className='text-muted pt-1'> {'Hashtag is formatted using the '} | ||||||
<a | ||||||
target='_blank' | ||||||
rel='noopener noreferrer' | ||||||
href='https://godoc.org/time#pkg-constants' | ||||||
>{'Go time package.'}</a> | ||||||
{' Embed a date by surrounding what January 2, 2006 would look like with double curly braces, i.e. {{Jan02}}'} | ||||||
<div style={{display: 'flex'}}> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does setting this value do in this case? It doesn't look like there are any There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, this expands items to fill available free space or shrinks them to prevent overflow. |
||||||
<div | ||||||
className='fifty' | ||||||
style={{padding: '5px'}} | ||||||
> | ||||||
<label className='control-label'>{'Hashtag Prefix'}</label> | ||||||
<input | ||||||
onChange={this.handleHashtagChange} | ||||||
className='form-control' | ||||||
value={this.state.hashtagPrefix ? this.state.hashtagPrefix : ''} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay |
||||||
/> | ||||||
</div> | ||||||
<div | ||||||
className='fifty' | ||||||
style={{padding: '5px'}} | ||||||
> | ||||||
<label className='control-label'>{'Date Format'}</label> | ||||||
<br/> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we able to accomplish this with css instead of using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mickmister removed |
||||||
<select | ||||||
name='format' | ||||||
value={this.state.dateFormat} | ||||||
onChange={this.handleDateFormat} | ||||||
style={{height: '35px', border: '1px solid #ced4da'}} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be done using an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, will move all css to scss. |
||||||
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> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do the values have spaces instead of underscores? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because underscore has special significance for go |
||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This empty line can be removed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure |
||||||
</select> | ||||||
</div> | ||||||
</div> | ||||||
|
||||||
<p className='text-muted pt-1'> | ||||||
<div | ||||||
className='alert alert-warning' | ||||||
role='alert' | ||||||
style={{marginBottom: '3px'}} | ||||||
> | ||||||
{'Prefixes may use underscore'}<code>{'_'}</code>{'.'} {'Other special characters including'} <code>{'-'}</code> {'are not allowed.'} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this a requirement? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
</div> | ||||||
{'Date would be appended to Hashtag Prefix, according to the chosen format.'} | ||||||
</p> | ||||||
</div> | ||||||
</Modal.Body> | ||||||
|
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.
Why did the default change here?
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.
Hashtags with
-
were returning no results for me, after some digging found out:ref
2/5, our plugin should be database agnostic but not sure if I should include these changes in this PR.
@mickmister
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'm not able to reproduce this issue using postgress using
#foo-02
. Is there anything more specific case that causes issues?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.
Case was same, but issue appeared randomly.