Skip to content

fix: Allow "spaces" in theme names while saving and display a more relevant error message - #15837

Merged
somangshu merged 8 commits into
releasefrom
fix/spaces-theme-names
Aug 22, 2022
Merged

fix: Allow "spaces" in theme names while saving and display a more relevant error message #15837
somangshu merged 8 commits into
releasefrom
fix/spaces-theme-names

Conversation

@dhruvikn

@dhruvikn dhruvikn commented Aug 8, 2022

Copy link
Copy Markdown
Contributor

Description

This PR intends to allow users to include "space(s)" in their theme name while creating/saving a new theme. Moreover, a new and more relevant error message is displayed which lets the user know what all is accepted in the theme name input.

No spaces allowed previously and now
No spaces allowed previously and now

Old and new error messages
Old and new error messages

Previously, while saving a new theme, we got an error if the name had any "space". However, Appsmith already has an in-house theme with a space in its name. 😄

"Water Lily" Theme
CleanShot 2022-08-08 at 13 38 29@2x

Fixes #14840

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Manually Tested

Few test cases
Few test cases

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@dhruvikn dhruvikn added Bug Something isn't working Good First Issue Good for newcomers Widgets Product This label groups issues related to widgets Low An issue that is neither critical nor breaks a user flow Papercut a trivially fixable usability bug App Theming Product Items that are related to the App level theming controls epic labels Aug 8, 2022
@dhruvikn
dhruvikn requested a review from somangshu August 8, 2022 10:53
@dhruvikn dhruvikn self-assigned this Aug 8, 2022
@vercel

vercel Bot commented Aug 8, 2022

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
appsmith ✅ Ready (Inspect) Visit Preview Aug 16, 2022 at 0:44AM (UTC)

@github-actions

github-actions Bot commented Aug 8, 2022

Copy link
Copy Markdown

Unable to find test scripts. Please add necessary tests to the PR.

@dhruvikn

dhruvikn commented Aug 8, 2022

Copy link
Copy Markdown
Contributor Author

/ok-to-test sha=9a8e982

@github-actions

github-actions Bot commented Aug 8, 2022

Copy link
Copy Markdown

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2817356855.
Workflow: Appsmith External Integration Test Workflow.
Commit: 9a8e982.
PR: 15837.

@github-actions

github-actions Bot commented Aug 8, 2022

Copy link
Copy Markdown

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/2817356855.
Commit: 9a8e982.
Results:

Click to view performance test results

Run 1 Run 2 Run 3 Run 4 Run 5 Median Mean SD.Sample SD.Population
SELECT_WIDGET_MENU_OPEN
scripting 1379.45 1170.71 1107.75 1076.88 1163.27 1163.27 1179.61 10.03 8.97
painting 19.02 11.34 7.5 11.42 22.26 11.42 14.31 42.63 38.16
rendering 1134.74 949.55 878.14 856.25 906.54 906.54 945.04 11.81 10.57
SELECT_WIDGET_SELECT_OPTION
scripting 232.68 177.15 155.17 182.68 160.11 177.15 181.56 16.95 15.16
painting 2.87 3.7 2.36 2.55 5.79 2.87 3.45 40.58 36.23
rendering 346.34 331.28 302.43 303.01 337.95 331.28 324.2 6.27 5.61

somangshu
somangshu previously approved these changes Aug 8, 2022

@somangshu somangshu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Apart from the comments, LGTM

export const NAME_SPACE_ERROR = () => `Name must not have spaces`;
export const SPECIAL_CHARACTER_ERROR = () => `Name must be alphanumeric`;
export const APLHANUMERIC_HYPHEN_SLASH_SPACE_ERROR = () =>
`Name must only contain alphanumeric characters, hyphen, slash, and space`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@dilippitchika does the copy look ok to you?

cc @jnikhila

@jnikhila jnikhila Aug 9, 2022

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@somangshu - looks good to me. Just one minor thing, if we can use something like "A name must begin with a letter and cannot start with a space" instead of "Name must not have spaces"- as it means that the name field cannot have spaces at all.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@somangshu - On another note, why are there different error messages for different validations for the same field? Can we club them all to show a single error message? Adding detail and getting one after the other error message will frustrate users.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@jnikhila the different validation messages are for different kinds of error, clubbing this mean the user will not have a pin pointed idea of what is doing wrong and also might have to jump into the debugger every time, AFAIK This change was made because the user did not have the a good idea about the error. I am not sure if in terms of UX this is a problem, @momcilo-appsmith @dilippitchika can comment on that better.

@dhruvikn for the other suggested change, we should create a new issue with the relevant details and take it up later. Can you do this?

Just one minor thing, if we can use something like "A name must begin with a letter and cannot start with a space" instead of "Name must not have spaces"- as it means that the name field cannot have spaces at all.

@dhruvikn dhruvikn Aug 9, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hi @jnikhila @somangshu. I think there is some confusion. Let me try to paint a clear picture. We have a file called messages.ts that has a lot of messages which are shown on particular conditions throughout Appsmith.

However, for this Theme Name field, there are only three messages used. These three messages are shown on different occasions. The messages for the Theme Name field are -

ERROR_MESSAGE_NAME_EMPTY = Please select a name
APLHANUMERIC_HYPHEN_SLASH_SPACE_ERROR = Name must only contain alphanumeric characters, hyphen, slash, and space
UNIQUE_NAME_ERROR = Name must be unique

Now, as for the NAME_SPACE_ERROR = Name must not have spaces, the author intended to say that "the name field cannot have spaces at all". Reference - #914

import {
createMessage,
ERROR_MESSAGE_NAME_EMPTY,
SPECIAL_CHARACTER_ERROR,

@somangshu somangshu Aug 8, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@dhruvikn is this being used elsewhere? Why are we not using the same variable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, the SPECIAL_CHARACTER_ERROR is not being used anywhere else. We can remove it entirely.
However, APLHANUMERIC_HYPHEN_SLASH_SPACE_ERROR seems a more suitable name for the message.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lets go for that

somangshu
somangshu previously approved these changes Aug 9, 2022

@somangshu somangshu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@somangshu

Copy link
Copy Markdown
Contributor

/ok-to-test sha=cadbf38

@github-actions

github-actions Bot commented Aug 9, 2022

Copy link
Copy Markdown

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2823100713.
Workflow: Appsmith External Integration Test Workflow.
Commit: cadbf38.
PR: 15837.

@chandannkumar

Copy link
Copy Markdown

Tested this PR and working as expected

@github-actions

Copy link
Copy Markdown

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/2823100713.
Commit: cadbf38.
Results:

Click to view performance test results

Run 1 Run 2 Run 3 Run 4 Run 5 Median Mean SD.Sample SD.Population
SELECT_WIDGET_MENU_OPEN
scripting 1336.44 1237.36 1133.64 1132.98 1132.97 1133.64 1194.68 7.63 6.83
painting 10.95 8.91 14.78 8.38 11.2 10.95 10.84 23.25 20.85
rendering 1124.52 934.43 903.14 890.53 885.97 903.14 947.72 10.62 9.50
SELECT_WIDGET_SELECT_OPTION
scripting 193.54 200.08 163.84 174.69 195.49 193.54 185.53 8.37 7.48
painting 6.79 8.95 4.37 4.88 13.58 6.79 7.71 48.51 43.45
rendering 416.4 328.02 337.78 319.77 321.85 328.02 344.76 11.79 10.55

@Aishwarya-U-R

Copy link
Copy Markdown
Contributor

/ok-to-test sha=f0610fe

@github-actions

Copy link
Copy Markdown

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2834317606.
Workflow: Appsmith External Integration Test Workflow.
Commit: f0610fe.
PR: 15837.

@github-actions

Copy link
Copy Markdown

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/2834317606.
Commit: f0610fe.
Results:

Click to view performance test results

Run 1 Run 2 Run 3 Run 4 Run 5 Median Mean SD.Sample SD.Population
SELECT_WIDGET_MENU_OPEN
scripting 1222.12 1114.61 1129.46 1193.36 1165.63 1165.63 1165.04 3.81 3.41
painting 14.56 13.67 13.67 13.26 10.61 13.67 13.15 11.41 10.19
rendering 943.8 902.73 893.91 951.46 929.8 929.8 924.34 2.72 2.44
SELECT_WIDGET_SELECT_OPTION
scripting 179.8 180.86 162.59 180.41 168.25 179.8 174.38 4.83 4.32
painting 2.89 6.45 9.16 3.2 2.77 3.2 4.89 57.87 51.74
rendering 311.52 322.05 346.51 314.08 326.49 322.05 324.13 4.28 3.83

@Aishwarya-U-R

Copy link
Copy Markdown
Contributor

/ok-to-test sha=f7510b2

@github-actions

Copy link
Copy Markdown

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2836814969.
Workflow: Appsmith External Integration Test Workflow.
Commit: f7510b2.
PR: 15837.

@Aishwarya-U-R

Copy link
Copy Markdown
Contributor

/ok-to-test sha=f7510b2

@github-actions

Copy link
Copy Markdown

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2836985535.
Workflow: Appsmith External Integration Test Workflow.
Commit: f7510b2.
PR: 15837.

@github-actions

Copy link
Copy Markdown

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/2836985535.
Commit: f7510b2.
Results:

Click to view performance test results

Run 1 Run 2 Run 3 Run 4 Run 5 Median Mean SD.Sample SD.Population
SELECT_WIDGET_MENU_OPEN
scripting 1003.18 1020.72 1048.99 1020.93 1155.83 1020.93 1049.93 5.85 5.23
painting 11.77 11.89 6.91 12.37 5.25 11.77 9.64 34.34 30.71
rendering 810.35 819.35 815.05 803.6 844.7 815.05 818.61 1.92 1.72
SELECT_WIDGET_SELECT_OPTION
scripting 148.56 152.47 153.01 147.08 148.96 148.96 150.02 1.73 1.55
painting 2.17 2.4 3.92 2.23 5.49 2.4 3.24 44.75 40.12
rendering 299.99 301.33 315.73 308.9 298.43 301.33 304.88 2.39 2.14

@dhruvikn

Copy link
Copy Markdown
Contributor Author

/ok-to-test sha=68dd876

@github-actions

Copy link
Copy Markdown

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2845078154.
Workflow: Appsmith External Integration Test Workflow.
Commit: 68dd876.
PR: 15837.

@github-actions

Copy link
Copy Markdown

UI Performance test run logs and artifacts: https://github.com/appsmithorg/appsmith/actions/runs/2845078154.
Commit: 68dd876.
Results:

Click to view performance test results

Run 1 Run 2 Run 3 Run 4 Run 5 Median Mean SD.Sample SD.Population
SELECT_WIDGET_MENU_OPEN
scripting 1033.5 1041.25 1108.92 1065.14 1040.42 1041.25 1057.85 2.93 2.62
painting 13.74 16.34 7.27 11.94 5.99 11.94 11.06 39.42 35.26
rendering 816.82 845.1 876.82 839.34 822.88 839.34 840.19 2.80 2.50
SELECT_WIDGET_SELECT_OPTION
scripting 151.95 222.85 157.83 182.28 150.44 157.83 173.07 17.70 15.83
painting 7.69 3.18 2.69 4.41 5.55 4.41 4.7 42.77 38.09
rendering 304.04 309.74 291.19 365.71 298.25 304.04 313.79 9.51 8.50

@dhruvikn

Copy link
Copy Markdown
Contributor Author

/ok-to-test sha=a77f9b1

@github-actions

Copy link
Copy Markdown

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2868611293.
Workflow: Appsmith External Integration Test Workflow.
Commit: a77f9b1.
PR: 15837.

@somangshu

Copy link
Copy Markdown
Contributor

/ok-to-test sha=a77f9b1

@github-actions

Copy link
Copy Markdown

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2874756591.
Workflow: Appsmith External Integration Test Workflow.
Commit: a77f9b1.
PR: 15837.

1 similar comment
@github-actions

Copy link
Copy Markdown

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/2874756591.
Workflow: Appsmith External Integration Test Workflow.
Commit: a77f9b1.
PR: 15837.

@somangshu
somangshu merged commit 9dae56e into release Aug 22, 2022
@somangshu
somangshu deleted the fix/spaces-theme-names branch August 22, 2022 05:22
if (/[^a-zA-Z0-9\-\/\ ]/.test(value)) {
isValid = false;
errorMessage = createMessage(SPECIAL_CHARACTER_ERROR);
errorMessage = createMessage(APLHANUMERIC_HYPHEN_SLASH_SPACE_ERROR);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@dhruvikn can we test this function in jest?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App Theming Product Items that are related to the App level theming controls epic Bug Something isn't working Good First Issue Good for newcomers Low An issue that is neither critical nor breaks a user flow Papercut a trivially fixable usability bug Widgets Product This label groups issues related to widgets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]-[98]:Save Theme does not support 'space' to save as a theme name

5 participants