-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: redesign organisation layout (#3257)
Co-authored-by: kyle-ssg <[email protected]>
- Loading branch information
1 parent
165f95b
commit 61d0585
Showing
19 changed files
with
1,686 additions
and
1,510 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { FC, useMemo } from 'react' | ||
import { NavLink } from 'react-router-dom' | ||
|
||
import AccountStore from 'common/stores/account-store' | ||
import { useHasPermission } from 'common/providers/Permission' | ||
import Icon from 'components/Icon' | ||
|
||
const OrganisationLink: FC = () => { | ||
const organisation = AccountStore.getOrganisation() | ||
|
||
const { permission: canManageUserGroups } = useHasPermission({ | ||
id: organisation?.id, | ||
level: 'organisation', | ||
permission: 'MANAGE_USER_GROUPS', | ||
}) | ||
|
||
const pageLink = useMemo(() => { | ||
if (!organisation) return null | ||
|
||
if (AccountStore.isAdmin() || canManageUserGroups) { | ||
return '/organisation-settings' | ||
} | ||
|
||
return '/projects' | ||
}, [organisation, canManageUserGroups]) | ||
|
||
return ( | ||
pageLink && ( | ||
<NavLink | ||
id='org-settings-link' | ||
activeClassName='active' | ||
className='nav-link' | ||
to={pageLink} | ||
> | ||
<span className='mr-1'> | ||
<Icon name='layout' width={20} fill='#9DA4AE' /> | ||
</span> | ||
{'Organisation'} | ||
</NavLink> | ||
) | ||
) | ||
} | ||
|
||
export default OrganisationLink |
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,62 @@ | ||
import { FC, useCallback, useEffect } from 'react' | ||
|
||
import AccountProvider from 'common/providers/AccountProvider' | ||
import AccountStore from 'common/stores/account-store' | ||
import AppActions from 'common/dispatcher/app-actions' | ||
import Utils from 'common/utils/utils' | ||
import Project from 'common/project' | ||
import Button from 'components/base/forms/Button' | ||
import CreateOrganisationModal from 'components/modals/CreateOrganisation' | ||
import Icon from './Icon' | ||
import OrganisationSelect from './OrganisationSelect' | ||
|
||
type OrganisationManageWidgetType = { | ||
onChange?: () => void | ||
} | ||
|
||
const OrganisationManageWidget: FC<OrganisationManageWidgetType> = ({ | ||
onChange, | ||
}) => { | ||
const handleCreateOrganisationClick = useCallback(() => { | ||
openModal('Create Organisation', <CreateOrganisationModal />, 'side-modal') | ||
}, []) | ||
|
||
useEffect(() => { | ||
AppActions.getOrganisation(AccountStore.getOrganisation().id) | ||
}, []) | ||
|
||
return ( | ||
<Row> | ||
<AccountProvider onChange={() => onChange && onChange()}> | ||
{({ organisation }: { organisation: unknown }) => | ||
organisation && ( | ||
<OrganisationSelect | ||
onChange={(organisationId: string) => { | ||
AppActions.selectOrganisation(organisationId) | ||
AppActions.getOrganisation(organisationId) | ||
}} | ||
/> | ||
) | ||
} | ||
</AccountProvider> | ||
{!Utils.getFlagsmithHasFeature('disable_create_org') && | ||
(!Project.superUserCreateOnly || | ||
(Project.superUserCreateOnly && AccountStore.isSuper())) && ( | ||
<div> | ||
<Flex className='text-center ml-3'> | ||
<Button | ||
data-test='create-organisation-btn' | ||
onClick={handleCreateOrganisationClick} | ||
size='large' | ||
className='btn btn-with-icon btn-lg px-3' | ||
> | ||
<Icon name='plus' width={24} fill='#656D7B' /> | ||
</Button> | ||
</Flex> | ||
</div> | ||
)} | ||
</Row> | ||
) | ||
} | ||
|
||
export default OrganisationManageWidget |
Oops, something went wrong.