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

fix gradient values #2384

Merged
merged 1 commit into from
Oct 11, 2023
Merged

Conversation

ada-x64
Copy link
Contributor

@ada-x64 ada-x64 commented Oct 10, 2023

Bugfix

Number style gradient values were not being populated. This uses the same code as an older version, but reimplemented in rust.

Testing

No tests were added or changed.

Screenshots (if appropriate)

Checklist

  • I have read the CONTRIBUTING.md and followed its Guidelines
  • I have linted my code locally, following the project's code style
  • I have tested my changes locally, and changes pass on the Azure Pipelines CI.

@ada-x64 ada-x64 force-pushed the bugs/number-styles-gradient-values branch from 85bfa28 to 30e56c6 Compare October 10, 2023 17:20
@texodus texodus added the bug Concrete, reproducible bugs label Oct 10, 2023
@ada-x64 ada-x64 force-pushed the bugs/number-styles-gradient-values branch from 30e56c6 to a800ac7 Compare October 10, 2023 19:58
Copy link
Member

@texodus texodus left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! Looks good!

if let Some(view) = ctx.props().view.clone() && let Some(column_name) = ctx.props().column_name.clone() {
ctx.link().send_future(async {
let view = view.unchecked_into::<JsPerspectiveView>();
let min_max = view._get_min_max(column_name.into()).await.unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

The _ prefix in the extern "C" functions is meant to indicate a place where the native wasm_bindgen type support is insufficient, and that this method should not be made public or called directly. I would argue in this case that, as this function always returns the JavaScript-equivalent of a 2-tuple of f64, that we should add fn get_min_max(col: &str) -> (f64, f64) to the the impl JsPerspectiveView block in perspective.js extern module, such that consumers of this API need not juggle wasm_bindgen typecasting magic as below at the callsite.

As a general principal I think, we want to try to contain wasm_bindgen types to dedicated FFI/extern modules except in cases where it impacts performance.

self.config.bg_gradient = None;
}
};

self.dispatch_config(ctx);
false
}
NumberColumnStyleMsg::DefaultGradientChanged(gradient) => {
Copy link
Member

Choose a reason for hiding this comment

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

Distributing the default value logic across multiple files like means we have the of the complexity of the default_config/config design, but none of the decoupling. We should instead IMO make the default_config() getter an async method which can query it's container.

@texodus texodus merged commit 5f5bc95 into finos:master Oct 11, 2023
html_template! {
<div class="item_title">{title.clone()}</div>
<div class="style_contents">
<NumberColumnStyle { config } {default_config} {on_change} />
<NumberColumnStyle column_name={column_name.clone()} view={view.clone()} { config } {default_config} {on_change} />
Copy link
Member

@texodus texodus Oct 11, 2023

Choose a reason for hiding this comment

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

Don't bind and pass View - pass the state object Session and request the view immediately where needed. This doesn't matter as much for this change due to the ephemeral nature of this component, but for components that persist between query changes, View can not only go stale, any remaining stale references will segfault if you try to call them.

@ada-x64 ada-x64 mentioned this pull request Oct 12, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Concrete, reproducible bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants