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

Allow renaming names from uploaded files #6358

Merged
merged 8 commits into from
Aug 5, 2024

Conversation

ehconitin
Copy link
Contributor

Hello @Bonapara,

Done with issue #6317. I had to create a new component, EditableField (Component), because the existing InputText component has a fixed height (link), which causes the attachment row to increase in size everytime clicked on rename.

I’ve also updated the colors for the box border and box shadow as specified in Figma.

Please let me know your thoughts.
Thanks

2024-07-22.02-25-40.mp4

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

The pull request introduces a new feature allowing users to rename uploaded files directly within the application, along with some UI enhancements.

  • New Component: Added EditableField.tsx in packages/twenty-front/src/modules/ui/field/input/components/ for inline renaming functionality.
  • Attachment Dropdown: Updated AttachmentDropdown.tsx to include a 'Rename' option with a corresponding handleRename function.
  • Attachment Row: Modified AttachmentRow.tsx to integrate the EditableField component for renaming files inline.
  • Theme Updates: Added editable color and box shadow styles in packages/twenty-ui/src/theme/constants/BorderDark.ts, BorderLight.ts, BoxShadowDark.ts, and BoxShadowLight.ts.
  • UI Consistency: Ensured new styles align with Figma specifications for a cohesive user experience.

7 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings

onFocus={onFocus}
onBlur={onBlur}
onChange={(event: ChangeEvent<HTMLInputElement>) => {
onChange?.(event.target.value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Style: Add error handling for the onChange callback to prevent potential runtime errors.

@Bonapara
Copy link
Member

Bonapara commented Jul 22, 2024

Thanks, @ehconitin! It would be great if the text was pre-selected. This should be an option that could be applied to any TextInput focus field.

@ehconitin
Copy link
Contributor Author

On it. @Bonapara

@ehconitin
Copy link
Contributor Author

ehconitin commented Jul 22, 2024

@Bonapara . Done.
thanks for the feedback.

2024-07-22.16-50-42.mp4

const handleInputBlur = () => {
handleUpdate();
};
useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic should be inside the EditableField component

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

setIsEditing(true);
};

const handleInputChange = (text: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, should be inside the editable field component

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

onBlur?: FocusEventHandler<HTMLInputElement>;
};

const EditableFieldComponent = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like some logic could be shared with TextInput but let's see this later.

@lucasbordeau lucasbordeau self-assigned this Jul 22, 2024
@ehconitin
Copy link
Contributor Author

@lucasbordeau Made the suggested changes.
Refactored the EditableField component to handle its own state and passed the updated function signature for handleUpdate. This ensures better encapsulation.
Thanks for the review.

Copy link
Member

@Weiko Weiko left a comment

Choose a reason for hiding this comment

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

LGTM!

@Weiko Weiko merged commit ed0102e into twentyhq:main Aug 5, 2024
5 of 11 checks passed
Copy link

github-actions bot commented Aug 5, 2024

Fails
🚫

node failed.

Log

�[31mError: �[39m RequestError [HttpError]: You have exceeded a secondary rate limit. Please wait a few minutes before you try again. If you reach out to GitHub Support for help, please include the request ID 8087:1613A3:A78E96B:136DF459:66B0EE2D.
    at /home/runner/work/twenty/twenty/node_modules/�[4m@octokit�[24m/request/dist-node/index.js:86:21
�[90m    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)�[39m {
  status: �[33m403�[39m,
  response: {
    url: �[32m'https://api.github.com/search/issues?q=is%3Apr%20author%3Aehconitin%20is%3Aclosed%20repo%3Atwentyhq%2Ftwenty&per_page=2&page=1'�[39m,
    status: �[33m403�[39m,
    headers: {
      �[32m'access-control-allow-origin'�[39m: �[32m'*'�[39m,
      �[32m'access-control-expose-headers'�[39m: �[32m'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset'�[39m,
      connection: �[32m'close'�[39m,
      �[32m'content-encoding'�[39m: �[32m'gzip'�[39m,
      �[32m'content-security-policy'�[39m: �[32m"default-src 'none'"�[39m,
      �[32m'content-type'�[39m: �[32m'application/json; charset=utf-8'�[39m,
      date: �[32m'Mon, 05 Aug 2024 15:22:21 GMT'�[39m,
      �[32m'referrer-policy'�[39m: �[32m'origin-when-cross-origin, strict-origin-when-cross-origin'�[39m,
      server: �[32m'github.com'�[39m,
      �[32m'strict-transport-security'�[39m: �[32m'max-age=31536000; includeSubdomains; preload'�[39m,
      �[32m'transfer-encoding'�[39m: �[32m'chunked'�[39m,
      vary: �[32m'Accept-Encoding, Accept, X-Requested-With'�[39m,
      �[32m'x-content-type-options'�[39m: �[32m'nosniff'�[39m,
      �[32m'x-frame-options'�[39m: �[32m'deny'�[39m,
      �[32m'x-github-api-version-selected'�[39m: �[32m'2022-11-28'�[39m,
      �[32m'x-github-media-type'�[39m: �[32m'github.v3; format=json'�[39m,
      �[32m'x-github-request-id'�[39m: �[32m'8087:1613A3:A78E96B:136DF459:66B0EE2D'�[39m,
      �[32m'x-ratelimit-limit'�[39m: �[32m'30'�[39m,
      �[32m'x-ratelimit-remaining'�[39m: �[32m'30'�[39m,
      �[32m'x-ratelimit-reset'�[39m: �[32m'1722871401'�[39m,
      �[32m'x-ratelimit-resource'�[39m: �[32m'search'�[39m,
      �[32m'x-ratelimit-used'�[39m: �[32m'1'�[39m,
      �[32m'x-xss-protection'�[39m: �[32m'0'�[39m
    },
    data: {
      documentation_url: �[32m'https://docs.github.com/free-pro-team@latest/rest/overview/rate-limits-for-the-rest-api#about-secondary-rate-limits'�[39m,
      message: �[32m'You have exceeded a secondary rate limit. Please wait a few minutes before you try again. If you reach out to GitHub Support for help, please include the request ID 8087:1613A3:A78E96B:136DF459:66B0EE2D.'�[39m
    }
  },
  request: {
    method: �[32m'GET'�[39m,
    url: �[32m'https://api.github.com/search/issues?q=is%3Apr%20author%3Aehconitin%20is%3Aclosed%20repo%3Atwentyhq%2Ftwenty&per_page=2&page=1'�[39m,
    headers: {
      accept: �[32m'application/vnd.github.v3+json'�[39m,
      �[32m'user-agent'�[39m: �[32m'octokit-rest.js/18.12.0 octokit-core.js/3.6.0 Node.js/18.20.4 (linux; x64)'�[39m,
      authorization: �[32m'token [REDACTED]'�[39m
    },
    request: { hook: �[36m[Function: bound bound register]�[39m }
  }
}
danger-results://tmp/danger-results-323ea5ac.json

Generated by 🚫 dangerJS against 33c3448

@ehconitin
Copy link
Contributor Author

ehconitin commented Aug 5, 2024

Hi @FelixMalfait,

Thanks for merging my PR and optimizing the code! I noticed a couple of features from the original issue didn’t make it into the final merge:

  • Filenames aren’t preselected as planned.
  • The input box border doesn’t match the Figma design.

These were part of my initial commit but seem to have been lost during the optimization. Should I open a new issue to reintroduce these, or do you have suggestions on how we can incorporate them without duplicating code?

Looking forward to your thoughts!

@FelixMalfait
Copy link
Member

@ehconitin I'm sorry I forgot to give feedback.
I think the direction you took made sense, and it would have been hard for you to do weight the trade-off yourself.
What I didn't like is that you introduced duplicated code, and even with that duplicated code some features didn't work out of the box (e.g. press escape to exit field).

The EditableField file wasn't properly named imo. It could have been something like FileInputField. But then we introduce a new pattern because FileInput is not a field type unlike other xxxField. So that would make the codebase more confusing.

Sometimes we have, as engineers, a duty to call out to the design team that they're asking for too much and that their ask will create a debt in the code. Then we can decide together if it's worth creating that debt.

In that case:

  • We don't have yet a clear vision for what the widgets on the show page are going to look like.
  • We don't have yet a clear vision of what the attachments will look like 6 months from now.

You might have seen recently we removed a lot of code and migrated Tasks/Notes to become standard objects in the code base. That's in line with our general vision in this project which is to rely on as few primitives as possible to power all concepts throughout the app. Attachments are likely to undergo a similar migration where we try to make them fit into standard patterns as much as possible.

Thanks a lot for your contribution! It was still helpful to have explored this direction

cc @Bonapara you'll notice the design are not like you wanted sorry!

@ehconitin
Copy link
Contributor Author

Hey @FelixMalfait ,

Thanks for the feedback! I appreciate you pointing out the duplicated code and the naming issues. I see where you're coming from about the design debt, too.

I’ll look into these and work on improving things.

Thanks alot!

@ehconitin ehconitin deleted the fixed-issue-6317 branch August 6, 2024 10:21
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.

6 participants