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

Add UI to rename tables #852

Merged
merged 9 commits into from
Dec 14, 2021
Merged

Add UI to rename tables #852

merged 9 commits into from
Dec 14, 2021

Conversation

seancolsen
Copy link
Contributor

@seancolsen seancolsen commented Nov 30, 2021

Fixes #447

Before

No way to rename a table.

After

Rename table via a modal accessible from the table actions menu.

Demo

Peek 2021-12-02 15-41

Additional features

  • client side validation for simple error scenarios like a blank name and a name conflict
  • auto focus and select, plus save on Enter key -- all to minimize keystrokes and mouse usage
  • toast message on error (and modal remains open)

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the master branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@seancolsen

This comment has been minimized.

@kgodey kgodey marked this pull request as ready for review November 30, 2021 01:32
@kgodey kgodey requested review from a team, silentninja and pavish and removed request for a team November 30, 2021 01:32
@kgodey

This comment has been minimized.

And incorporate it into Confirmation component
Before:

- The 'open' and 'close' events were dispatching _before_ updating the
  DOM.
- If I wanted to interact with the contents of the modal immediately
  after it opens, I'm out of luck because it won't actually be open
  yet.

After:

- We use `await tick()` to make sure the DOM is updated first.
@seancolsen seancolsen marked this pull request as ready for review December 2, 2021 20:44
@seancolsen seancolsen added the pr-status: review A PR awaiting review label Dec 2, 2021
let proceed: () => Promise<void>;

function schemaContainsTableName(_name: string): boolean {
return [...$tables.data.values()].map((t) => t.name).includes(_name);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the offending line that prompted me to set '@typescript-eslint/no-unsafe-return': 'off',

I'm a little surprised that eslint struggled here. But in general I want to move in the direction of turning off linting rules when they're getting in our way.

Here it seems like svelte-check should catch problems. For example, I tried changing the return statement to return 7 and observed the following error from svelte-check:

Error: Type 'number' is not assignable to type 'boolean'. (ts)

To me, that result from svelte-check says that we don't need eslint for this particular rule.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what could have caused eslint to fail here, I assume it has something to do with recognizing the type of $tables.

I'm okay with disabling problematic rules for now.

@kgodey kgodey self-assigned this Dec 6, 2021
@seancolsen seancolsen linked an issue Dec 8, 2021 that may be closed by this pull request
@pavish pavish self-assigned this Dec 13, 2021
Base automatically changed from 759_conf to master December 13, 2021 18:17
Copy link
Member

@pavish pavish left a comment

Choose a reason for hiding this comment

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

@seancolsen This PR looks good to me!

Comment on lines +33 to +37
function handleKeypress(e: KeyboardEvent) {
if (e.key === 'Enter') {
dispatch('enter');
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be better to bubble up the keypress event directly rather than handling it within the TextInput component.

Copy link
Member

@pavish pavish Dec 14, 2021

Choose a reason for hiding this comment

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

@seancolsen We can handle this on a subsequent PR.

let proceed: () => Promise<void>;

function schemaContainsTableName(_name: string): boolean {
return [...$tables.data.values()].map((t) => t.name).includes(_name);
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what could have caused eslint to fail here, I assume it has something to do with recognizing the type of $tables.

I'm okay with disabling problematic rules for now.

@pavish pavish merged commit 055a95e into master Dec 14, 2021
@pavish pavish deleted the 447_rename_table branch December 14, 2021 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: review A PR awaiting review
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Implement editing a table's name
3 participants