-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/access-management' of https://github.com/equino…
…r/fusion-project-portal into feature/access-management
- Loading branch information
Showing
15 changed files
with
259 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
import { defineAppConfig } from '@equinor/fusion-framework-cli'; | ||
|
||
const feature = true; | ||
export default defineAppConfig((_env) => ({ | ||
environment: { | ||
client: { | ||
baseUri: 'https://backend-fusion-project-portal-test.radix.equinor.com', | ||
defaultScopes: ['api://02f3484c-cad0-4d1d-853d-3a9e604b38f3/access_as_user'], | ||
}, | ||
client: feature | ||
? { | ||
baseUri: 'https://backend-fusion-project-portal-feature.radix.equinor.com', | ||
defaultScopes: ['api://7bf96dd1-39fe-47dd-8286-329c730ac76b/access_as_user'], | ||
} | ||
: { | ||
baseUri: 'https://backend-fusion-project-portal-test.radix.equinor.com', | ||
defaultScopes: ['api://02f3484c-cad0-4d1d-853d-3a9e604b38f3/access_as_user'], | ||
}, | ||
}, | ||
})); |
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
93 changes: 93 additions & 0 deletions
93
client/apps/portal-administration/src/components/FormComponents/AddAdmins.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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { Label, Icon, Button, Typography } from '@equinor/eds-core-react'; | ||
import { PersonSelect, PersonListItem, PersonSelectEvent } from '@equinor/fusion-react-person'; | ||
import { FieldErrors, UseFormSetValue, UseFormWatch } from 'react-hook-form'; | ||
import styled from 'styled-components'; | ||
import { error_filled, close } from '@equinor/eds-icons'; | ||
import { PortalInputs } from '../../schema'; | ||
|
||
const Style = { | ||
AdminError: styled(Typography).withConfig({ displayName: 'AdminError' })` | ||
display: flex; | ||
gap: 0.5rem; | ||
align-items: center; | ||
`, | ||
AdminList: styled.div` | ||
padding-top: 1rem; | ||
display: flex; | ||
flex-direction: row; | ||
flex-wrap: wrap; | ||
gap: 1rem; | ||
`, | ||
}; | ||
|
||
export const AddAdmins = ({ | ||
watch, | ||
setValue, | ||
errors, | ||
canEdit, | ||
}: { | ||
watch: UseFormWatch<PortalInputs>; | ||
setValue: UseFormSetValue<PortalInputs>; | ||
errors: FieldErrors<PortalInputs>; | ||
canEdit?: boolean; | ||
}) => { | ||
const handlePersonSelect = (e: PersonSelectEvent) => { | ||
const selected = e.nativeEvent.detail.selected?.azureId; | ||
if (!selected) return; | ||
const current = watch().admins; | ||
const selectedItems = [...current, { azureUniqueId: selected }]; | ||
setValue('admins', selectedItems, { shouldTouch: true, shouldValidate: true }); | ||
}; | ||
|
||
const handlePersonRemove = (azureUniqueId: string) => { | ||
setValue( | ||
'admins', | ||
watch().admins.filter((a) => a.azureUniqueId !== azureUniqueId), | ||
{ shouldTouch: true } | ||
); | ||
}; | ||
|
||
const handleOnBlur = () => { | ||
setValue('admins', watch().admins, { shouldTouch: true }); | ||
}; | ||
|
||
return ( | ||
<> | ||
{canEdit && ( | ||
<div> | ||
<Label htmlFor="#person-select" label={'Search for Portal Admins'}></Label> | ||
<PersonSelect | ||
id="person-select" | ||
variant="page-dense" | ||
selectedPerson={null} | ||
onBlur={handleOnBlur} | ||
onSelect={handlePersonSelect} | ||
placeholder="Search.." | ||
/> | ||
</div> | ||
)} | ||
<Style.AdminList> | ||
{errors.admins && ( | ||
<Style.AdminError variant="caption" color="danger"> | ||
{errors.admins.message} | ||
<Icon data={error_filled} title="Error" /> | ||
</Style.AdminError> | ||
)} | ||
{watch().admins.map((person) => ( | ||
<PersonListItem key={person.azureUniqueId} azureId={person.azureUniqueId}> | ||
{canEdit && ( | ||
<Button | ||
variant="ghost_icon" | ||
onClick={() => { | ||
handlePersonRemove(person.azureUniqueId); | ||
}} | ||
> | ||
<Icon data={close} title={`Remove admin`} /> | ||
</Button> | ||
)} | ||
</PersonListItem> | ||
))} | ||
</Style.AdminList> | ||
</> | ||
); | ||
}; |
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
Oops, something went wrong.