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

feat: allow org members to mark projects as favorites #2040

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sheensantoscapadngan
Copy link
Member

@sheensantoscapadngan sheensantoscapadngan commented Jun 28, 2024

Description 📣

  • This PR will enable org members to create project favorites which will be listed accordingly in the ff UIs
image image image

Type ✨

  • Bug fix
  • New feature
  • Breaking change
  • Documentation

Tests 🛠️

# Here's some code block to paste some code snippets

@maidul98 maidul98 requested review from akhilmhdh and removed request for maidul98 June 28, 2024 18:11
@@ -271,6 +280,30 @@ export const AppLayout = ({ children }: LayoutProps) => {
}
};

const addProjectToFavorites = useCallback(
Copy link
Member

Choose a reason for hiding this comment

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

A bit confused by this usecallback?

Copy link
Member

Choose a reason for hiding this comment

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

And the below one

icon={faSolidStar}
className="text-sm text-mineshaft-300 hover:text-mineshaft-400"
onClick={(e) => {
e.stopPropagation();
Copy link
Member

Choose a reason for hiding this comment

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

Missing try catch and notification for both remove and add

favoriteWorkspaces.every((entry) => entry.id !== ws.id)
);

const addProjectToFavorites = useCallback(
Copy link
Member

Choose a reason for hiding this comment

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

Same doubt - The purpose of useCallback

</div>
</div>
))}
{[...favoriteWorkspaces, ...nonFavoriteWorkspaces].map((workspace, ind) =>
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 this is unnecessarily complex. Just do a useMemo(if the list could be big or computation is a lot). Then just sort the workspace list by favorite or not and add a computed field isFavourite

</>
)}
<div className="mt-4 grid w-full grid-cols-1 gap-4 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4">
{isWorkspaceLoading &&
Copy link
Member

Choose a reason for hiding this comment

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

Wait for isFavorite api call to finish loading. Else the list would jump if the second api call is delayed.

Because consider the workspace loading finished. You will render everything as non favorite as favorites are not loaded yet. Then favorites would load and again list gets modified causing a jump effect.

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.

None yet

2 participants