Skip to content

Commit cc1cd84

Browse files
committed
add foldall and unfoldall
1 parent f65dc9f commit cc1cd84

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

ui/src/components/repo/sidebar.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,29 @@ function ToastError() {
839839
return <Box></Box>;
840840
}
841841

842+
function SidebarTest() {
843+
const dispatch = useDispatch();
844+
return (
845+
<Box>
846+
SidebarTest
847+
<Button
848+
onClick={() => {
849+
dispatch(repoSlice.actions.foldAll());
850+
}}
851+
>
852+
Fold All
853+
</Button>
854+
<Button
855+
onClick={() => {
856+
dispatch(repoSlice.actions.unfoldAll());
857+
}}
858+
>
859+
Unfold All
860+
</Button>
861+
</Box>
862+
);
863+
}
864+
842865
export function Sidebar() {
843866
return (
844867
<Box mx={2} px="1rem" boxShadow="xl" rounded="md" bg="gray.200">
@@ -850,6 +873,10 @@ export function Sidebar() {
850873
<GitBar />
851874
</Box>
852875
<Divider my={2} />
876+
<Box boxShadow="xl" p="2" rounded="md" bg="gray.50">
877+
<SidebarTest />
878+
</Box>
879+
<Divider my={2} />
853880
<Box boxShadow="xl" p="2" rounded="md" bg="gray.50">
854881
<SidebarRuntime />
855882
<SidebarKernel />

ui/src/lib/reducers/pod.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,18 @@ export default {
152152
state.pods[id].fold = !state.pods[id].fold;
153153
}
154154
},
155+
foldAll: (state, action) => {
156+
for (const [id, pod] of Object.entries(state.pods)) {
157+
if (pod) {
158+
pod.fold = true;
159+
}
160+
}
161+
},
162+
unfoldAll: (state, action) => {
163+
for (const [id, pod] of Object.entries(state.pods)) {
164+
pod.fold = false;
165+
}
166+
},
155167
toggleThundar: (state, action) => {
156168
let id = action.payload;
157169
if (!state.pods[id].thundar) {

0 commit comments

Comments
 (0)