Skip to content

Commit

Permalink
Merge branch 'release/0.8.0' of github.com:OpenSourceBrain/OSBv2 into…
Browse files Browse the repository at this point in the history
… jupyterhub-update
  • Loading branch information
filippomc committed Feb 6, 2025
2 parents 3954b89 + a521a01 commit 3102d5a
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 60 deletions.
2 changes: 1 addition & 1 deletion applications/osb-portal/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "frontend",
"version": "0.7.0",
"version": "0.8.0",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SearchIcon from "@mui/icons-material/Search";
//style
import { bgRegular, chipTextColor } from "../../theme";
import styled from "@mui/system/styled";
import { debounce } from "lodash";

const StyledTextField = styled(TextField)(({ theme }) => ({
backgroundColor: bgRegular,
Expand Down Expand Up @@ -44,21 +45,24 @@ interface RepositoriesSearchProps {
}

export default (props: RepositoriesSearchProps) => {

const handleChange = React.useCallback(debounce((event: React.ChangeEvent<HTMLInputElement>) => {
// Timout improves responsiveness while typing
props.filterChanged(event.target.value);
}, 1000), []);

return (
<StyledTextField
variant="standard"
id="standard-start-adornment"
fullWidth={true}
value={props?.value}
sx={{
borderRadius: props?.borderRadius
? `${props?.borderRadius}px`
: "8px 0px 0px 8px",
}}
placeholder="Search"
onChange={(e) => {
props.filterChanged(e.target.value.toLowerCase());
}}
onChange={handleChange}
InputProps={{
startAdornment: (
<InputAdornment position="start">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,14 @@ export const SearchFilterReposWorkspaces = (
}
);
}, 500),
[]
);
[] );

const handleTagsChange = React.useCallback((event, value) => props?.setSearchFilterValues({
...props?.searchFilterValues,
tags: value,
})
, [props?.searchFilterValues]);

return (
<>
<RepositoriesWorkspacesSearchField value={props.searchFilterValues.text} filterChanged={props?.filterChanged} />
Expand Down Expand Up @@ -223,12 +228,7 @@ export const SearchFilterReposWorkspaces = (
onInputChange={(event, value) => {
handleTagInput(value);
}}
onChange={(event, value) =>
props?.setSearchFilterValues({
...props?.searchFilterValues,
tags: value,
})
}
onChange={handleTagsChange}
onClose={(event, reason) => handleTagInput("")}
renderTags={(value, getTagProps) =>
value.map((option, index) => (
Expand Down Expand Up @@ -309,6 +309,8 @@ export const SearchFilterReposWorkspaces = (
</StyledPopover>
</>
);


};

export default SearchFilterReposWorkspaces;
96 changes: 50 additions & 46 deletions applications/osb-portal/src/pages/Repositories/RepositoriesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,32 @@ const customButtonStyle = {
},
};

const CustomButton = ({
listType,
Icon,
changeListView,
listView
}: {
listType: string;
Icon: ReactElement;
changeListView: (type: string) => void;
listView: string;
}) => {
if (listType === listView) {
return (
<StyledActiveIconButton onClick={() => changeListView(listType)}>
{Icon}
</StyledActiveIconButton>
);
} else {
return (
<StyledIconButton onClick={() => changeListView(listType)}>
{Icon}
</StyledIconButton>
);
}
};

export const StyledIconButton = styled(IconButton)(() => customButtonStyle);

export const StyledActiveIconButton = styled(IconButton)(() => ({
Expand Down Expand Up @@ -105,25 +131,23 @@ export const RepositoriesPage = ({
const [tabValue, setTabValue] = React.useState(RepositoriesTab.all);
const [listView, setListView] = React.useState<string>("list");



const openRepoUrl = (repositoryId: number) => {
const openRepoUrl = React.useCallback((repositoryId: number) => {
navigate(`/repositories/${repositoryId}`);
};
}, []);

const debouncedHandleSearchFilter = (newTextFilter: string) => {
const handleSearchFilter = React.useCallback((newTextFilter: string) => {
setSearchFilterValues({ ...searchFilterValues, text: newTextFilter });
debounce(() => updateReposList(newTextFilter), 500)();
};
}, []);

const setReposValues = (reposDetails) => {
const setReposValues = React.useCallback((reposDetails) => {
setRepositories(reposDetails.osbrepositories);
setTotal(reposDetails.pagination.total);
setTotalPages(reposDetails.pagination.numberOfPages);
setLoading(false);
};
}, []);

const updateReposList = (updatedSearchFilterValues) => {
const updateReposList = React.useCallback(
async (updatedSearchFilterValues) => {
const isSearchFieldsEmpty =
updatedSearchFilterValues?.tags?.length === 0 &&
updatedSearchFilterValues?.types?.length === 0 &&
Expand All @@ -150,48 +174,30 @@ export const RepositoriesPage = ({
setReposValues(reposDetails);
});
}
};
}, [page, tabValue, user?.id]);

const handleRefreshRepositories = () => {
const handleRefreshRepositories = React.useCallback(() => {
updateReposList(searchFilterValues);
}
}, [searchFilterValues]);

const handleTabChange = (event: any, newValue: RepositoriesTab) => {
const handleTabChange = React.useCallback((event: any, newValue: RepositoriesTab) => {
setTotal(0);
setTabValue(newValue);
setPage(1)
};
}, []);

const changeListView = (type: string) => {
const changeListView = React.useCallback((type: string) => {
setListView(type);
};
}, []);

const handleChangePage = (event: unknown, current: number) => {
const handleChangePage = React.useCallback((event: unknown, current: number) => {
setPage(current);
};
}, []);

const CustomButton = ({
listType,
Icon,
}: {
listType: string;
Icon: ReactElement;
}) => {
if (listType === listView) {
return (
<StyledActiveIconButton onClick={() => changeListView(listType)}>
{Icon}
</StyledActiveIconButton>
);
} else {
return (
<StyledIconButton onClick={() => changeListView(listType)}>
{Icon}
</StyledIconButton>
);
}
};
React.useEffect(() => updateReposList(searchFilterValues), [page, searchFilterValues, tabValue, counter]);

React.useEffect(() => {
updateReposList(searchFilterValues)
}, [page, searchFilterValues, tabValue, counter]);

return (
<>
Expand Down Expand Up @@ -261,13 +267,11 @@ export const RepositoriesPage = ({
variant="contained"
aria-label="Disabled elevation buttons"
>
<CustomButton Icon={<WindowIcon />} listType="grid" />
<CustomButton Icon={<ListIcon />} listType="list" />
<CustomButton Icon={<WindowIcon />} listType="grid" listView={listView} changeListView={changeListView} />
<CustomButton Icon={<ListIcon />} listType="list" listView={listView} changeListView={changeListView} />
</ButtonGroup>
<SearchFilterReposWorkspaces
filterChanged={(newTextFilter) =>
debouncedHandleSearchFilter(newTextFilter)
}
filterChanged={handleSearchFilter}
searchFilterValues={searchFilterValues}
setSearchFilterValues={setSearchFilterValues}
hasTypes={true}
Expand Down
2 changes: 1 addition & 1 deletion applications/workspaces/server/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from setuptools import setup, find_packages

NAME = "workspaces"
VERSION = "0.7.0"
VERSION = "0.8.0"

# To install the library, run the following
#
Expand Down

0 comments on commit 3102d5a

Please sign in to comment.