Repository navigation
[indexPatterns] remove support for time patterns - #12158
Conversation
|
@jbudz do we need to do anything for migration in this PR? We're removing support for the |
|
Perhaps we should also reject importing index patterns that are no longer supported? |
|
Talked about this with @jbudz and @tylersmalley, Created #12242 to track. Thoughts @epixa? |
59d3053 to
dc36344
Compare
dc36344 to
a437d62
Compare
|
Is there any documentation on how to migrate saved objects from one index pattern to another? If so, can we link to it in the warning in your second screenshot? |
|
I think we can also make the following changes:
|
| @@ -1,3 +1,3 @@ | |||
| export { getFieldCapabilities } from './field_capabilities'; | |||
| export { resolveTimePattern } from './resolve_time_pattern'; | |||
| export { createNoMatchingIndicesError, isNoMatchingIndicesError } from './errors'; | |||
There was a problem hiding this comment.
Can we remove isNoMatchingIndicesError from lib/errors.js?
There was a problem hiding this comment.
The function was used more in the past, but I didn't remove it because it's used to ensure that convertEsIndexNotFoundError() is producing the right errors. Open to other solutions there and removing this if you have ideas. I would just much rather export isNoMatchingIndicesError than the ERR_NO_MATCHING_INDICES constant.
There was a problem hiding this comment.
Sorry, can you point me to where it's used? I grepped src for "isNoMatchingIndicesError" and didn't see any hits.
There was a problem hiding this comment.
| } | ||
|
|
||
| sessionStorage.set(HISTORY_STORAGE_KEY, [...previousIds, indexPattern.id]); | ||
| notify.warning( |
There was a problem hiding this comment.
I don't think we should tightly couple application logic (whether things should be displayed) with view logic (how things are displayed). In the vein, I think it makes sense to uncouple this module from notify and kbnUrl. Then the caller would have the option of surfacing the message via notifications, inside of an InfoPanel, or in some other part of the UI, depending on what makes the most sense in the given context.
From there, we probably don't need to dictate the precise notification message. The caller should be responsible for determining how to communicate information to the user, again based on the context. At that point, we're left with what I see as the main concern of this module, which is determining whether the message should be displayed at all, based on our flag and persistence rules. This will simplify the code and the unit tests significantly.
So I'd rename this module to be is_unsupported_time_pattern and have it return true or false. What do you think?
There was a problem hiding this comment.
I definitely agree about separating concerns, but indexPattern.isUnsupportedTimePattern() already exists and is responsible for determining if this logic should execute as well as if we should show the warning on the edit page.
This module used to be implemented in the caller, and the caller was responsible for determining if the unsupported index pattern should trigger a warning, but in an effort to make it more testable I pulled it out into a module that is purely responsible for determining if we should call notify.warning() or not.
All that said, I'm not fond of how much stubbing is necessary to test this module and would be interested in other ways you think this could be broken up to make that less necessary. At the end of the day though, I'm pretty sure we are going to have to stub the browser storage if we're going to test how this or any other module interacts with session storage, and we're going to have to stub notify for the same reason... Open to other suggestions though.
There was a problem hiding this comment.
Maybe we just need a different name. What do you think of my idea of making this module's single responsibility to be to check our flag and persistence rules? Then we'd end up with something like this:
import { BoundToConfigObjProvider } from 'ui/bound_to_config_obj';
export function IsUserAwareOfUnsupportedTimePatternProvider(Private, $injector) {
const BoundToConfigObj = Private(BoundToConfigObjProvider);
const sessionStorage = $injector.get('sessionStorage');
const HISTORY_STORAGE_KEY = 'indexPatterns:warnAboutUnsupportedTimePatterns:history';
const FLAGS = new BoundToConfigObj({
enabled: '=indexPatterns:warnAboutUnsupportedTimePatterns'
});
return function isUserAwareOfUnsupportedTimePattern(indexPattern) {
// The user's disabled the notification. They know about it.
if (!FLAGS.enabled) {
return true;
}
// We've already told the user.
const previousIds = sessionStorage.get(HISTORY_STORAGE_KEY) || [];
if (previousIds.includes(indexPattern.id)) {
return true;
}
// Let's store this for later, so we don't tell the user multiple times.
sessionStorage.set(HISTORY_STORAGE_KEY, [...previousIds, indexPattern.id]);
return false;
};
}And in index_pattern.js, we'd use it like this:
if (indexPattern.isUnsupportedTimePattern()) {
if (!isUserAwareOfUnsupportedTimePattern(indexPattern)) {
notify.warning(
'Support for time-intervals has been removed. ' +
`View the ["${indexPattern.id}" index pattern in management](` +
kbnUrl.getRouteHref(indexPattern, 'edit') +
') for more information.'
);
}
}…s/remove-time-patterns
…s/remove-time-patterns
21c78c1 to
c5aed80
Compare
|
Can we add this to the breaking changes asciidoc? Also thoughts on a adding a docs migration process to the meta issue? We tell users to re-create the index pattern, but there isn't much guidance in the case of porting field formatters and scripted fields. |
jbudz
left a comment
There was a problem hiding this comment.
Code LGTM.
Re the UX, thoughts on removing the timeout or only setting it as viewed in session storage after OK has been pressed? I ask because I missed the message the first time around and had to go incognito to find it.
Other than that, breaking change docs and then this LGTM
|
@jbudz we've decided to disable the warning by default until we have a method for editing index patterns, but I totally agree with the notion of only dismissing the warning when the user clicks "OK", I too missed the warning several times. I'll get this in the breaking changes doc though, since users won't be able to create index patterns like this anymore. |
|
... LGTM after. |
|
Can you update the description to reflect where this landed? |
* [indexPatterns] remove support for time patterns * Revert "[indexPatterns] remove support for time patterns" This reverts commit 4263e37. * [indexPatterns] remove ability to create time-based patterns * [indexPattern/routes] fix export of routes for stub * [Storage] export Storage class for testing * [indexPatterns/unsupportedTimePatterns] add tests * [indexPatterns] focus warning check module * [indexPatterns/tests] fix method name * add metion of this change to migration docs * disable warnings by default until we have a migration tool * prevent the warning from disapearing * fix grammar * enabled warnings in the tests
Part of #12242
Summary: