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

[Workspace]Fix page crash caused by invalid workspace color #7671

Merged

Conversation

wanglam
Copy link
Contributor

@wanglam wanglam commented Aug 9, 2024

Description

This PR for fixing page crashed after invalid color be assigned to avatar component in the Workspace Menu component.

Issues Resolved

#7672

Screenshot

image

Testing the changes

1.Go to 'Create workspace' page
2.Fill workspace name and select use case, input a invalid color.
3.Click on 'Create workspace' button
4.Workspace should not be created with invalid color, it should show form error

Changelog

  • fix: [Workspace]Fix page crash caused by invalid workspace color

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

opensearch-changeset-bot bot added a commit to wanglam/OpenSearch-Dashboards that referenced this pull request Aug 9, 2024
@wanglam wanglam force-pushed the add-workspace-color-validation branch from b480aa6 to c1d5d3d Compare August 9, 2024 06:06
opensearch-changeset-bot bot added a commit to wanglam/OpenSearch-Dashboards that referenced this pull request Aug 9, 2024
Copy link

codecov bot commented Aug 9, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 5 lines in your changes missing coverage. Please review.

Project coverage is 63.69%. Comparing base (389fd28) to head (8789c06).
Report is 209 commits behind head on main.

Files with missing lines Patch % Lines
...orkspace/public/components/workspace_form/utils.ts 71.42% 1 Missing and 1 partial ⚠️
src/plugins/workspace/server/routes/index.ts 0.00% 2 Missing ⚠️
...ublic/components/workspace_menu/workspace_menu.tsx 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7671   +/-   ##
=======================================
  Coverage   63.69%   63.69%           
=======================================
  Files        3633     3634    +1     
  Lines       80126    80140   +14     
  Branches    12695    12702    +7     
=======================================
+ Hits        51034    51043    +9     
- Misses      25984    25987    +3     
- Partials     3108     3110    +2     
Flag Coverage Δ
Linux_1 30.60% <66.66%> (+<0.01%) ⬆️
Linux_2 55.63% <ø> (ø)
Linux_3 40.55% <ø> (ø)
Linux_4 31.30% <ø> (ø)
Windows_1 30.62% <66.66%> (+<0.01%) ⬆️
Windows_2 55.58% <ø> (ø)
Windows_3 40.55% <ø> (ø)
Windows_4 31.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wanglam wanglam force-pushed the add-workspace-color-validation branch from 37b85d9 to 6a4944f Compare August 9, 2024 06:31
@wanglam wanglam changed the title [Workspace]Fixed page crash caused by invalid workspace color values [Workspace]Fix page crash caused by invalid workspace color values Aug 9, 2024
opensearch-changeset-bot bot added a commit to wanglam/OpenSearch-Dashboards that referenced this pull request Aug 9, 2024
opensearch-changeset-bot bot added a commit to wanglam/OpenSearch-Dashboards that referenced this pull request Aug 9, 2024
@wanglam wanglam changed the title [Workspace]Fix page crash caused by invalid workspace color values [Workspace]Fix page crash caused by invalid workspace colo Aug 9, 2024
@wanglam wanglam changed the title [Workspace]Fix page crash caused by invalid workspace colo [Workspace]Fix page crash caused by invalid workspace color Aug 9, 2024
Comment on lines +6 to +8
// Reference https://github.com/opensearch-project/oui/blob/main/src/services/color/is_valid_hex.ts
export const validateWorkspaceColor = (color?: string) =>
!!color && /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(color);
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we replace it with import { is_valid_hex } from '@opensearch-project/oui/lib/services/color';?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That not works fine in my local. Seems can't import from @opensearch-project/oui/lib/services/color;
I've tried import { isValidHex } from '@elastic/eui';, but it not works for server side.

@SuZhou-Joe SuZhou-Joe merged commit 248c8ff into opensearch-project:main Aug 12, 2024
72 of 73 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 12, 2024
* Add validation for workspace color

Signed-off-by: Lin Wang <[email protected]>

* Changeset file for PR #7671 created/updated

---------

Signed-off-by: Lin Wang <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 248c8ff)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
ruanyl pushed a commit that referenced this pull request Aug 12, 2024
…7681)

* Add validation for workspace color



* Changeset file for PR #7671 created/updated

---------



(cherry picked from commit 248c8ff)

Signed-off-by: Lin Wang <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
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.

5 participants