Skip to content

Enhance SSH dialog user experience #4260

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

Open
wants to merge 16 commits into
base: development
Choose a base branch
from
Open

Conversation

0oM4R
Copy link
Contributor

@0oM4R 0oM4R commented Jun 29, 2025

Description

this pr include two unrelated changes that only lint fixes

  • prevent empty key name
  • Disable closing the dialog while generating or saving the key
  • Apply new constraints on names
  • Rename the keys that do not follow the constraints
  • Show a toast to inform the user that the keys have been recovered and updated successfully
image image image

image

Related Issues

Tested Scenarios

  • Generate an SSH key and try to close while generating
  • An empty name will trigger field validation
  • Import and try to close the dialog while saving
  • generate keys from dashboard.dev that do not follow the new constraints, this should be recovered and named to defaultN

Documentation PR

For UI changes, Please provide the Documentation PR on info_grid

To consider

Preliminary Checks:

  • Preliminary Checks
    • Does it completely address the issue linked?
    • What about edge cases?
    • Does it meet the specified acceptance criteria?
    • Are there any unintended side effects?
    • Does the PR adhere to the team's coding conventions, style guides, and best practices?
    • Does it integrate well with existing features?
    • Does it impact the overall performance of the application?
    • Are there any bottlenecks or slowdowns?
    • Has it been optimized for efficiency?
    • Has it been adequately tested with unit, integration, and end-to-end tests?
    • Are there any known defects or issues?
    • Is the code well-documented?
    • Are changes to documentation reflected in the code?

UI Checks:

  • UI Checks
    • If a UI design is provided/ does it follow it?
    • Does every button work?
    • Is the data displayed logical? Is it what you expected?
    • Does every validation work?
    • Does this interface feel intuitive?
    • What about slow network? Offline?
    • What if the gridproxy/graphql/chain is failing?
    • What would a first time user have a hard time navigating here?

Code Quality Checks:

  • Code Quality Checks
    • Code formatted/linted? Are there unused imports? .. etc
    • Is there redundant/repeated code?
    • Are there conditionals that are always true or always false?
    • Can we write this more concisely?
    • Can we reuse this code? If yes, where?
    • Will the changes be easy to maintain and update in the future?
    • Can this code become too complex to understand for other devs?
    • Can this code cause future integration problems?

Testing Checklist

  • Does it Meet the specified acceptance criteria.
  • Test if changes can affect any other functionality.
  • Tested with unit, integration, and end-to-end tests.
  • Tested the un-happy path and rollback scenarios.
  • Documentation updated to meet the latest changes.
  • Check automated tests working successfully with the changes.
  • Can be covered by automated tests.

General Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstring
  • Screenshots/Video attached (needed for UI changes)

- prevent empty key name
- disable close the dialog while generating or saving the key
@xmonader xmonader changed the title Enhance SHH dialog user experience Enhance SSH dialog user experience Jun 29, 2025
@0oM4R 0oM4R marked this pull request as draft June 29, 2025 10:47
@0oM4R 0oM4R marked this pull request as ready for review July 14, 2025 11:43
@samaradel
Copy link
Contributor

image

shouldn't it be senstive case ?

await sshKeysManagement.update(newKeys);
createCustomToast("SSH keys have been recovered successfully.", ToastType.success);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The keys will be renamed, this is to make the user aware of what happened to the keys

@samaradel samaradel self-requested a review July 15, 2025 08:34
@0oM4R
Copy link
Contributor Author

0oM4R commented Jul 15, 2025

image shouldn't it be senstive case ?

It was not requested, and there is no conflict in keys, so I think it is fine for now, We may have another issue to discuss further

Comment on lines +267 to +278
assignDefaultNames(keys?: SSHKeyData[]): SSHKeyData[] {
if (!keys) {
keys = this.oldKeys as SSHKeyData[];
}
const existingNames = new Set(keys.map(k => k.name).filter(Boolean));
for (const key of keys) {
if (isAlphanumericWithSpace("Invalid name")(key.name) !== true) {
key.name = this.getUniqueName(existingNames, false);
}
}
return keys;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
assignDefaultNames(keys?: SSHKeyData[]): SSHKeyData[] {
if (!keys) {
keys = this.oldKeys as SSHKeyData[];
}
const existingNames = new Set(keys.map(k => k.name).filter(Boolean));
for (const key of keys) {
if (isAlphanumericWithSpace("Invalid name")(key.name) !== true) {
key.name = this.getUniqueName(existingNames, false);
}
}
return keys;
}
assignDefaultNames(keys?: SSHKeyData[]): SSHKeyData[] {
if (!keys) {
keys = this.oldKeys as SSHKeyData[];
}
// Collect existing names, filtering out empty or falsy names
const existingNames = new Set(
keys
.map(k => k.name)
.filter(name => name && isAlphanumericWithSpace("Invalid name")(name) === true)
);
for (const key of keys) {
// Check if name is invalid or empty
if (!key.name || isAlphanumericWithSpace("Invalid name")(key.name) !== true) {
// Assign a unique default name
key.name = this.getUniqueName(existingNames, false);
} else {
// Add valid existing name to the set to prevent duplicates
existingNames.add(key.name);
}
}
return keys;
}

Comment on lines +170 to +181
export function isAlphanumericWithSpace(msg: string) {
return (value: string) => {
if (value.endsWith(" ")) {
return msg;
}
value = value.trimEnd();
if (!/^[a-zA-Z0-9]+( [a-zA-Z0-9]+)*$/.test(value)) {
return msg;
}
return true;
};
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export function isAlphanumericWithSpace(msg: string) {
return (value: string) => {
if (value.endsWith(" ")) {
return msg;
}
value = value.trimEnd();
if (!/^[a-zA-Z0-9]+( [a-zA-Z0-9]+)*$/.test(value)) {
return msg;
}
return true;
};
}
export function isAlphanumericWithSpace(msg: string) {
return (value: string) => {
if (value.endsWith(" ") || !/^[a-zA-Z0-9]+( [a-zA-Z0-9]+)*$/.test(value.trimEnd())) {
return msg;
}
return true;
};
}


it("should not allow empty string", () => {
expect(validator("")).toBe("Invalid input");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add this
it("should not allow a string with only spaces", () => { expect(validator(" ")).toBe("Invalid input"); expect(validator(" ")).toBe("Invalid input"); });

Copy link
Contributor

Choose a reason for hiding this comment

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

and this it("should allow a single character", () => { expect(validator("A")).toBe(true); expect(validator("z")).toBe(true); expect(validator("1")).toBe(true); });

@amiraabouhadid
Copy link
Contributor

amiraabouhadid commented Jul 16, 2025

tests pass
Screenshot 2025-07-16 at 20 33 59
validation err appears on empty name
Screenshot 2025-07-16 at 20 36 49
save btn should be disabled when form is invalid

@ramezsaeed
Copy link
Contributor

tests pass Screenshot 2025-07-16 at 20 33 59 validation err appears on empty name Screenshot 2025-07-16 at 20 36 49 save btn should be disabled when form is invalid

+1 save button should be disabled in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants