Skip to content

Commit 5c64109

Browse files
committed
#891 add option to select all files in workspace from repo
1 parent 1ef1218 commit 5c64109

File tree

5 files changed

+70
-3
lines changed

5 files changed

+70
-3
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Subproject commit ff44c209b71b119a1d9ede41550d555e362c76e8
1+
Subproject commit b0839b2e1d902a42955a32a3981823aab36017c7

applications/osb-portal/src/components/repository/RepositoryPageDetails.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ const RepositoryPageDetails = ({
438438
>
439439
<TableRow>
440440
<TableCell padding="checkbox" sx={{ width: "1.8em" }}>
441+
<Tooltip title="Select all files">
441442
<Checkbox
442443
color="primary"
443444
checked={
@@ -446,9 +447,10 @@ const RepositoryPageDetails = ({
446447
}
447448
onChange={(e) => onSelectAllFiles(e.target.checked)}
448449
inputProps={{
449-
"aria-label": "select all desserts",
450+
"aria-label": "select all files",
450451
}}
451452
/>
453+
</Tooltip>
452454
</TableCell>
453455
<TableCell component="th">
454456
<Typography component="p">Name</Typography>

applications/osb-portal/src/components/repository/RepositoryResourceBrowser.tsx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
bgLightestShade,
3737
bgInputs,
3838
} from "../../theme";
39+
import { Tooltip } from "@mui/material";
3940

4041
const useStyles = makeStyles((theme) => ({
4142
textField: {
@@ -178,6 +179,22 @@ export default ({
178179
setChecked({});
179180
}, [refresh]);
180181

182+
const resourcesList = React.useMemo(() => currentPath
183+
?.slice(-1)[0]
184+
?.children?.filter(
185+
(e) => !filter || e.resource.name.toLowerCase().includes(filter)
186+
), [currentPath, filter]);
187+
188+
let resourcesListObject: {
189+
[id: string]: RepositoryResourceNode;
190+
} = React.useMemo(() => resourcesList?.reduce(
191+
(resourcesListObject, item) => {
192+
resourcesListObject[item.resource.path] = item.children;
193+
return resourcesListObject;
194+
},
195+
{}
196+
), [resourcesList]);
197+
181198
const onCheck = (isChecked: boolean, value: RepositoryResourceNode) => {
182199
if (isChecked) {
183200
checked[value.resource.path] = value;
@@ -192,6 +209,17 @@ export default ({
192209
setCurrentPath([...currentPath, n]);
193210
};
194211

212+
const onSelectAllFiles = (value) => {
213+
if (value) {
214+
setChecked(resourcesListObject);
215+
checkedChanged(resourcesList);
216+
} else {
217+
setChecked({});
218+
checkedChanged([])
219+
}
220+
};
221+
222+
195223
return <>
196224
<Box display="flex" flex-direction="row" alignItems="center">
197225
{backAction && (
@@ -233,7 +261,40 @@ export default ({
233261
<Box mt={1} className="scrollbar">
234262
<TableContainer component="div">
235263
<Table className={classes.list} aria-label="repository resources">
264+
<TableHead
265+
sx={{
266+
"& .MuiTableCell-root": {
267+
padding: "8px 8px 8px 0",
268+
269+
"& .MuiButtonBase-root": {
270+
padding: 0,
271+
},
272+
},
273+
}}
274+
>
275+
<TableRow>
276+
<TableCell padding="checkbox" sx={{ width: "1.8em" }}>
277+
<Tooltip title="Select all files">
278+
<Checkbox
279+
color="primary"
280+
checked={
281+
Object.keys(checked)?.length ===
282+
currentPath.slice(-1)[0].children?.length
283+
}
284+
onChange={(e) => onSelectAllFiles(e.target.checked)}
285+
inputProps={{
286+
"aria-label": "select all files",
287+
}}
288+
/>
289+
</Tooltip>
290+
</TableCell>
291+
<TableCell component="th">
292+
<Typography component="p">Name</Typography>
293+
</TableCell>
294+
</TableRow>
295+
</TableHead>
236296
<TableBody>
297+
237298
{currentPath
238299
.slice(-1)[0]
239300
.children.filter(

applications/osb-portal/src/pages/Repositories/RepositoriesPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export const RepositoriesPage = ({
137137

138138
const handleSearchFilter = React.useCallback((newTextFilter: string) => {
139139
setSearchFilterValues({ ...searchFilterValues, text: newTextFilter });
140+
setPage(1);
140141
}, []);
141142

142143
const setReposValues = React.useCallback((reposDetails) => {
@@ -281,7 +282,7 @@ export const RepositoriesPage = ({
281282
</Grid>
282283
</Box>
283284
</Box>
284-
285+
{!repositories?.length && !loading && <Typography sx={{p: 3}}>No repositories found</Typography>}
285286
{listView === "list" ? (
286287
<RepositoriesTable
287288
handleRepositoryClick={(repository: OSBRepository) =>
@@ -330,6 +331,7 @@ export const RepositoriesPage = ({
330331
/>
331332
)}
332333
</Box>
334+
333335
{repositories && totalPages > 1 && (
334336
<OSBPagination
335337
count={totalPages}

applications/osb-portal/src/pages/WorkspacesPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ export const WorkspacesPage = (props: WorkspacesPageProps) => {
9191
...searchFilterValues,
9292
text: newTextFilter,
9393
});
94+
setPage(1);
95+
9496

9597
debounce(() => {
9698
getWorkspacesList({ searchFilterValues: { ...searchFilterValues, text: newTextFilter } });

0 commit comments

Comments
 (0)