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

[add data] prototype for string resources #7156

Closed

Conversation

BigFunger
Copy link
Contributor

@BigFunger BigFunger commented May 9, 2016

Prototype Only

Adds string resources to the application. This allows us to define string resources outside of the views in which they are consumed.

This could also be modified in the future to create an i18n/l10n system.

This strings are stored in a registry that can added to by anywhere in the system.

Moving parts

  • A 'resource' string filter is added
  • A 'string_resources' webpack shim is added. This would need to be imported into any directive that uses string resources.
  • A string_resources.js file is added in src/ui/public. This is where the key/values are defined.

.../add_data_steps/pipeline_setup/string_resources.js

import registry from 'ui/string_resources/registry';

registry.register({
  addData: {
  pipelineSetup: {
    headerTextCallout:
      'Let\'s build a pipeline!'
    ...
  }
}

.../pipeline_setup/index.js

...
import './string_resources';
...

.../views/pipeline_setup.html

...
<!-- Use the resource filter and a dot separated property name to access a string in the resources file -->
<em ng-bind="'addData.pipelineSetup.headerTextCallout' | resource"></em>
...

.../directives/filebeat_wizard.js

...
import 'string-resources'; //webpack shim
...

@BigFunger BigFunger added review discuss Feature:Add Data Add Data and sample data feature on Home labels May 9, 2016
'Let\'s build a pipeline!',

headerText:
'Ingest pipelines are an easy way to modify documents before they\'re indexed in Elasticsearch. ' +
Copy link
Contributor

Choose a reason for hiding this comment

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

Using es6 backticks would eliminate the need for +'s at the end of each line.

@Bargs
Copy link
Contributor

Bargs commented May 9, 2016

I was thinking about it some more, and I think the Angular filter is ok if it remains a thin layer over a plain module that does the real internationalization work down the road. This way we can have the convenience of the filter in Kibana, but other plugins that might use different view technology can still make use of and add to the module.

Along those lines, should we make this pluggable now? I'm thinking plugins should be able to both add and consume resource strings, and the strings should be namespaced with the name of the plugin that added them.

One last thought at the moment. Could/should we combine this with the dynamic doc links module? #6989

@Bargs Bargs assigned BigFunger and unassigned Bargs May 9, 2016
@BigFunger
Copy link
Contributor Author

I moved the strings into a registry and added them to a few more pages to get a better feel for what this would look like across the application.

@BigFunger BigFunger assigned rashidkpc and unassigned BigFunger May 13, 2016
@rashidkpc
Copy link
Contributor

rashidkpc commented May 13, 2016

Why use a filter instead of a directive here?Using {{}} all over the place will cause all of those expression to be dirty checked and the filter to be re-evaluated with every $digest cycle. What about something like

<button
  class="btn btn-primary"
  ng-click="wizard.nextStep()">
  kbn-text="commonButtons.next"
</button>

Interestingly, in the future, you could expand the role of the thing passed to kbn-text to include meta data. You could make it an object instead of a string and supply tooltip and aria values to be added to the element, which would simplify the markup.

@rashidkpc
Copy link
Contributor

Also, much discussion has been had on this subject in this thread: #6515

@rashidkpc
Copy link
Contributor

@epixa your thoughts on the design here would be helpful

@rashidkpc rashidkpc assigned BigFunger and unassigned rashidkpc May 13, 2016
@epixa
Copy link
Contributor

epixa commented May 13, 2016

What's the motivation here in the context of add data?

@Bargs
Copy link
Contributor

Bargs commented May 16, 2016

@epixa this came up during a couple of discussions about in-page documentation for the Add Data wizards (#6851). Ideally the user will be able to use the wizards without getting dumped to outside documentation, so we plan on adding lots of help text to the page.

@debadair told us this help text would be easier for the docs team to review and help manage if it were pulled out into separate string resource files. There are obvious benefits for internationalization down the road as well, but we're not trying to solve that entire problem here. Mainly we're just trying to get static text out of the html templates.

@epixa
Copy link
Contributor

epixa commented May 16, 2016

That makes sense, thanks!

The biggest concern I have is that we're using JS modules as a state management system - simply importing the registry results in an essentially-global, mutable singleton. I recommend at the very least changing ui/string_resources/registry to a function that returns a new registry object, and then we could invoke that function once during setup and expose it through angular's DI system.

I don't think these configurations should be created during runtime, either. Instead, we should put configuration like this inside static configuration files (json or yml) that we then load into memory at startup. This would allow us to develop more tooling around the configuration itself without being coupled to a running instance of Kibana, and it would also mean that we could handle errors in parsing configuration in helpful ways, whereas something like a missing comma in the current implementation would just crash the entire application.

Finally, overall this seems like something that could be handled statically at build time rather than on the client at runtime. This whole implementation would essentially become a devDependency, and there would be no lingering issues with or concerns for performance impacts in production builds.

@Bargs
Copy link
Contributor

Bargs commented May 16, 2016

@epixa @BigFunger perhaps we should chat over zoom or IRC about this. I have a few questions before we dive too deep:

  • How much of this do we want to tackle in the context of Add Data?
  • Is a partial solution worse than no solution at all? Or can we build something that's a step in the right direction without building a full i18n system right now.
  • @debadair this one is for you. Internationalization aside, would your team benefit simply from having text snippets all in one place inside Kibana, rather than scattered throughout html templates? Just wondering how much benefit we'll gain here taking a step towards a better system vs. waiting till we have time to tackle the problem in full.

@srl295
Copy link
Contributor

srl295 commented May 19, 2016

OK, yes we just opened the PR #7247 for issue #6515 - need to combine efforts of course.

@Bargs
Copy link
Contributor

Bargs commented May 20, 2016

Yeah now that I look at that PR and issue, there's a huge amount of overlap. Given that prototyping is already under way in #7247 it seems kinda foolish to reproduce that work here. Unless anyone has a compelling argument to the contrary, I think we should forget about trying to implement some half measure in Add Data that's just going to get thrown away after #6515 is complete.

@epixa
Copy link
Contributor

epixa commented May 20, 2016

No objections here. For now, let's just put the add data help info directly into the templates.

@BigFunger BigFunger closed this Jun 7, 2016
jbudz pushed a commit that referenced this pull request Sep 27, 2023
`v88.3.0`⏩`v88.5.0`

closes #151514

---

## [`88.5.0`](https://github.com/elastic/eui/tree/v88.5.0)

- Updated `EuiCallOut` with a new `onDismiss` prop
([#7156](elastic/eui#7156))
- Added a new `renderCustomToolbar` prop to `EuiDataGrid`, which allows
custom rendering of the toolbar.
([#7190](elastic/eui#7190))
- Added a new `allowResetButton` prop to
`toolbarVisibility.showDisplaySelector` of `EuiDataGrid`, which allows
hiding the "Reset to default" button from the display settings popover.
([#7190](elastic/eui#7190))
- Added a new `additionalDisplaySettings` prop to
`toolbarVisibility.showDisplaySelector` of `EuiDataGrid`, which allows
rendering extra settings inside the display settings popover.
([#7190](elastic/eui#7190))
- Updated `EuiDataGrid`'s toolbar display settings button icon
([#7190](elastic/eui#7190))
- Updated `EuiTextTruncate` with significantly improved iteration
performance. Removed `measurementRenderAPI` prop, as `EuiTextTruncation`
now only uses more performant canvas render API
([#7210](elastic/eui#7210))
- Updated `EuiPopover` with a new configurable `repositionToCrossAxis`
prop ([#7211](elastic/eui#7211))
- Updated `EuiDatePicker` to support `compressed` input styling
([#7218](elastic/eui#7218))
- Added `gradient` and `palette` icon glyphs.
([#7220](elastic/eui#7220))

**Bug fixes**

- Fixed `EuiPopover`'s missing animations on popover close
([#7211](elastic/eui#7211))
- Fixed `EuiInputPopover` anchoring to the wrong side and missing
shadows on smaller screens
([#7211](elastic/eui#7211))
- Fixed `EuiSuperDatePicker` icon spacing on the quick select button
([#7217](elastic/eui#7217))
- Fixed a missing type in `EuiMarkdownEditor`'s default processing
plugins ([#7221](elastic/eui#7221))


## [`88.4.1`](https://github.com/elastic/eui/tree/v88.4.1)

**Bug fixes**

- Fixed missing `className`s on `EuiTextTruncate`
([#7212](elastic/eui#7212))
- Fixed `title`s on `EuiComboBox` dropdown options to always be present
([#7212](elastic/eui#7212))
- Fixed `EuiComboBox` truncation issues when search is an empty space
([#7212](elastic/eui#7212))

## [`88.4.0`](https://github.com/elastic/eui/tree/v88.4.0)

- Updated `EuiComboBox` to allow configuring text truncation behavior
via `truncationProps`. These props can be set on the entire combobox as
well as on on individual dropdown options.
([#7028](elastic/eui#7028))
- Updated `EuiInMemoryTable` with a new `searchFormat` prop (defaults to
`eql`). When setting this prop to `text`, the built-in search bar will
ignore EQL syntax and allow searching for plain strings with special
characters and symbols.
([#7175](elastic/eui#7175))

**Bug fixes**

- `EuiComboBox` now always shows the highlighted search text, even on
truncated text ([#7028](elastic/eui#7028))
- Fixed missing i18n in `EuiSearchBar`'s default placeholder and
aria-label text ([#7175](elastic/eui#7175))
- Fixed the inline compressed styles of `EuiDescriptionListTitle` to use
a taller line-height for readability
([#7185](elastic/eui#7185))
- Fixed `EuiComboBox` to correctly truncate selected items when
displayed as pills and plain text
([#7193](elastic/eui#7193))

**Accessibility**

- Added `aria-current` attribute to `EuiTablePagination`
([#7186](elastic/eui#7186))

**CSS-in-JS conversions**

- Converted `EuiDroppable` and `EuiDraggable` to Emotion; Removed
`$euiDragAndDropSpacing` Sass variables
([#7187](elastic/eui#7187))

---------

Co-authored-by: Patryk Kopycinski <contact@patrykkopycinski.com>
Co-authored-by: Jan Monschke <jan.monschke@elastic.co>
Co-authored-by: Thomas Watson <watson@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Feature:Add Data Add Data and sample data feature on Home review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants