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

[WEB-2294] fix: remove 'Add Project' button from archives route and remove it from the dropdown in header #5469

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/core/components/project/card-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const ProjectCardList = observer(() => {
<p className="whitespace-pre-line text-base text-custom-text-400">
{searchQuery.trim() === ""
? "Remove the filters to see all projects"
: "No projects detected with the matching\ncriteria. Create a new project instead"}
: "No projects detected with the matching criteria.\nCreate a new project instead"}
</p>
</div>
</div>
Expand Down
9 changes: 0 additions & 9 deletions web/core/components/project/dropdowns/filters/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,6 @@ export const ProjectFiltersSelection: React.FC<Props> = observer((props) => {
}
title="My projects"
/>
<FilterOption
isChecked={!!displayFilters.archived_projects}
onClick={() =>
handleDisplayFiltersUpdate({
archived_projects: !displayFilters.archived_projects,
})
}
title="Archived"
/>
</div>

{/* access */}
Expand Down
2 changes: 1 addition & 1 deletion web/core/components/project/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export const ProjectsBaseHeader = observer(() => {
/>
</FiltersDropdown>
</div>
{isAuthorizedUser && (
{isAuthorizedUser && !isArchived && (
<Button
size="sm"
onClick={() => {
Expand Down
19 changes: 12 additions & 7 deletions web/core/components/project/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ const Root = observer(() => {
// derived values
const pageTitle = currentWorkspace?.name ? `${currentWorkspace?.name} - Projects` : undefined;

const isArchived = pathname.includes("/archives");

const allowedDisplayFilters = currentWorkspaceAppliedDisplayFilters?.filter(
(filter) => filter !== "archived_projects"
) ?? [];

const handleRemoveFilter = useCallback(
(key: keyof TProjectFilters, value: string | null) => {
if (!workspaceSlug) return;
Expand All @@ -55,25 +61,24 @@ const Root = observer(() => {
if (!workspaceSlug) return;
clearAllFilters(workspaceSlug.toString());
clearAllAppliedDisplayFilters(workspaceSlug.toString());
if (isArchived) updateDisplayFilters(workspaceSlug.toString(), { archived_projects: true });
}, [clearAllFilters, clearAllAppliedDisplayFilters, workspaceSlug]);

useEffect(() => {
if (pathname.includes("/archives")) {
updateDisplayFilters(workspaceSlug.toString(), { archived_projects: true });
} else {
updateDisplayFilters(workspaceSlug.toString(), { archived_projects: false });
}
isArchived ? updateDisplayFilters(workspaceSlug.toString(), { archived_projects: true }) :
updateDisplayFilters(workspaceSlug.toString(), { archived_projects: false });
}, [pathname]);

return (
<>
<PageHead title={pageTitle} />
<div className="flex h-full w-full flex-col">
{(calculateTotalFilters(currentWorkspaceFilters ?? {}) !== 0 ||
currentWorkspaceAppliedDisplayFilters?.length !== 0) && (
(allowedDisplayFilters.length>0)) && (
<div className="border-b border-custom-border-200 px-5 py-3">
<ProjectAppliedFiltersList
appliedFilters={currentWorkspaceFilters ?? {}}
appliedDisplayFilters={currentWorkspaceAppliedDisplayFilters ?? []}
appliedDisplayFilters={allowedDisplayFilters}
handleClearAllFilters={handleClearAllFilters}
handleRemoveFilter={handleRemoveFilter}
handleRemoveDisplayFilter={handleRemoveDisplayFilter}
Expand Down
Loading