Skip to content

Commit 735d940

Browse files
committed
Organization update to add My Account and start of reseller support
1 parent 5555e6e commit 735d940

13 files changed

+402
-332
lines changed

frontend/src/components/Avatar/Avatar.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface Props {
1717
active?: boolean
1818
border?: number
1919
fallback?: string
20+
marginRight?: number
2021
children?: React.ReactNode
2122
}
2223

@@ -30,11 +31,12 @@ export const Avatar: React.FC<Props> = ({
3031
active,
3132
border = 1,
3233
fallback,
34+
marginRight,
3335
children,
3436
}) => {
3537
const url = `https://www.gravatar.com/avatar/${md5(email || '')}?s=${size * 2}&d=force-fail`
3638
const color = createColor(email)
37-
const css = useStyles({ size, color, button, inline, active, border })
39+
const css = useStyles({ size, color, button, inline, marginRight, active, border })
3840
fallback = (fallback || email || '?').substring(0, 1).toUpperCase()
3941

4042
let Element = (
@@ -57,10 +59,18 @@ export const Avatar: React.FC<Props> = ({
5759
)
5860
}
5961

60-
type StyleProps = { button?: boolean; inline?: boolean; active?: boolean; size: number; color: number; border: number }
62+
type StyleProps = {
63+
button?: boolean
64+
inline?: boolean
65+
marginRight?: number
66+
active?: boolean
67+
size: number
68+
color: number
69+
border: number
70+
}
6171

6272
const useStyles = makeStyles(({ palette }) => ({
63-
avatar: ({ size, color, inline, border }: StyleProps) => ({
73+
avatar: ({ size, color, inline, marginRight, border }: StyleProps) => ({
6474
color: palette.alwaysWhite.main,
6575
fontSize: size * 0.625,
6676
height: size,
@@ -70,7 +80,7 @@ const useStyles = makeStyles(({ palette }) => ({
7080
fontFamily: 'Roboto Mono',
7181
backgroundColor: labelLookup[color].color,
7282
border: `${border}px solid ${palette.white.main}`,
73-
marginRight: inline ? spacing.sm : 0,
83+
marginRight: inline ? spacing.sm : marginRight,
7484
}),
7585
button: ({ active, border }: StyleProps) => ({
7686
backgroundColor: active ? undefined : palette.white.main,
Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import React from 'react'
2-
import { makeStyles } from '@mui/styles'
32
import { LinearProgress as MuiLinearProgress } from '@mui/material'
43

54
type Props = { loading?: boolean }
65

7-
export const LinearProgress: React.FC<Props> = ({ loading }) => {
8-
const css = useStyles()
9-
return loading ? <MuiLinearProgress className={css.loading} /> : null
10-
}
11-
12-
const useStyles = makeStyles({
13-
loading: {
14-
position: 'absolute',
15-
width: '100%',
16-
zIndex: 10,
17-
height: 1,
18-
bottom: 0,
19-
left: 0,
20-
},
21-
})
6+
export const LinearProgress: React.FC<Props> = ({ loading }) =>
7+
loading ? (
8+
<MuiLinearProgress
9+
sx={{
10+
position: 'absolute',
11+
width: '100%',
12+
zIndex: 10,
13+
height: '1px',
14+
bottom: 0,
15+
left: 0,
16+
}}
17+
/>
18+
) : null

frontend/src/components/OrganizationGuestDetails.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import React, { useEffect, useState } from 'react'
22
import { getAllDevices } from '../selectors/devices'
3-
import { useSelector, useDispatch } from 'react-redux'
43
import { selectNetworks } from '../selectors/networks'
4+
import { useSelector, useDispatch } from 'react-redux'
5+
import { LinearProgress, Typography, List, Box } from '@mui/material'
56
import { State, Dispatch } from '../store'
6-
import { Typography, List, Box } from '@mui/material'
77
import { ListItemLocation } from './ListItemLocation'
8+
import { LoadingMessage } from './LoadingMessage'
89
import { TargetPlatform } from './TargetPlatform'
910
import { ShareDetails } from './ShareDetails'
1011
import { Gutters } from './Gutters'
1112
import { Icon } from './Icon'
1213

1314
type Props = {
14-
loaded: boolean
1515
guest?: IGuest
16+
loaded?: boolean
1617
}
1718

1819
export const OrganizationGuestDetails: React.FC<Props> = ({ guest, loaded }) => {
@@ -37,7 +38,9 @@ export const OrganizationGuestDetails: React.FC<Props> = ({ guest, loaded }) =>
3738

3839
useEffect(() => {
3940
if (!loaded) dispatch.organization.fetchGuests()
40-
}, [guest])
41+
}, [guest, loaded])
42+
43+
if (!loaded) return <LinearProgress color="info" sx={{ marginTop: 5, marginX: 5, height: '1px' }} />
4144

4245
if (!guest?.deviceIds.length && !guest?.networkIds.length) return null
4346

frontend/src/components/OrganizationMember.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const OrganizationMember: React.FC<Props> = ({ member, roles = [], disabl
4444
onClick={event => event.stopPropagation()}
4545
/>
4646
{!enterprise && (
47-
<Box width={120} display="inline-block" textAlign="right" marginRight={`${spacing.md}px`}>
47+
<Box width={90} display="inline-block" textAlign="right" marginRight={`${spacing.md}px`}>
4848
<LicenseSelect member={member} disabled={disabled} />
4949
</Box>
5050
)}

frontend/src/components/OrganizationMemberDetails.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ import { Typography, List, Box } from '@mui/material'
99
import { RoleAccessCounts } from './RoleAccessCounts'
1010
import { ListItemLocation } from './ListItemLocation'
1111
import { LicenseSelect } from './LicenseSelect'
12+
import { FormDisplay } from './FormDisplay'
1213
import { RoleSelect } from './RoleSelect'
13-
import { Duration } from '../components/Duration'
14+
import { Timestamp } from './Timestamp'
1415
import { Gutters } from './Gutters'
1516
import { Icon } from './Icon'
1617

1718
type Props = {
18-
member: IOrganizationMember
19+
member?: IOrganizationMember
1920
organization: IOrganizationState
2021
}
2122

@@ -36,9 +37,6 @@ export const OrganizationMemberDetails: React.FC<Props> = ({ member, organizatio
3637
<>
3738
<Typography variant="subtitle1">Member</Typography>
3839
<Gutters>
39-
<Typography variant="caption" marginBottom={3} component="div">
40-
Since <Duration startTime={member?.created?.getTime()} ago />
41-
</Typography>
4240
<Box display="flex" flexWrap="wrap" alignItems="center" justifyContent="space-between">
4341
<Box display="flex" marginRight={2} gap={1}>
4442
<RoleSelect
@@ -61,6 +59,12 @@ export const OrganizationMemberDetails: React.FC<Props> = ({ member, organizatio
6159
</Box>
6260
</Box>
6361
</Gutters>
62+
<FormDisplay
63+
icon={<Icon name="calendar-star" />}
64+
label="Member since"
65+
displayValue={<Timestamp date={member?.created} />}
66+
displayOnly
67+
/>
6468
</>
6569
)}
6670
{!!accessible.length && (

frontend/src/components/OrganizationMemberList.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const OrganizationMemberList: React.FC<Props> = ({ organization, owner, e
1717
<OrganizationMember
1818
disabled
1919
key={owner.user.id}
20-
link={false}
20+
link={true}
2121
member={owner}
2222
roles={organization?.roles}
2323
enterprise={enterprise}

0 commit comments

Comments
 (0)