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

chore: stat widget polish #33696

Merged
merged 13 commits into from
May 27, 2024
Merged

chore: stat widget polish #33696

merged 13 commits into from
May 27, 2024

Conversation

jsartisan
Copy link
Contributor

@jsartisan jsartisan commented May 23, 2024

Fixes #33397

/ok-to-test tags="@tag.Anvil"

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9257919530
Commit: 30c8b31
Cypress dashboard url: Click here!

@jsartisan jsartisan requested a review from a team May 23, 2024 11:02
@jsartisan jsartisan requested review from a team as code owners May 23, 2024 11:02
@github-actions github-actions bot added Anvil Pod Issue related to Anvil project High This issue blocks a user from building or impacts a lot of users Task A simple Todo WDS team labels May 23, 2024
Copy link
Contributor

coderabbitai bot commented May 23, 2024

Walkthrough

Walkthrough

The changes involve renaming and enhancing the StatBoxComponent to StatsComponent with additional properties for better customization and interactivity. The anvilConfig was updated to refine widget sizing, and the styles.module.css file was modified to introduce new padding and styling rules. Additionally, various configurations and constants were adjusted to align with the new component structure and functionality.

Changes

File Path Change Summary
.../WDSStatsWidget/component/index.tsx Renamed StatBoxComponent to StatsComponent and added new properties (caption, onClick, valueChangeColor, valueColor).
.../WDSStatsWidget/config/anvilConfig.ts Updated isLargeWidget to false and modified minWidth property for additional sizing options.
.../anvil/common/styles.module.css Introduced new padding rules and updated styles for zones and cards based on elevation levels.
.../WidgetAdditionSagas.ts Changed condition from configMap[key] to configMap[key] != undefined in getWidgetSessionValues function.
.../anvil/constants.ts Added CARD_ELEVATION with a value of 3 to the Elevations enum.
.../widgets/index.ts Renamed WDSStatBoxWidget to WDSStatsWidget in import and WDSWidgets array.
.../WDSStatsWidget/component/types.ts Introduced StatsComponentProps interface extending StatsWidgetProps.
.../WDSStatsWidget/config/defaultsConfig.ts Updated widget configuration values and introduced new properties (valueColor, valueChangeColor, caption).
.../WDSStatsWidget/config/metaConfig.ts Updated widget configuration name from "Statbox" to "Stats".
.../WDSStatsWidget/config/propertyPaneConfig/contentConfig.ts Added new property for value color, modified placeholders, renamed properties, and added an Events section.
.../WDSStatsWidget/config/propertyPaneConfig/styleConfig.ts Introduced propertyPaneStyleConfig object for defining styles related to the property pane.
.../WDSStatsWidget/index.tsx Exported WDSStatsWidget from the widget module.
.../WDSStatsWidget/widget/index.tsx Added WDSStatsWidget class with static methods for configuration retrieval and event handling.
.../WDSStatsWidget/widget/types.ts Renamed StatBoxWidgetProps to StatsWidgetProps and adjusted properties.
.../wds/constants.ts Renamed STATBOX_WIDGET to STATS_WIDGET in WDS_V2_WIDGET_MAP object.

Assessment against linked issues

Objective (Issue #33397) Addressed Explanation
Make statbox a hug type widget
Add changes according to the documentation

Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between cdfcce6 and 30c8b31.
Files selected for processing (1)
  • app/client/src/layoutSystems/anvil/common/styles.module.css (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/client/src/layoutSystems/anvil/common/styles.module.css

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to full the review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label May 23, 2024
@jsartisan
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9207257815.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 33696.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-33696.dp.appsmith.com

@jsartisan
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9219852468.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 33696.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-33696.dp.appsmith.com

} = props;

return (
<Flex
alignItems="center"
className={styles.statbox}
data-clickable={onClick !== undefined ? "" : undefined}
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤨

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removedclassName={styles.statbox} as styles from src/layoutSystems/anvil/common/styles.module.css were enough.

I added data-clickable just to add styles ( like hover )based on if there is onClick handler available. Let me remove this as we will be doing it separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this prop.

@@ -1,7 +1,7 @@
import type { AnvilConfig } from "WidgetProvider/constants";

export const anvilConfig: AnvilConfig = {
isLargeWidget: true,
isLargeWidget: false,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not enough because ResponsiveBehavior should be changed to hug. The idea here is to be able to have multiple StatsWidget in the same zone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CleanShot 2024-05-24 at 14 09 56@2x Fill or Hug? 😵‍💫 We have the `ResponsiveBehaviour.Fill` for statbox in our `src/widgets/wds/WDSStatsWidget/config/defaultsConfig.ts`

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I'm a little confused about the terminology. Fill widget is the correct behavior, but as far as I can see, it does not work correctly.
Here's what we have:
Снимок экрана 2024-05-24 в 12 18 01

And for example, how inputs works:
Снимок экрана 2024-05-24 в 12 17 44

So Stats should behave the same way.

@@ -1,7 +1,7 @@
import { WIDGET_TAGS } from "constants/WidgetConstants";

export const metaConfig = {
name: "Statbox",
name: "Stats",
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm just wondering why the name was changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was there in list of things we need to do in the polish.

@KelvinOm
Copy link
Collaborator

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9222033974.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 33696.
recreate: .

@jsartisan
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9222073045.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 33696.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-33696.dp.appsmith.com

@jsartisan jsartisan requested review from a team and riodeuno and removed request for a team May 24, 2024 12:02
@jsartisan
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9223591801.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 33696.
recreate: .

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range and nitpick comments (11)
app/client/src/sagas/WidgetAdditionSagas.ts (11)

Line range hint 66-66: Specify a more precise type instead of any.

- tabs: any;
+ tabs: { [key: string]: TabDetails }; // Assuming TabDetails is an interface representing the structure of each tab.

Line range hint 232-232: Specify a more precise type instead of any.

- propsBlueprint?: WidgetBlueprint;
+ propsBlueprint?: WidgetBlueprint; // Ensure WidgetBlueprint is properly typed in its definition.

Line range hint 251-251: Use optional chaining to simplify the code.

- if (blueprint && blueprint.view) {
+ if (blueprint?.view) {

Line range hint 273-278: Prefer using for...of for iterating over arrays.

- childPropsList.forEach((props: GeneratedWidgetPayload) => {
+ for (const props of childPropsList) {

Line range hint 290-290: Use optional chaining to simplify the code.

- if (blueprint && blueprint.operations && blueprint.operations.length > 0) {
+ if (blueprint?.operations?.length > 0) {

Line range hint 304-304: Avoid using the delete operator; consider setting the property to undefined or restructuring the object without the property.

- delete widget.blueprint;
+ const { blueprint, ...rest } = widget;
+ widget = rest;

Line range hint 478-478: Specify a more precise type instead of any.

- const newTabProps: any = getChildTabData(tabProps, {
+ const newTabProps: TabProps = getChildTabData(tabProps, { // Assuming TabProps is an interface for tab properties.

Line range hint 491-491: Specify a more precise type instead of any.

- const updatedWidgets: CanvasWidgetsReduxState = yield call(
+ const updatedWidgets: CanvasWidgetsReduxState = yield call( // Ensure CanvasWidgetsReduxState is properly typed in its definition.

Line range hint 501-501: Simplify the computed expression without using a string literal.

- const sessionStorageKey = `${widgetType}.${parent.widgetId}.${key}`;
+ const sessionStorageKey = [widgetType, parent.widgetId, key].join('.');

Line range hint 563-563: Specify a more precise type instead of any.

- let valueFromSession: any = sessionStorage.getItem(sessionStorageKey);
+ let valueFromSession: string | null = sessionStorage.getItem(sessionStorageKey); // sessionStorage.getItem returns a string or null.

Line range hint 277-277: Avoid reassigning function parameters as it can lead to confusing and hard-to-track bugs.

- widget.children = [];
+ const newChildren = [];
+ // Use newChildren for further operations and assign it back to widget.children at the end if needed.

Also applies to: 292-292

@@ -552,7 +553,7 @@ export function getWidgetSessionValues(
}

for (const key in configMap) {
if (configMap[key]) {
if (configMap[key] != undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Use strict inequality operator !== instead of !=.

- if (configMap[key] != undefined) {
+ if (configMap[key] !== undefined) {

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
if (configMap[key] != undefined) {
if (configMap[key] !== undefined) {

@@ -544,6 +544,7 @@

let widgetType = type;
const configMap = WidgetFactory.widgetConfigMap.get(type);

const widgetSessionValues: any = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Specify a more precise type instead of any.

- const widgetSessionValues: any = {};
+ const widgetSessionValues: Record<string, unknown> = {}; // Use a more specific type if possible.

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
const widgetSessionValues: any = {};
const widgetSessionValues: Record<string, unknown> = {}; // Use a more specific type if possible.

Copy link

Deploy-Preview-URL: https://ce-33696.dp.appsmith.com

@jsartisan jsartisan force-pushed the chore/statbox-polish branch from 807d857 to 46a4270 Compare May 27, 2024 06:39
@jsartisan
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9250475616.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 33696.
recreate: .

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Comment on lines +15 to +17
constructor(props: StatsWidgetProps) {
super(props);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove unnecessary constructor.

-  constructor(props: StatsWidgetProps) {
-    super(props);
-  }

The constructor in this class is redundant since it only calls super(props) and does nothing else. Removing it will clean up the code without affecting functionality.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
constructor(props: StatsWidgetProps) {
super(props);
}

Copy link

Deploy-Preview-URL: https://ce-33696.dp.appsmith.com

@jsartisan
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9251320197.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 33696.
recreate: .

Copy link

Deploy-Preview-URL: https://ce-33696.dp.appsmith.com

@jsartisan jsartisan requested review from KelvinOm and removed request for riodeuno May 27, 2024 09:46
KelvinOm
KelvinOm previously approved these changes May 27, 2024
KelvinOm
KelvinOm previously approved these changes May 27, 2024
@jsartisan jsartisan added the ok-to-test Required label for CI label May 27, 2024
@jsartisan jsartisan enabled auto-merge (squash) May 27, 2024 16:32
@jsartisan jsartisan merged commit ec67a0a into release May 27, 2024
44 checks passed
@jsartisan jsartisan deleted the chore/statbox-polish branch May 27, 2024 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Anvil Pod Issue related to Anvil project High This issue blocks a user from building or impacts a lot of users ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo WDS team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Statbox polish
2 participants