-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41ebb42
commit 3b9cf30
Showing
10 changed files
with
141 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
165 changes: 62 additions & 103 deletions
165
...sources/theme/rciam-group/account/src/app/group-widgets/GroupAdminPage/GroupSubgroups.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,76 @@ | ||
import * as React from 'react'; | ||
import {FC,useState,useEffect,useRef} from 'react'; | ||
import { DataList,DataListItem,DataListItemCells,DataListItemRow,DataListCell, Button, Tooltip, DataListAction, SelectVariant, Checkbox,Select,SelectOption, FormAlert, Alert, Modal, ModalVariant, Form, FormGroup, TextInput} from '@patternfly/react-core'; | ||
// @ts-ignore | ||
import { HttpResponse, GroupsServiceClient } from '../../groups-mngnt-service/groups.service'; | ||
// @ts-ignore | ||
import { ConfirmationModal } from '../Modals'; | ||
import {ValidateEmail} from '../../js/utils.js' | ||
import { Loading } from '../LoadingModal'; | ||
import { Msg } from '../../widgets/Msg'; | ||
import { GroupListItem } from '../../content/group-page/AdminGroupsPage'; | ||
import {PlusIcon } from '@patternfly/react-icons'; | ||
import { CreateSubgroupModal } from '../Modals'; | ||
|
||
interface AdminGroup{ | ||
id? : string; | ||
name: string; | ||
path: string; | ||
extraSubGroups: AdminGroup[]; | ||
} | ||
|
||
export const GroupSubGroups: FC<any> = (props) => { | ||
|
||
const [createSubgroup,setCreateSubgroup] = useState(false); | ||
|
||
const titleId = 'typeahead-select-id-1'; | ||
let subgroupDefault = { | ||
name: "", | ||
attributes: { | ||
description: [""] | ||
} | ||
} | ||
let groupsService = new GroupsServiceClient(); | ||
const [modalInfo,setModalInfo] = useState({}); | ||
const [loading,setLoading] = useState(false); | ||
const [createModal,setCreateModal] = useState(false); | ||
const [subGroup,setSubGroup] = useState(subgroupDefault); | ||
const [validSubGroup,setValidSubGroup]= useState(false); | ||
|
||
useEffect(()=>{ | ||
setValidSubGroup(subGroup.name.length>0&&subGroup.attributes.description[0].length>0); | ||
},[subGroup]); | ||
const emptyGroup= ()=>{ | ||
return ( | ||
<DataListItem key='emptyItem' aria-labelledby="empty-item"> | ||
<DataListItemRow key='emptyRow'> | ||
<DataListItemCells dataListCells={[ | ||
<DataListCell key='empty'><strong>No subgroups</strong></DataListCell> | ||
]} /> | ||
</DataListItemRow> | ||
</DataListItem> | ||
) | ||
} | ||
|
||
const createSubgroup = () =>{ | ||
setLoading(true); | ||
groupsService!.doPost<any>("/group-admin/group/"+props.groupId+"/children",{...subGroup}) | ||
.then((response: HttpResponse<any>) => { | ||
setLoading(false); | ||
if(response.status===200||response.status===204){ | ||
setModalInfo({ | ||
title:"Sub Group Created", | ||
accept_message: "OK", | ||
accept: function(){ | ||
setModalInfo({})}, | ||
cancel: function(){ | ||
setModalInfo({})} | ||
}); | ||
// setGroupMembers(response.data.results); | ||
} | ||
}).catch((err)=>{ | ||
setLoading(false); | ||
console.log(err)}) | ||
} | ||
|
||
|
||
return ( | ||
<React.Fragment> | ||
<Button onClick={()=>{setCreateModal(true);}}>Create Subgroup</Button> | ||
<Modal | ||
variant={ModalVariant.medium} | ||
title={"Create Subgroup"} | ||
isOpen={createModal} | ||
onClose={()=>{setCreateModal(false)}} | ||
actions={[ | ||
<Tooltip {...(!!validSubGroup ? { trigger:'manual', isVisible:false }:{trigger:'mouseenter'})} | ||
content={ | ||
<div> | ||
Make sure you have provided all the required information | ||
</div> | ||
} | ||
<CreateSubgroupModal groupId={props.groupId} active={createSubgroup} afterSuccess={()=>{props.fetchGroupConfiguration();}} close={()=>{setCreateSubgroup(false);}}/> | ||
<DataList id="groups-list" aria-label={Msg.localize('groupLabel')} isCompact> | ||
|
||
<DataListItem id="groups-list-header" aria-labelledby="Columns names"> | ||
|
||
<DataListItemRow className="gm_datalist-header"> | ||
<DataListItemCells | ||
dataListCells={[ | ||
<DataListCell key='group-name-header' width={2}> | ||
<strong><Msg msgKey='Name' /></strong> | ||
</DataListCell>, | ||
<DataListCell key='group-path-header' width={2}> | ||
<strong><Msg msgKey='Path' /></strong> | ||
</DataListCell> | ||
]} | ||
/> | ||
<DataListAction | ||
className="gm_cell-center" | ||
aria-labelledby="check-action-item1 check-action-action2" | ||
id="check-action-action1" | ||
aria-label="Actions" | ||
isPlainButtonAction | ||
> | ||
<div> | ||
<Button key="confirm" variant="primary" isDisabled={!validSubGroup} onClick={()=>{createSubgroup();}}> | ||
Create | ||
</Button> | ||
</div> | ||
|
||
</Tooltip> | ||
, | ||
|
||
<Button key="cancel" variant="link" onClick={()=>{setCreateModal(false);}}> | ||
Cancel | ||
</Button> | ||
|
||
]} | ||
> | ||
<Form> | ||
<FormGroup | ||
label="Group Name" | ||
isRequired | ||
fieldId="simple-form-name-01" | ||
// helperText="" | ||
> | ||
<TextInput | ||
isRequired | ||
type="text" | ||
id="simple-form-name-01" | ||
name="simple-form-name-01" | ||
aria-describedby="simple-form-name-01-helper" | ||
value={subGroup.name} | ||
onChange={(value)=>{console.log("This is the thing " + value); subGroup.name=value; setSubGroup({...subGroup})}} | ||
/> | ||
</FormGroup> | ||
<FormGroup label="Description" isRequired fieldId="simple-form-desription-01"> | ||
<TextInput | ||
isRequired | ||
type="text" | ||
id="simple-form-email-01" | ||
name="simple-form-email-01" | ||
value={subGroup.attributes.description[0]} | ||
onChange={(value)=>{console.log("This is the thing " + value); subGroup.attributes.description[0]=value; setSubGroup({...subGroup})}} | ||
/> | ||
</FormGroup> | ||
</Form> | ||
</Modal> | ||
<Loading active={loading}/> | ||
<ConfirmationModal modalInfo={modalInfo}/> | ||
<Tooltip content={"Create Subgroup"}> | ||
<Button className={"gm_createsub-button"} onClick={()=>{setCreateSubgroup(true)}}><PlusIcon/></Button> | ||
</Tooltip> | ||
</DataListAction> | ||
|
||
</DataListItemRow> | ||
</DataListItem> | ||
{props.groupConfiguration?.extraSubGroups&&props.groupConfiguration?.extraSubGroups.length>0 ? | ||
props.groupConfiguration?.extraSubGroups.map((group:AdminGroup,appIndex:number)=>{ | ||
return( | ||
<GroupListItem group={group as AdminGroup} fetchAdminGroups={props.fetchGroupConfiguration} appIndex={appIndex} depth={0} /> | ||
) | ||
}): | ||
emptyGroup() | ||
} | ||
</DataList> | ||
</React.Fragment> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.