Skip to content

Commit

Permalink
Show file tree by default (#25052)
Browse files Browse the repository at this point in the history
Feel free to close this if there isn't interest.

The tree view looks amazing, and all of our users are really enjoying it
(major kudos to developers!), but only IF I tell them it exists!

Essentially, the file tree view as it is effectively undiscoverable.  

This PR changes the default state for the tree view to open, which
should significantly help with discoverability.

An alternative could be to reserve more horizontal space, as a typical
accordion panel would look (eg. VS Code), eg.

![image](https://github.com/go-gitea/gitea/assets/12700993/505ea40c-42b1-4111-b306-48e51e8e2130)
  • Loading branch information
kdumontnu authored Jun 2, 2023
1 parent e389714 commit 72eedfb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion templates/repo/diff/box.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
{{svg "octicon-sidebar-expand" 20 "icon gt-hidden"}}
</button>
<script>
const diffTreeVisible = localStorage?.getItem('diff_file_tree_visible') === 'true';
// Default to true if unset
const diffTreeVisible = localStorage?.getItem('diff_file_tree_visible') !== 'false';
const diffTreeBtn = document.querySelector('.diff-toggle-file-tree-button');
const diffTreeIcon = `.octicon-sidebar-${diffTreeVisible ? 'expand' : 'collapse'}`;
diffTreeBtn.querySelector(diffTreeIcon).classList.remove('gt-hidden');
Expand Down
3 changes: 2 additions & 1 deletion web_src/js/components/DiffFileTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ export default {
}
},
mounted() {
this.store.fileTreeIsVisible = localStorage.getItem(LOCAL_STORAGE_KEY) === 'true';
// Default to true if unset
this.store.fileTreeIsVisible = localStorage.getItem(LOCAL_STORAGE_KEY) !== 'false';
document.querySelector('.diff-toggle-file-tree-button').addEventListener('click', this.toggleVisibility);
this.hashChangeListener = () => {
Expand Down

0 comments on commit 72eedfb

Please sign in to comment.