Skip to content

[indexPatterns] remove support for time patterns - #12158

Merged
spalger merged 18 commits into
elastic:masterfrom
spalger:index-patterns/remove-time-patterns
Jun 14, 2017
Merged

spalger merged 18 commits into
elastic:masterfrom
spalger:index-patterns/remove-time-patterns

Conversation

@spalger

@spalger spalger commented Jun 3, 2017 •

Copy link
Copy Markdown
Contributor

Part of #12242

Summary:

image

image

@spalger spalger added the WIP Work in progress label Jun 3, 2017
@spalger

spalger commented Jun 6, 2017

Copy link
Copy Markdown
Contributor Author

@jbudz do we need to do anything for migration in this PR? We're removing support for the intervalName field in the index-pattern type, but that shouldn't have any BWC implications. What will be an issue for people is the saved objects they have that are using time pattern based index patterns. Maybe we should add a warning message to 5.5...

@spalger

spalger commented Jun 6, 2017

Copy link
Copy Markdown
Contributor Author

Perhaps we should also reject importing index patterns that are no longer supported?

@spalger

spalger commented Jun 7, 2017 •

Copy link
Copy Markdown
Contributor Author

Talked about this with @jbudz and @tylersmalley, Created #12242 to track. Thoughts @epixa?

@spalger
spalger force-pushed the index-patterns/remove-time-patterns branch 4 times, most recently from 59d3053 to dc36344 Compare June 8, 2017 00:52
@spalger
spalger force-pushed the index-patterns/remove-time-patterns branch from dc36344 to a437d62 Compare June 8, 2017 02:23
@spalger
spalger requested review from cjcenizal and tylersmalley June 8, 2017 02:25
@spalger spalger removed the WIP Work in progress label Jun 8, 2017
@spalger spalger added :Management Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// release_note:breaking and removed :Management Team:Core Platform Core services: plugins, logging, config, saved objects, http, ES client, i18n, etc t// labels Jun 8, 2017
@cjcenizal

Copy link
Copy Markdown
Contributor

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?

@cjcenizal

Copy link
Copy Markdown
Contributor

I think we can also make the following changes:

@cjcenizal cjcenizal left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome! I love seeing all of this code get tossed. I had one small suggestion and one medium-size suggestion.

@@ -1,3 +1,3 @@
export { getFieldCapabilities } from './field_capabilities';
export { resolveTimePattern } from './resolve_time_pattern';
export { createNoMatchingIndicesError, isNoMatchingIndicesError } from './errors';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove isNoMatchingIndicesError from lib/errors.js?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, can you point me to where it's used? I grepped src for "isNoMatchingIndicesError" and didn't see any hits.

@spalger spalger Jun 12, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

sessionStorage.set(HISTORY_STORAGE_KEY, [...previousIds, indexPattern.id]);
notify.warning(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.'
        );
      }
    }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the suggestion, thanks @cjcenizal

@spalger
spalger force-pushed the index-patterns/remove-time-patterns branch from 21c78c1 to c5aed80 Compare June 12, 2017 22:13

@cjcenizal cjcenizal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@spalger
spalger requested review from ycombinator and removed request for ycombinator June 12, 2017 23:50
@jbudz
jbudz self-requested a review June 13, 2017 18:42
@jbudz

jbudz commented Jun 13, 2017 •

Copy link
Copy Markdown
Contributor

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.
edit: nevermind, I see it now

@jbudz jbudz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@spalger

spalger commented Jun 13, 2017

Copy link
Copy Markdown
Contributor Author

@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.

@jbudz

jbudz commented Jun 13, 2017

Copy link
Copy Markdown
Contributor

...we removed the ability to create index patterns define a specific date-pattern small nit on the breaking change docs, should "define" be "from"?

LGTM after.

@spalger
spalger merged commit 1119414 into elastic:master Jun 14, 2017
@epixa

epixa commented Jun 14, 2017

Copy link
Copy Markdown
Contributor

Can you update the description to reflect where this landed?

@spalger
spalger deleted the index-patterns/remove-time-patterns branch June 14, 2017 01:38
patrykkopycinski pushed a commit to patrykkopycinski/kibana that referenced this pull request May 6, 2026
* [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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants