-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Issue 1706: Option to rename tags #2989
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
Conversation
• repurpose RenameFolderModal.styl to RenameModal so it is more generic
| } | ||
| } | ||
|
|
||
| handleConfirmButtonClick (e) { |
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 don't you call this.confirm directly instead of making a whole new method for it?
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.
Thanks for looking it over! Updated.
| <div styleName='header'> | ||
| <div styleName='title'>{i18n.__('Rename Tag')}</div> | ||
| </div> | ||
| <ModalEscButton handleEscButtonClick={(e) => this.handleCloseButtonClick(e)} /> |
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.
Nit. I think handleCloseButtonClick method is not needed here.
You could destructure prop close with const { close } = this.props and do
| <ModalEscButton handleEscButtonClick={(e) => this.handleCloseButtonClick(e)} /> | |
| <ModalEscButton handleEscButtonClick={close} /> |
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.
Fixed in e985f12
| <div styleName='control'> | ||
| <input styleName='control-input' | ||
| placeholder={i18n.__('Tag Name')} | ||
| ref='name' |
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 it would be better to use callback refs as it's likely that this will be deprecated in a future React version. Please use ref={ref => this.nameInput=ref} & add this.nameInput = null to the constructor & update the references from this.refs.name to the new property.
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.
Fixed in b1d62c8
| placeholder={i18n.__('Tag Name')} | ||
| ref='name' | ||
| value={this.state.name} | ||
| onChange={(e) => this.handleChange(e)} |
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.
Nit. Please use .bind(this) for onChange, onKeyDown and onClick so you can write e.g. onChange={this.handleChange}.
But this requires this.handleChange = this.handleChange.bind(this) in the constructor - we could probably also use class properties but I think that's not used in the code base.
I'm also not sure if it's supported by the Babel setup - I haven't checked.
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.
Fixed in ce5d4ac
|
Looks great. Just some smaller inline comments & one point would be awesome if you could add. If you're selecting a tag and then rename it - the location is wrong and no notes are displayed. By adding the following code to your import { hashHistory } from 'react-router' // add to imports
renameTag (tag, updatedTag) {
Promise
.all(notes.map(note => dataApi.updateNote(note.storage, note.key, note)))
.then(() => { /* ... */ })
.then(() => {
if (window.location.hash.includes(tag)) {
hashHistory.replace(`/tags/${updatedTag}`)
}
this.props.close()
})
} |
…er via the TagSelect component
|
Thanks for the detailed feedback @AWolf81! Great tip with your comment above as it exposed an issue with the topbar tag |
|
Branch has been brought up to date with the latest master |
|
Just a friendly ping on this @ZeroX-DG 😀 |
|
Hi @khaliqgant , sorry for the late response. Can you change the color of the modal so that it will match the theme? For example, here is how it look on monokai theme Also a note can't have duplicated tags but if you do like this, the bug will appear:
|
|
Thanks for the feedback @ZeroX-DG.
Updated with 9a2dcbc
Updated with 4efbe08 and added in an error message to assist the user as seen in the video: |
|
@khaliqgant This is not quite what I wanted, I think it's better to merge tag into the existing tag if there's any. If the user want to rename tag |
|
@khaliqgant ping |
|
@khaliqgant ping 2 |
|
Close due to inactivity |
* allow a tag to be renamed and update all notes that use that tag • repurpose RenameFolderModal.styl to RenameModal so it is more generic * call handleConfirmButtonClick directly instead of sending through a confirm method * better name for method to confirm the rename * use close prop instead of a new method * use callback ref instead of legacy string refs * bind the handleChange in the constructor to allow for direct function assignment * update the tag in the URL upon change * use the eventEmitter to update the tags in the SnippetNoteDetail header via the TagSelect component * respect themes when modal is opened * show error message when trying to rename to an existing tag * lint fix, const over let * add missing letter * fix routing and add merge warning dialog * fix space-before-parens lint error * change theming * add check if tag changed Co-authored-by: Khaliq Gant <khaliqgant@gmail.com>




Description
Tags at present moment cannot be renamed. This PR reuses the "RenameFolderModal" to allow a user to rename a tag that is selected.
This update also renames the "RenameFolderModal.styl" to "RenameModal.styl" since the RenameTagModal.js uses that style as well and I felt it was clearer to use a more generic name. This is my first PR to the project (be kind! 😬) so I wasn't sure if that is something the maintainers would agree with or not.
Issue fixed
Fixes #1706
Type of changes
Checklist: