# project_panel: Disable undo and redo on read-only projects \(\#61104\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/68b165e450b47311567f97e81b2117417c414099)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 68b165e450b47311567f97e81b2117417c414099

Requested commit: 68b165e450b47311567f97e81b2117417c414099

Commit: 68b165e450b47311567f97e81b2117417c414099

Tree: 9855dc013868e8c3bf3e7ceae9c6a35a1ae82d9e

Author: Dino

Committer: GitHub

## Message

```
project_panel: Disable undo and redo on read-only projects (#61104)

# Objective

Users in a read-only project should have no permission to create,
rename, move, trash or delete files, as such, they should also have no
way to undo or redo these actions. These changes ensure that the
listeners for both `project_panel::Undo` and `project_panel::Redo` are
only registered if the project is not read-only.

## Solution

The `ProjectPanel` listeners for both the `Undo` and `Redo` actions were
not gated behind the existing `!Project::is_read_only` call, on
`ProjectPanel::render`, so these changes move the listeners inside that
check.

## Testing

Currently, there isn't an easy way to manually test this, as these
actions were already disabled in collab and the easiest way to get into
a read-only project is connect as a collab guest. However, in order to
ensure this continues being asserted once we remove the collab
restriction, the
`project_panel::tests::undo::undo_redo_unavailable_for_read_only_collab_guest`
test has been added.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [ ] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [ ] Performance impact has been considered and is acceptable

---

Release Notes:

- N/A
```

## Parents

- [7d07d39f19d1ca56a5e1e3216d73f611ae7b5759](https://git.cafe/gitcafe/zed/commit/7d07d39f19d1ca56a5e1e3216d73f611ae7b5759?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/68b165e450b47311567f97e81b2117417c414099?format=markdown)
