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: split projects view into "my projects" and "other projects" #6886

Merged
merged 16 commits into from
Apr 22, 2024

Conversation

thomasheartman
Copy link
Contributor

@thomasheartman thomasheartman commented Apr 18, 2024

This PR removes the previous "my projects" filter in favor always splitting projects, but showing both on the main screen.

To make it a bit easier to work with, it also moves the project group component into its own file, causing some extra lines of code change. My apologies 🙇🏼

Copy link

vercel bot commented Apr 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 19, 2024 8:26am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Apr 19, 2024 8:26am

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

Code Health Quality Gates: OK

  • Improving Code Health: 1 findings(s) ✅

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

Code Health Quality Gates: OK

  • Improving Code Health: 1 findings(s) ✅

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

Code Health Quality Gates: OK

  • Improving Code Health: 1 findings(s) ✅

View detailed results in CodeScene

Comment on lines 159 to 176
const projectsLists = useMemo(() => {
if (!splitProjectList) {
return { my: [], other: projects };
}

const my: IProjectCard[] = [];
const other: IProjectCard[] = [];

for (const project of filteredProjects) {
console.log('handling', project);
if (shouldDisplayInMyProjects(myProjects)(project)) {
my.push(project);
} else {
other.push(project);
}
}
return { my, other };
}, [filteredProjects, myProjects, splitProjectList]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanna extract this into its own function so that I can test it properly.

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

Code Health Quality Gates: OK

  • Improving Code Health: 1 findings(s) ✅

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

Code Health Quality Gates: OK

  • Improving Code Health: 1 findings(s) ✅

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

Code Health Quality Gates: OK

  • Improving Code Health: 1 findings(s) ✅

View detailed results in CodeScene

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

Code Health Quality Gates: OK

  • Improving Code Health: 1 findings(s) ✅

View detailed results in CodeScene

Comment on lines 210 to 300
const ProjectGroup: React.FC<{
sectionTitle?: string;
projects: IProjectCard[];
}> = ({ sectionTitle, projects }) => {
return (
<StyledProjectGroupContainer>
<ConditionallyRender
condition={Boolean(sectionTitle)}
show={
<Typography component='h3'>{sectionTitle}</Typography>
}
/>
<ConditionallyRender
condition={projects.length < 1 && !loading}
show={
<ConditionallyRender
condition={searchValue?.length > 0}
show={
<TablePlaceholder>
No projects found matching &ldquo;
{searchValue}
&rdquo;
</TablePlaceholder>
}
elseShow={
<TablePlaceholder>
No projects available.
</TablePlaceholder>
}
/>
}
elseShow={
<StyledItemsContainer>
<ConditionallyRender
condition={loading}
show={() =>
loadingData.map((project: IProjectCard) => (
<ProjectCard
data-loading
onHover={() => {}}
key={project.id}
name={project.name}
id={project.id}
mode={project.mode}
memberCount={2}
health={95}
featureCount={4}
/>
))
}
elseShow={() => (
<>
{projects.map(
(project: IProjectCard) => (
<StyledCardLink
key={project.id}
to={`/projects/${project.id}`}
>
<ProjectCard
onHover={() =>
handleHover(
project.id,
)
}
name={project.name}
mode={project.mode}
memberCount={
project.memberCount ??
0
}
health={project.health}
id={project.id}
featureCount={
project.featureCount
}
isFavorite={
project.favorite
}
/>
</StyledCardLink>
),
)}
</>
)}
/>
</StyledItemsContainer>
}
/>
</StyledProjectGroupContainer>
);
};
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 just extracting the component that was already there, so that we can use it in two places. However, it feels pretty gnarly.

I'm unsure about moving it out into its own file, though, because then we'd have to add five extra parameters to the function:

  • loading
  • searchValue
  • CardComponent
  • ContainerComponent
  • handleHover

Still, it might be a neater approach. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Update: I went ahead with extracting this into its own file. I think it's the right thing to do.

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

Code Health Quality Gates: OK

  • Improving Code Health: 1 findings(s) ✅

View detailed results in CodeScene

const projectsListNewCards = useUiFlag('projectsListNewCards');
const filters = ['All projects', 'My projects'];
const [filter, setFilter] = useState(filters[0]);
const splitProjectList = useUiFlag('projectListFilterMyProjects');

Choose a reason for hiding this comment

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

✅ Getting better: Complex Method
ProjectListNew decreases in cyclomatic complexity from 23 to 17, threshold = 10

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

Code Health Quality Gates: OK

  • Improving Code Health: 1 findings(s) ✅

View detailed results in CodeScene

@thomasheartman thomasheartman merged commit b6833d9 into main Apr 22, 2024
13 checks passed
@thomasheartman thomasheartman deleted the feat/show-my-projects-in-all-projects branch April 22, 2024 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants