Skip to content
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

removes angular from fieldFormatts #17581

Merged
merged 8 commits into from
Apr 12, 2018

Conversation

ppisljar
Copy link
Member

@ppisljar ppisljar commented Apr 5, 2018

  • Angular dependency is removed from field formatts (pretty much just removing the provider wrapper)
  • FieldFormatterRegistry is refactored to not depend on angular

@ppisljar ppisljar added WIP Work in progress Feature:Visualizations Generic visualization features (in case no more specific feature label is available) v7.0.0 v6.4.0 labels Apr 5, 2018
function init() {
config.watch('format:defaultTypeMap', parseDefaultTypeMap);
}
this._config.subscribe(({ key, newValue }) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

@spalger: i am not sure why the watch was used here and i couldn't get this subscribe to fire ... do we need this ? if so does it look correct ? when would we need to unsubscribe ?

Copy link
Contributor

@spalger spalger Apr 5, 2018

Choose a reason for hiding this comment

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

It is called whenever the uiSettings change, seems to be working when I test it:

image

when would we need to unsubscribe ?

That's a good question... I don't think we need to unsubscribe since the fieldFormatsRegistry is never torn down, but I'm concerned how that will work with tests, especially since the uiSettingsClient is currently stubbed out for each test https://github.com/elastic/kibana/blob/master/src/ui/public/test_harness/test_harness.js#L33-L49

Copy link
Contributor

Choose a reason for hiding this comment

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

How about we add this as another method on the chrome object, like https://github.com/elastic/kibana/blob/master/src/ui/public/chrome/api/ui_settings.js#L12-L14, and then stub it out in the tests just like we do for the uiSettings client. Then I'll prioritize migrating the uiSettings and fieldFormats services over to the new platform once we have that plumbing in place.

@elasticmachine
Copy link
Contributor

💔 Build Failed

createSomeFormat(FieldFormat)
));
},
this._config = chrome.getUiSettingsClient();
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it used to be the config service, but now that this class is using the uiSettings client can we reflect that in the property naming? this._uiSettings?


beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
Vis = Private(VisProvider);
AggType = Private(AggTypesAggTypeProvider);
AggConfig = Private(VisAggConfigProvider);
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
fieldFormat = Private(RegistryFieldFormatsProvider);
Copy link
Contributor

Choose a reason for hiding this comment

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

If we move the fieldFormat registry to be like the uiSettings client, we'll want to keep the fieldFormat = chrome.getFieldFormatsRegistry() at this point so that it gets the unique registry for this test.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

return { settings: stubUiSettings.getAll() };
}
// stub the UiSettingsClient
if (chrome.getUiSettingsClient.restore) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This check is only necessary if we are calling this logic multiple times.

@ppisljar ppisljar force-pushed the ang/removeAngularFieldFormatts branch 2 times, most recently from a8b7e0b to d4a8411 Compare April 9, 2018 23:00
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💔 Build Failed

@ppisljar ppisljar force-pushed the ang/removeAngularFieldFormatts branch from c621654 to 69814df Compare April 10, 2018 17:00
@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@ppisljar ppisljar removed the WIP Work in progress label Apr 10, 2018
@ppisljar ppisljar changed the title WIP: removes angular from fieldFormatts removes angular from fieldFormatts Apr 10, 2018
Copy link
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

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

Looking good, just a couple lame naming asks

init();
}
});
export const registryFieldFormats = new FieldFormatRegistry();
Copy link
Contributor

Choose a reason for hiding this comment

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

registryFieldFormats seems backwards, can we please just call this fieldFormats like we do nearly everywhere we use it?

name: 'fieldFormats',
index: ['id'],
group: ['fieldType'],
class FieldFormatRegistry extends IndexedArray {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should move this into ui/field_formats/field_formats.js. IMO this isn't really a registry, and that's fine but we might as well keep it next to the rest of the field formats code.

Copy link
Member Author

Choose a reason for hiding this comment

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

that folder doesn't exist so i'll leave it where it is for now

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@thomasneirynck thomasneirynck removed their request for review April 11, 2018 20:23
@timroes timroes added the chore label Apr 12, 2018
@@ -5,23 +5,22 @@ import { VisProvider } from 'ui/vis';
import { AggTypesAggTypeProvider } from 'ui/agg_types/agg_type';
import { VisAggConfigProvider } from 'ui/vis/agg_config';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';
Copy link
Contributor

Choose a reason for hiding this comment

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

Just use import { fieldFormats as fieldFormat } then we can get rid of the const fieldFormat = fieldFormats in this file ... (or use search and replace :D)

const getConfig = (...args) => config.get(...args);
const self = this;
let defaultMap;
this._uiSettings.subscribe(({ key, newValue }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder whether we maybe should introduce a subscribeTo('key', (newVal) => {}) to UiSettingsClient, since it seems for me like most people who want to subscribe want to subscribe to specific changes in the long run, and all just having that if statement then. @spalger

Though just a thought nothing to change in this PR.

Copy link
Contributor

@timroes timroes left a comment

Choose a reason for hiding this comment

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

LGTM, if Spencer approves the way test harness is handled.

@ppisljar ppisljar merged commit adabbf3 into elastic:master Apr 12, 2018
ppisljar added a commit to ppisljar/kibana that referenced this pull request Apr 12, 2018
@ppisljar ppisljar deleted the ang/removeAngularFieldFormatts branch April 12, 2018 12:31
@elasticmachine
Copy link
Contributor

💔 Build Failed

@ppisljar ppisljar restored the ang/removeAngularFieldFormatts branch September 26, 2018 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Feature:Visualizations Generic visualization features (in case no more specific feature label is available) review v6.4.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants