Skip to content

Added .get, renamed .getAll as .getRaw, added new .getAll method#7374

Merged
bevacqua merged 12 commits intoelastic:masterfrom
bevacqua:feature/config-get
Jul 7, 2016
Merged

Added .get, renamed .getAll as .getRaw, added new .getAll method#7374
bevacqua merged 12 commits intoelastic:masterfrom
bevacqua:feature/config-get

Conversation

@bevacqua
Copy link
Contributor

@bevacqua bevacqua commented Jun 3, 2016

As pointed out by @Bargs in #7301, the .get method was missing from the server-side settings config module. I took the liberty of also changing .getAll into .getRaw since it returns the entire manifest objects for the settings (includes descriptions, user-provided, and default values), and added a new .getAll implementation where an object of configuration key/value pairs is provided.

Note: .getAll wasn't being used anywhere anyways.

@Bargs
Copy link
Contributor

Bargs commented Jun 8, 2016

What would you say to adding a cache for these settings? One thing that was unexpected/frustrating when I first tried to use this API was that the get methods returned promises. If the entire app is going through this API to make changes, it shouldn't be a problem knowing when to invalidate the cache for a given key.

@bevacqua
Copy link
Contributor Author

bevacqua commented Jun 8, 2016

Sounds good but also would need a hook to learn about changes made directly against the index?

Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably have some tests for these higher level methods.

@Bargs
Copy link
Contributor

Bargs commented Jun 8, 2016

@bevacqua do we still have code that directly accesses the config in the .kibana index? Or are you thinking of user's modifying it themselves outside of Kibana?

@bevacqua
Copy link
Contributor Author

bevacqua commented Jun 8, 2016

I meant users. I was told to trust no one.

@Bargs
Copy link
Contributor

Bargs commented Jun 8, 2016

Haha ok. I think there's a case to be made for users modifying Kibana internal data at their own risk, but it's not a huge deal, I'm ok with leaving it as is if we wanna play it safe.

In that case the code looks good, but I would like to see some tests that exercise those getters at least.

Also one other note, since I am using getAll in the feature/ingest branch, we'll need to keep that in mind depending on which PR gets merged first. It'll probably be yours and you won't have to worry about it, but in the off chance feature/ingest gets in first we'll need to update that usage in this PR.

@Bargs Bargs assigned bevacqua and unassigned Bargs Jun 8, 2016
@bevacqua
Copy link
Contributor Author

bevacqua commented Jun 8, 2016

I'd say block your issue on this one and I'll add tests so we can merge it before you do yours. Can you x-ref them?

@Bargs Bargs mentioned this pull request Jun 8, 2016
@Bargs
Copy link
Contributor

Bargs commented Jun 8, 2016

Yeah left a note on my PR. Like I said, very unlikely that one will be ready first anyways.

@bevacqua
Copy link
Contributor Author

bevacqua commented Jun 27, 2016

@Bargs

  • Added a metric ton of tests
  • Updated your API usage in master (via fba84993)
  • Added .removeMany method
  • Plus the original .get, .getRaw, and .getAll shuffling mentioned in OP

@bevacqua bevacqua assigned Bargs and unassigned bevacqua Jun 27, 2016
@bevacqua
Copy link
Contributor Author

jenkins, test it

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 these tests can be simplified by creating a separate "returns a promise" test that makes this kind of assertion instead of repeating it within each test. This will make each test's description more accurate, make the tests more readable since they will be testing "just one thing", and the tests themselves will be deflated a bit.

describe('#setMany()', () => {
    it('returns a promise', () => {
      const { uiSettings } = instantiate();
      const result = uiSettings.setMany({});
      expect(typeof result.then).to.be('function');
    });

    it('updates a single value in one operation', () => {
      /* ... */
    });

    it('updates several values in one operation', () => {
      /* ... */
    });
  });

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally. Split out assertions into separate tests.

@Bargs
Copy link
Contributor

Bargs commented Jun 30, 2016

jenkins, test it

@bevacqua
Copy link
Contributor Author

@Bargs 🏓 (Ping)

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we know what promise implementation is returned? If so, expect.js's constructor assertion could be used instead of duck typing:

expect(result).to.be.a(Promise);

@Bargs
Copy link
Contributor

Bargs commented Jun 30, 2016

One thing that's not obvious to me from the tests or the documentation is the difference between getRaw and getUserProvided or why I should prefer one over the other. It seems like getUserProvided doesn't merge the config in ES with the defaults, but if that were the case I don't see why the results are returned with nested objects with userValue keys. If getUserProvided only returns user values, couldn't it just return a flat object?

@Bargs
Copy link
Contributor

Bargs commented Jun 30, 2016

Just a suggestion: expect.js's eql method only checks for loose equality. For strict and deep equality checks I usually like to do expect(_.isEqual(result, expected)).to.be.ok(); This might be especially important since some of the tests are dealing with null values.

@Bargs
Copy link
Contributor

Bargs commented Jun 30, 2016

@bevacqua just a few minor questions/comments

@Bargs Bargs assigned bevacqua and unassigned Bargs Jun 30, 2016
@bevacqua
Copy link
Contributor Author

bevacqua commented Jul 4, 2016

@Bargs .getUserProvided() is leveraged by the REST API to respond with what's changed. The defaults aren't resent to the client as they aren't going to change unless the app gets restarted. That function uses the ES model. The .getDefaults() method uses the same model. .getRaw() also uses the same model, merging both user configuration in ES and defaults. Then there's .getAll(), which takes the output from .getRaw() and turns it into key value pairs as you mentioned.

The non-flat methods aren't flat because the metadata is used on the client-side, and to maintain the format for easy merging

@bevacqua
Copy link
Contributor Author

bevacqua commented Jul 5, 2016

Oh, wow, I didn't expect .eql to be that loose.

@Bargs
Copy link
Contributor

Bargs commented Jul 5, 2016

Yeah, it sucks... that's why I'd still like to switch to Chai.

@bevacqua
Copy link
Contributor Author

bevacqua commented Jul 5, 2016

@Bargs Added comments, used .isEqual

@bevacqua bevacqua force-pushed the feature/config-get branch from 3c84c81 to 40d2898 Compare July 5, 2016 14:53
@bevacqua
Copy link
Contributor Author

bevacqua commented Jul 5, 2016

jenkins, test it

1 similar comment
@Bargs
Copy link
Contributor

Bargs commented Jul 5, 2016

jenkins, test it

@Bargs
Copy link
Contributor

Bargs commented Jul 5, 2016

Pending tests passing, LGTM

@Bargs Bargs removed their assignment Jul 5, 2016
@bevacqua bevacqua force-pushed the feature/config-get branch from 40d2898 to 1673b31 Compare July 6, 2016 18:14
@bevacqua
Copy link
Contributor Author

bevacqua commented Jul 6, 2016

jenkins, test it

@bevacqua
Copy link
Contributor Author

bevacqua commented Jul 6, 2016

jenkins, test this

@cjcenizal
Copy link
Contributor

LGTM

@bevacqua bevacqua merged commit 05f6a56 into elastic:master Jul 7, 2016
@epixa epixa added v5.0.0-alpha5 and removed v5.0.0 labels Oct 7, 2016
airow pushed a commit to airow/kibana that referenced this pull request Feb 16, 2017
Added .get, renamed .getAll as .getRaw, added new .getAll method

Former-commit-id: 05f6a56
cee-chen added a commit that referenced this pull request Mar 12, 2024
`v93.2.0`⏩`v93.3.0`

---

## [`v93.3.0`](https://github.com/elastic/eui/releases/v93.3.0)

- Added new `EuiDataGrid` new prop: `cellContext`, an optional object of
additional props passed to the cell render function.
([#7374](elastic/eui#7374))
- `EuiBreadcrumbs`'s `popoverContent` API now accepts a render function
that will be passed a `closePopover` callback, allowing consumers to
close the breadcrumb popover from their popover content
([#7555](elastic/eui#7555))

**Bug fixes**

- Fixed missing animation on native `EuiProgress` bar update
([#7538](elastic/eui#7538))
- Fixed an `EuiDataGrid` bug with `gridStyle.rowClasses`, where custom
consumer classes that began with `euiDataGridRow` would not be correctly
removed/reapplied ([#7549](elastic/eui#7549))
- Fixed a visual `EuiDataGrid` bug where `EuiCheckbox`es within control
columns were not vertically centered within single height rows
([#7549](elastic/eui#7549))
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.

4 participants