Skip to content

Conversation

@Siddhant-K-code
Copy link
Member

@Siddhant-K-code Siddhant-K-code commented Sep 27, 2023

Description

This PR addresses the need for adding a basic organization name validation before making server calls during the organization creation process.

Impact

The goal is to optimize server load and elevate user experience by confirming that only valid organization names are processed. Currently, calls are made to the createTeam endpoint even when the name is empty. This approach allows users to promptly receive basic error messages for issues like empty fields and character limits, instead of sending a request to the server and then displaying the error on the UI, a process that typically takes approximately 1.2 seconds for updates.

Summary generated by Copilot

🤖 Generated by Copilot at b21dc8e

Added placeholders and validation for team and project names. This enhances the usability and feedback of the dashboard UI.

Related Issue(s)

Fixes #

How to test

  • Open preview
  • Create a new organization
    • Hit Create organization when input box is empty & see error message 👀
    • Now, do same with Org name of characters less than 3 and more than 64

Documentation

Preview status

Gitpod was successfully deployed to your preview environment.

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

/hold

@Siddhant-K-code Siddhant-K-code changed the title Validate name pre-server call on org creation Implement name validation before server calls on Org creation Sep 27, 2023
@Siddhant-K-code Siddhant-K-code marked this pull request as ready for review September 27, 2023 04:33
@Siddhant-K-code Siddhant-K-code requested a review from a team as a code owner September 27, 2023 04:34
value={projectName}
error={badProjectName}
onChange={setProjectName}
placeholder="My Project"
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you see a case where the name was empty?

const createTeam = async (event: FormEvent) => {
event.preventDefault();

/* Basic name validation before sending to the server to save time & API calls */
Copy link
Contributor

Choose a reason for hiding this comment

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

It's fast enough and not worth maintaining validation logic twice.

Copy link
Contributor

@svenefftinge svenefftinge left a comment

Choose a reason for hiding this comment

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

Thanks @Siddhant-K-code for caring about the UX!
We want to avoid maintaining validation logic and error messages twice, unless there is a good reason. In this case, the UI feedback seems absolutely fine as it is. So I'd rather not add code unnecessarily. Let me know if I have missed something. 🙏

@Siddhant-K-code
Copy link
Member Author

Absolutely, I'll proceed to close the PR. The main goal was to initiate communication with the server only after conducting fundamental validation on the frontend. However, I understand your concern regarding the management of duplicates. The primary reference for this was:

if (project) {
badProjectName = projectName.length > 0 ? undefined : "Project name can not be blank.";
if (projectName.length > 32) {
badProjectName = "Project name can not be longer than 32 characters.";
}

@Siddhant-K-code Siddhant-K-code deleted the sid/name-validation-org-creation branch September 27, 2023 06:22
@svenefftinge
Copy link
Contributor

Thanks! We should definitely be more consistent and rely on server-side validation as much as reasonable.

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.

4 participants