Skip to content

Commit

Permalink
feat(nav-views): Enforce no deletion on last view (#85959)
Browse files Browse the repository at this point in the history
In the near future, we will allow users to have 0 views. Until that
time, we should still enforce the 1 view minimum limit on the frontend
since that's what the backend expects.
  • Loading branch information
MichaelSun48 authored Feb 26, 2025
1 parent 975b00d commit 967852f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface IssueViewNavEllipsisMenuProps {
baseUrl: string;
deleteView: () => void;
duplicateView: () => void;
isLastView: boolean;
setIsEditing: (isEditing: boolean) => void;
updateView: (view: IssueView) => void;
view: IssueView;
Expand All @@ -32,6 +33,7 @@ export function IssueViewNavEllipsisMenu({
duplicateView,
updateView,
baseUrl,
isLastView,
}: IssueViewNavEllipsisMenuProps) {
const navigate = useNavigate();
const organization = useOrganization();
Expand Down Expand Up @@ -127,6 +129,7 @@ export function IssueViewNavEllipsisMenu({
label: t('Delete'),
priority: 'danger',
onAction: deleteView,
disabled: isLastView,
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export interface IssueViewNavItemContentProps {
* Whether the item is active.
*/
isActive: boolean;
/**
* Whether the item is the last view in the list.
* This will be removed once view sharing/starring is implemented.
*/
isLastView: boolean;
/**
* A callback function that updates the view with new params.
*/
Expand All @@ -65,6 +70,7 @@ export function IssueViewNavItemContent({
updateView,
deleteView,
duplicateView,
isLastView,
}: IssueViewNavItemContentProps) {
const organization = useOrganization();
const location = useLocation();
Expand Down Expand Up @@ -137,6 +143,7 @@ export function IssueViewNavItemContent({
>
<IssueViewNavQueryCount view={view} />
<IssueViewNavEllipsisMenu
isLastView={isLastView}
setIsEditing={setIsEditing}
view={view}
updateView={updateView}
Expand Down
1 change: 1 addition & 0 deletions static/app/components/nav/issueViews/issueViewNavItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ export function IssueViewNavItems({
updateView={updatedView => handleUpdateView(view, updatedView)}
deleteView={() => handleDeleteView(view)}
duplicateView={() => handleDuplicateView(view)}
isLastView={views.length === 1}
/>
</AnimatePresence>
))}
Expand Down

0 comments on commit 967852f

Please sign in to comment.