Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

Bug fixes part 2 #257

Merged
merged 5 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,31 @@
* All rights reserved.
*/

import React from "react";
import React, {ChangeEvent} from "react";
import {FormControl, InputAdornment, InputBase, withStyles} from "@material-ui/core";
import Stylable from "../../interfaces/Stylable";
import styles from "./styles";
import CloseIcon from "@material-ui/icons/Close";
import SearchIcon from "@material-ui/icons/Search";

interface SearchBarProps extends Stylable {

onChange?(event: ChangeEvent<HTMLInputElement>): void;
}

const SearchBar = React.forwardRef((props: SearchBarProps, ref) => {
const {
classes,
className,
style,
onChange,
} = props;


return (
<FormControl style={{width: "100%"}}>
<InputBase
className={classes.searchInput}
onChange={onChange}
placeholder="Search…"
endAdornment={
<InputAdornment position="end">
Expand Down
2 changes: 1 addition & 1 deletion src/layout/MonitorLayout/MonitorLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const MonitorLayout = React.forwardRef((props: MonitorLayoutProps, ref: Ref<HTML
.catch(err => {
const errorHandler = new ErrorHandler(enqueueErrorSnackbar);
errorHandler
// .on(401, () => {logout()})
.on(401, () => {logout()})
.on(404, "User not found")
.handle(err);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import UserData from "../../../../interfaces/UserData";
import Role from "../../../../interfaces/Role";
import SearchIcon from "@material-ui/icons/Search";
import CloseIcon from "@material-ui/icons/Close";
import SearchBar from "../../../../components/SearchBar/SearchBar";
import useAuth from "../../../../hooks/useAuth";

interface DialogUserProps extends Stylable {
user: UserData | null;
Expand Down Expand Up @@ -64,16 +66,31 @@ const DialogUser = React.forwardRef((props: DialogUserProps, ref: Ref<any>) => {
onRemoveRole,
} = props;


const confirm = useConfirm();
const {getUser} = useAuth();
const loggedUser = getUser();


// const [user, setUser] = useState<UserData | null>(userOrg);
const [isAddRoleToUserButtonActive, setIsAddRoleToUserButtonActive] = useState<null | HTMLElement>(null);
const [isRemoveRoleFromUserButtonActive, setIsRemoveRoleFromUserButtonActive] = useState<null | HTMLElement>(null);
const [filterRoles, setFilterRoles] = useState<Role[]>(roles);
const [searchValue, setSearchValue] = useState("");


useEffect(() => {
setFilterRoles(roles.filter(role => role.name.toLowerCase().includes(searchValue)));
}, [searchValue]);

useEffect(() => {
setFilterRoles(roles);
}, [roles]);

// useEffect(() => {
// setUser(userOrg);
// }, [userOrg]);

function handleSearch(event: React.ChangeEvent<HTMLInputElement>) {
setSearchValue(event.target.value.toLowerCase());
}
Expand Down Expand Up @@ -164,23 +181,26 @@ const DialogUser = React.forwardRef((props: DialogUserProps, ref: Ref<any>) => {
</ListItemText>
</ListItem>
<Divider/>
<Box className={classes.search}>
<Box className={classes.searchIcon}>
<SearchIcon/>
</Box>
<InputBase
onChange={handleSearch}
placeholder="Search…"
classes={{
root: classes.inputRoot,
input: classes.inputInput,
}}
inputProps={{"aria-label": "search"}}
/>
<IconButton>
<CloseIcon/>
</IconButton>
</Box>
<ListItem>
<SearchBar onChange={handleSearch}/>
</ListItem>
{/*<Box className={classes.search}>*/}
{/* <Box className={classes.searchIcon}>*/}
{/* <SearchIcon/>*/}
{/* </Box>*/}
{/* <InputBase*/}
{/* onChange={handleSearch}*/}
{/* placeholder="Search…"*/}
{/* classes={{*/}
{/* root: classes.inputRoot,*/}
{/* input: classes.inputInput,*/}
{/* }}*/}
{/* inputProps={{"aria-label": "search"}}*/}
{/* />*/}
{/* <IconButton>*/}
{/* <CloseIcon/>*/}
{/* </IconButton>*/}
{/*</Box>*/}
{filterRoles.length !== 0 ? filterRoles.map(role => {

return (
Expand Down Expand Up @@ -247,7 +267,7 @@ const DialogUser = React.forwardRef((props: DialogUserProps, ref: Ref<any>) => {
onClick={() => confirm(async () => onRemove([user?.id]), {title: `are you sure you want to remove user: ${user?.username} ?`})}

>
Remove User from Organization
{loggedUser?.id === user?.id ? "Leave from Organization" : "Remove User from Organization"}
</Button>
</Box>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import Plugin from "../../../../interfaces/Plugin";
*/
interface PluginComponentProps extends Stylable {
plugin: Plugin,
can?: boolean,

invokeDialog(): void,

setCurrentPlugin(id: number): void,
}

Expand All @@ -37,19 +40,25 @@ const PluginComponent = React.forwardRef((props: PluginComponentProps, ref: Ref<
plugin,
invokeDialog,
setCurrentPlugin,
can = true,
} = props;

return (
<Grid container spacing={0} className={classes.container}>
<Grid item xs={10}>
<List className={classes.listRoot}>
<ListItem style={style} className={className} button onClick={()=>{invokeDialog(); setCurrentPlugin(plugin.id)}}>
<ListItem style={style} className={className} button onClick={() => {
invokeDialog();
setCurrentPlugin(plugin.id);
}}>
<ListItemText primary={plugin.name} secondary={plugin.description}/>
{can &&
<ListItemSecondaryAction>
<IconButton>
<CloseIcon/>
</IconButton>
</ListItemSecondaryAction>
}
</ListItem>
</List>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import List from "@material-ui/core/List";
*/
interface TopicWithButtonProps extends Stylable {
children?: string,
can?: boolean;

onClick?(): void,
}
Expand All @@ -46,13 +47,15 @@ const TopicWithButton = React.forwardRef((props: TopicWithButtonProps, ref: Ref<
className,
children,
onClick,
can = true
} = props;
return (
<Grid container className={classes.firstLine}>
<Grid item xs={12} md={10}>
<List component="nav" aria-label="secondary mailbox folders">
<ListItem className={classes.paddingNone}>
<ListItemText primary={children} primaryTypographyProps={{variant: "h6"}}/>
{can &&
<ListItemSecondaryAction>
<IconButton
edge="end"
Expand All @@ -62,6 +65,7 @@ const TopicWithButton = React.forwardRef((props: TopicWithButtonProps, ref: Ref<
<AddIcon/>
</IconButton>
</ListItemSecondaryAction>
}
</ListItem>
<Divider/>
</List>
Expand Down
Loading