θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content

Conversation

@shatfield4
Copy link
Collaborator

Pull Request Type

  • ✨ feat
  • πŸ› fix
  • ♻️ refactor
  • πŸ’„ style
  • πŸ”¨ chore
  • πŸ“ docs

Relevant Issues

resolves #707

What is in this change?

Describe the changes in this PR that are impactful to the repo.

  • Add option under Appearance settings where an admin can set the support email in the user menu to be a custom email

Additional Information

Add any other context about the Pull Request here that was not captured above.

Developer Validations

  • I ran yarn lint from the root of the repo & committed changes
  • Relevant documentation has been updated
  • I have tested my code functionality
  • Docker build succeeds locally

@shatfield4 shatfield4 linked an issue Feb 15, 2024 that may be closed by this pull request
@shatfield4 shatfield4 self-assigned this Feb 15, 2024
@shatfield4 shatfield4 marked this pull request as ready for review February 15, 2024 07:10
@review-agent-prime
Copy link

frontend/src/components/UserMenu/index.jsx

Consider using the useCallback hook for the handleClose function in the UserButton component. This will prevent unnecessary re-renders of the component when the function is recreated on each render.
Create Issue
See the diff
Checkout the fix

    const handleClose = useCallback((event) => {
      if (
        menuRef.current &&
        !menuRef.current.contains(event.target) &&
        !buttonRef.current.contains(event.target)
      ) {
        setShowMenu(false);
      }
    }, []);
git fetch origin && git checkout -b ReviewBot/Impro-k6n5tgq origin/ReviewBot/Impro-k6n5tgq

Consider using the useCallback hook for the handleOpenAccountModal function in the UserButton component. This will prevent unnecessary re-renders of the component when the function is recreated on each render.
Create Issue
See the diff
Checkout the fix

    const handleOpenAccountModal = useCallback(() => {
      setShowAccountSettings(true);
      setShowMenu(false);
    }, []);
git fetch origin && git checkout -b ReviewBot/Impro-p8pl613 origin/ReviewBot/Impro-p8pl613

frontend/src/pages/GeneralSettings/Appearance/SupportEmail/index.jsx

Consider using the useCallback hook for the updateSupportEmail function in the SupportEmail component. This will prevent unnecessary re-renders of the component when the function is recreated on each render.
Create Issue
See the diff
Checkout the fix

    const updateSupportEmail = useCallback(async (e) => {
      e.preventDefault();
      const form = new FormData(e.target);
      const supportEmail = form.get("supportEmail");
      const { success, error } = await Admin.updateSystemPreferences({
        support_email: supportEmail,
      });

      if (!success) {
        showToast(`Failed to update support email: ${error}`, "error");
        return;
      } else {
        showToast("Successfully updated support email.", "success");
        window.localStorage.removeItem(System.cacheKeys.supportEmail);
        setHasChanges(false);
      }
    }, []);
git fetch origin && git checkout -b ReviewBot/Impro-5nb2lhd origin/ReviewBot/Impro-5nb2lhd

Consider using the useCallback hook for the removeEmail function in the SupportEmail component. This will prevent unnecessary re-renders of the component when the function is recreated on each render.
Create Issue
See the diff
Checkout the fix

    const removeEmail = useCallback(async (e) => {
      e.preventDefault();
      const { success, error } = await Admin.updateSystemPreferences({
        support_email: null,
      });

      if (!success) {
        showToast(`Failed to remove support email: ${error}`, "error");
        return;
      } else {
        setSupportEmail("");
        showToast("Successfully removed support email.", "success");
        window.localStorage.removeItem(System.cacheKeys.supportEmail);
        setHasChanges(false);
      }
    }, []);
git fetch origin && git checkout -b ReviewBot/Impro-31dme5e origin/ReviewBot/Impro-31dme5e

Consider using the useCallback hook for the onEmailChange function in the SupportEmail component. This will prevent unnecessary re-renders of the component when the function is recreated on each render.
Create Issue
See the diff
Checkout the fix

    const onEmailChange = useCallback((e) => {
      setSupportEmail(e.target.value);
      setHasChanges(true);
    }, []);
git fetch origin && git checkout -b ReviewBot/Impro-et0zlvo origin/ReviewBot/Impro-et0zlvo

server/endpoints/admin.js

  It's a good practice to provide more detailed error messages in your catch blocks. This will help you debug issues more effectively. Also, consider using a logging library or service that provides more functionality than console.error, such as the ability to log errors in various environments.

Create Issue
See the diff
Checkout the fix

    catch (e) {
      console.error(`Error occurred in adminEndpoints: ${e.message}`);
      response.sendStatus(500).end();
    }
git fetch origin && git checkout -b ReviewBot/Impro-k4qsyxj origin/ReviewBot/Impro-k4qsyxj
  You can improve the performance of your application by reducing the number of database calls. In the "/admin/system-preferences" endpoint, you are making multiple calls to the database to get each system setting. You can improve this by making a single call to get all the system settings at once.

Create Issue
See the diff
Checkout the fix

    const settings = await SystemSettings.getAll();
git fetch origin && git checkout -b ReviewBot/Impro-31e1hlw origin/ReviewBot/Impro-31e1hlw

@Mintplex-Labs Mintplex-Labs deleted a comment from review-agent-prime bot Feb 15, 2024
@Mintplex-Labs Mintplex-Labs deleted a comment from review-agent-prime bot Feb 15, 2024
@Mintplex-Labs Mintplex-Labs deleted a comment from review-agent-prime bot Feb 15, 2024
@timothycarambat timothycarambat merged commit 17c1913 into master Feb 19, 2024
@timothycarambat timothycarambat deleted the 707-feat-allow-user-to-set-support-email branch February 19, 2024 18:30
cabwds pushed a commit to cabwds/anything-llm that referenced this pull request Jul 3, 2025
* implement custom support email for usermenu support button

* small refactor

---------

Co-authored-by: timothycarambat <rambat1010@gmail.com>
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.

[FEAT]: Allow user to set support email

3 participants