-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Warn if the title is a duplicate #10321
Warn if the title is a duplicate #10321
Conversation
jenkins test this |
2454c0b
to
b5c3fbf
Compare
Does this PR implement the same functionality for Saved Searches and Visualizations? I didn't do a thorough code review but noticed some dashboard files changed but not others that jumped out as Discover or Visualization changes. I'm not sure the message is clear enough. It tells them that there already is a dashboard with this title. But it could be more clear about what will happen when I click Save dashboard. It's going to create another dashboard with the same name. Maybe something like this? But I need to think through the scenarios where I think this is going to appear.
|
Hmmm, my query is not correct as it returns matches on substrings. Trying to figure out how to create an exact match query... |
7cd051a
to
e3aedf3
Compare
jenkins test this (looks like the build was aborted) |
c7540dd
to
76b9bdb
Compare
Hmm, latest build failure is related to saving, but not sure it's due to this PR:
I'll rebase |
973b6c5
to
f661370
Compare
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.
Functionality looks great! Just had some minor code suggestions.
err.message === OVERWRITE_REJECTED || | ||
err.message === SAVE_DUPLICATE_REJECTED)) { | ||
return; | ||
} |
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 break this up to make it a little more readable?
if (err) {
if (err.message === OVERWRITE_REJECTED) {
return;
}
if (err.message === SAVE_DUPLICATE_REJECTED) {
return;
}
}
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.
ehhh, I don't love suggestion, I'd look at that and be like, why not just combine them into an ||?
how about this new variation as a compromise?
@@ -3,7 +3,7 @@ | |||
In previous versions of Kibana, changing the name of a {{savedObject.getDisplayName()}} would make a copy with the new name. Use the 'Save as a new {{savedObject.getDisplayName()}}' checkbox to do this now. | |||
</div> | |||
<label> | |||
<input type="checkbox" ng-model="savedObject.copyOnSave" ng-checked="savedObject.copyOnSave"> | |||
<input type="checkbox" data-test-subj="saveAsNewCheckbox" ng-model="savedObject.copyOnSave" ng-checked="savedObject.copyOnSave"> |
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 put these attributes on multiple lines?
<input
type="checkbox"
data-test-subj="saveAsNewCheckbox"
ng-model="savedObject.copyOnSave"
ng-checked="savedObject.copyOnSave"
>
expect(countOfDashboards).to.equal(2); | ||
}); | ||
|
||
bdd.it('Does not warn when saving a duplicate title that remains unchanged for an existing dashboard', async function() { |
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 had a hard time parsing this description... how does this sound to you: "Does not warn when you save an existing dashboard with the title it already has, and that title is a duplicate"? Does that describe this test accurately?
expect(isConfirmOpen).to.equal(false); | ||
}); | ||
|
||
bdd.it('Warns when saving a duplicate title that remains unchanged when Save as New Dashboard is checked', async function() { |
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.
And here, how about: "Warns you when you Save as New Dashboard, and the title is a duplicate"?
test/functional/index.js
Outdated
'intern/dojo/node!./apps/dashboard', | ||
'intern/dojo/node!./status_page' | ||
// 'intern/dojo/node!./status_page' |
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.
Haha I do this all the time! 😄
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.
This time it was actually intentional :) Trying to reduce the time for a build because I was having a very tough time figuring out what the issue was (turns out it was a delay between saving a new dashboard and reloading the url to point to the newly saved dashboard).
PageObjects.common.debug('Storing time with dashboard: ' + on); | ||
const saveAsNewCheckbox = await PageObjects.common.findTestSubject('saveAsNewCheckbox'); | ||
const checked = await saveAsNewCheckbox.getProperty('checked'); | ||
if (checked === true && on === false || |
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 be made terser?
if (checked !== isAlreadyChecked) {
PageObjects.common.debug('Flipping save as new checkbox');
await saveAsNewCheckbox.click();
}
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.
Doh! Good catch, much clearer. :)
@@ -276,8 +319,19 @@ export default class DashboardPage { | |||
await PageObjects.header.setAbsoluteRange(fromTime, toTime); | |||
} | |||
|
|||
async storeTimeWithDashboard(on) { | |||
async saveAsNewCheckbox(on) { |
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 rename this to setSaveAsNewCheckBox(checked)
to make it clear what the action is that we're taking?
PageObjects.common.debug('Storing time with dashboard: ' + on); | ||
const saveAsNewCheckbox = await PageObjects.common.findTestSubject('saveAsNewCheckbox'); | ||
const checked = await saveAsNewCheckbox.getProperty('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.
Can we rename this to isAlreadyChecked
?
0eae3c7
to
c1e2f59
Compare
* @param error {Error} the error | ||
* @return {boolean} | ||
*/ | ||
function getShouldSuppressExpectedError(error) { |
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.
How about renaming this to isErrorNonFatal
? This way the name of function helps us assign meaning to the error without specifying what we should do about it. If for some reason we decide to return the error instead of suppressing it, this function will still be useful and won't need to be renamed.
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 that's a little confusing too because it's not an error at all, it's a user response. The whole flow is a bit awkward, and it'd be better if we just stopped using the confirmModalPromise to begin with, but I don't want to do that refactor now.
I have no better suggestion, so sgtm for now.
a0c8896
to
a0c5daf
Compare
2d3b1b6
to
75d9e46
Compare
@cjcenizal or @LeeDr, any more comments on this PR? I think I addressed everything. |
I just tried a case with saving Visualizations where it didn't work, probably because of the characters I used?
Obviously this is an odd case, and I only tried this one visualization name so far. So I don't know exactly what cases work and which don't. Are we comparing analyzed names which would remove those chars? I'll keep testing a bit 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.
LGTM!
Also if I name an object But combinations of special characters and letter always seems to work correctly. And I also tested that the duplication check is only within that object type. So I can create a saved search, visualization, and dashboard all with the name If the special character cases aren't easy to solve, I'd still give a LGTM. |
add more tests.
Add a comment and rename one of the variables to make the distinction clearer.
…r the page has navigated away
75d9e46
to
7bc0268
Compare
Unfortunately it's not easy to fix @LeeDr. If I have a visualization name
Nothing is returned, presumably because it strips special characters. If this issue were resolved: #10348 then we could get around this shortcoming. For the short term, I think we should acknowledge it as a limitation, but move forward. |
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.
LGTM Thanks / for - checking # on the special ! chars :-)
Backports PR #10321 **Commit 1:** Warn if the title is a duplicate * Original sha: b0aa0b8 * Authored by Stacey Gammon <gammon@elastic.co> on 2017-02-13T18:07:23Z **Commit 2:** warn when copyOnSave is checked. add a test * Original sha: ee42002 * Authored by Stacey Gammon <gammon@elastic.co> on 2017-02-14T14:20:37Z **Commit 3:** update message * Original sha: c90c8ae * Authored by Stacey Gammon <gammon@elastic.co> on 2017-02-14T14:24:50Z **Commit 4:** fix tests * Original sha: 5ec1a92 * Authored by Stacey Gammon <gammon@elastic.co> on 2017-02-14T15:04:14Z **Commit 5:** Fix issues with substring matching add more tests. * Original sha: 4335e9e * Authored by Stacey Gammon <gammon@elastic.co> on 2017-02-14T18:54:58Z **Commit 6:** make case insensitive and return matching title * Original sha: 8881739 * Authored by Stacey Gammon <gammon@elastic.co> on 2017-02-14T19:34:04Z **Commit 7:** Fix bug caused by subtle difference between this.type and type Add a comment and rename one of the variables to make the distinction clearer. * Original sha: f4011ce * Authored by Stacey Gammon <gammon@elastic.co> on 2017-02-16T16:31:13Z **Commit 8:** add debug messages. * Original sha: 2d44889 * Authored by Stacey Gammon <gammon@elastic.co> on 2017-02-16T18:05:03Z **Commit 9:** fix tests again * Original sha: 3212c91 * Authored by Stacey Gammon <gammon@elastic.co> on 2017-02-16T22:10:25Z **Commit 10:** uncomment out tests * Original sha: 1f2cb28 * Authored by Stacey Gammon <gammon@elastic.co> on 2017-02-16T22:12:06Z **Commit 11:** more debug messages * Original sha: 807b190 * Authored by Stacey Gammon <gammon@elastic.co> on 2017-02-17T02:09:37Z **Commit 12:** save more screenshots * Original sha: 3d025e9 * Authored by Stacey Gammon <gammon@elastic.co> on 2017-02-17T02:34:29Z **Commit 13:** Need to wait till save finishes or the page may redirect the url after the page has navigated away * Original sha: de00e24 * Authored by Stacey Gammon <gammon@elastic.co> on 2017-02-17T14:01:22Z **Commit 14:** address code review comments * Original sha: 7bc0268 * Authored by Stacey Gammon <gammon@elastic.co> on 2017-02-17T17:28:34Z
Fixes #10073