Skip to content

Commit

Permalink
feat: Update to latest design-system (#1266)
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmar authored Oct 25, 2023
1 parent 6425dcd commit a2eef51
Show file tree
Hide file tree
Showing 32 changed files with 2,485 additions and 2,941 deletions.
2 changes: 2 additions & 0 deletions www/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ module.exports = {
rules: {
'@typescript-eslint/consistent-type-exports': 'error',
'import-newlines/enforce': 'off',
// Allow css prop for styled-components
'react/no-unknown-property': ['error', { ignore: ['css'] }],
},
}
19 changes: 11 additions & 8 deletions www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@nivo/geo": "0.83.0",
"@nivo/line": "0.83.0",
"@octokit/core": "4.2.1",
"@pluralsh/design-system": "1.343.0",
"@pluralsh/design-system": "3.4.1",
"@react-spring/web": "9.7.2",
"@stripe/react-stripe-js": "2.1.0",
"@stripe/stripe-js": "1.54.0",
Expand Down Expand Up @@ -134,7 +134,7 @@
"@graphql-codegen/typescript": "4.0.0",
"@graphql-codegen/typescript-operations": "4.0.0",
"@graphql-codegen/typescript-react-apollo": "3.3.7",
"@pluralsh/eslint-config-typescript": "2.5.41",
"@pluralsh/eslint-config-typescript": "2.5.84",
"@pluralsh/stylelint-config": "1.1.3",
"@types/events": "3.0.0",
"@types/jsdom": "21.1.1",
Expand All @@ -145,11 +145,12 @@
"@types/react-stripe-elements": "6.0.6",
"@types/styled-components": "5.1.26",
"@types/uuid": "9.0.1",
"@typescript-eslint/eslint-plugin": "5.59.9",
"@typescript-eslint/parser": "5.59.9",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"@vitejs/plugin-basic-ssl": "1.0.1",
"@vitejs/plugin-react": "4.0.0",
"@vitest/ui": "0.32.0",
"@vitest/ui": "0.34.3",
"babel-plugin-styled-components": "2.1.4",
"concurrently": "8.1.0",
"eslint": "8.42.0",
"eslint-config-pluralsh": "3.1.0",
Expand All @@ -169,10 +170,12 @@
"source-map-explorer": "2.5.3",
"stylelint": "15.7.0",
"stylelint-config-prettier": "9.0.5",
"typescript": "4.9.5",
"typescript": "5.2.2",
"vite": "4.4.9",
"vite-plugin-pwa": "0.16.4",
"vitest": "0.32.0",
"vite-plugin-pwa": "0.16.3",
"vite-plugin-rewrite-all": "1.0.1",
"vite-tsconfig-paths": "4.2.0",
"vitest": "0.34.3",
"wait-on": "7.0.1"
},
"lint-staged": {
Expand Down
6 changes: 3 additions & 3 deletions www/src/components/Invite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useState } from 'react'
import { useParams } from 'react-router-dom'

import {
Invite,
Invite as InviteT,
User,
useInviteQuery,
useRealizeInviteMutation,
Expand Down Expand Up @@ -38,7 +38,7 @@ function ExistingInvite({
id,
user,
}: {
invite: Invite
invite: InviteT
id: any
user: User
}) {
Expand Down Expand Up @@ -119,7 +119,7 @@ export default function Invite() {
if (data?.invite?.user) {
return (
<ExistingInvite
invite={data?.invite as Invite}
invite={data?.invite as InviteT}
id={inviteId}
user={data?.invite?.user as User}
/>
Expand Down
14 changes: 9 additions & 5 deletions www/src/components/account/CreateGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactNode, useCallback, useContext, useEffect, useState } from 'react'
import { Box } from 'grommet'
import { Button, Modal, ValidatedInput } from '@pluralsh/design-system'
import { useTheme } from 'styled-components'

import { appendConnection, updateCache } from '../../utils/graphql'
import { GqlError } from '../utils/Alert'
Expand All @@ -10,6 +10,7 @@ import SubscriptionContext from '../../contexts/SubscriptionContext'
import BillingFeatureBlockModal from './billing/BillingFeatureBlockModal'

export function CreateGroup({ q }: any) {
const theme = useTheme()
const { availableFeatures } = useContext(SubscriptionContext)
const isAvailable = !!availableFeatures?.userManagement
const [createModalVisible, setCreateModalVisible] = useState(false)
Expand Down Expand Up @@ -82,9 +83,12 @@ export function CreateGroup({ q }: any) {
</>
}
>
<Box
width="50vw"
gap="small"
<div
css={{
display: 'flex',
flexDirection: 'column',
gap: theme.spacing.medium,
}}
>
{errorMsg}
<ValidatedInput
Expand All @@ -97,7 +101,7 @@ export function CreateGroup({ q }: any) {
value={description}
onChange={({ target: { value } }) => setDescription(value)}
/>
</Box>
</div>
</Modal>
<BillingFeatureBlockModal
open={blockModalVisible}
Expand Down
2 changes: 1 addition & 1 deletion www/src/components/account/CreateServiceAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function ServiceAccountForm({
return (
<Box
fill
gap="small"
gap="medium"
{...box}
>
{error && (
Expand Down
2 changes: 1 addition & 1 deletion www/src/components/account/EditGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export function EditGroupAttributes({ group, open, onClose }: any) {
/>
<Switch
checked={global}
onChange={({ target: { checked } }) => update({ global: checked })}
onChange={(checked) => update({ global: checked })}
>
Apply globally
</Switch>
Expand Down
1 change: 0 additions & 1 deletion www/src/components/account/Group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function GroupMember({ user, group, first, last, edit }: any) {
return (
<ListItem
flex={false}
background="fill-two"
first={first}
last={last}
>
Expand Down
16 changes: 6 additions & 10 deletions www/src/components/account/InviteUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { Button, Div, P, Span } from 'honorable'
import { useCallback, useContext, useState } from 'react'
import { Link } from 'react-router-dom'

import { toNumber } from 'lodash'

import { useCurrentUser } from '../../contexts/CurrentUserContext'
import SubscriptionContext from '../../contexts/SubscriptionContext'
import { GqlError } from '../utils/Alert'
Expand Down Expand Up @@ -40,16 +42,10 @@ export function InviteUser({ refetch }: { refetch?: (() => void) | null }) {
}, [reset])

const attemptInvite = useCallback(() => {
console.log('attempt', {
isGrandfathered,
isPaidPlan,
userCount: account?.userCount,
})
if (
!isGrandfathered &&
!isPaidPlan &&
(account?.userCount ?? 0) >= MAX_OPEN_SOURCE_USERS
) {
let userCount = toNumber(account?.userCount)

userCount = Number.isNaN(userCount) ? 0 : userCount
if (!isGrandfathered && !isPaidPlan && userCount >= MAX_OPEN_SOURCE_USERS) {
setShowLimitModal(true)
} else {
setShowInviteModal(true)
Expand Down
15 changes: 10 additions & 5 deletions www/src/components/account/Role.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Box } from 'grommet'
import { ValidatedInput } from '@pluralsh/design-system'
import { useState } from 'react'

import { useTheme } from 'styled-components'

import { BindingInput } from './Typeaheads'

export function GeneralAttributes({
Expand All @@ -10,14 +11,18 @@ export function GeneralAttributes({
bindings,
setBindings,
}: any) {
const theme = useTheme()
const [repositories, setRepositories] = useState(
attributes.repositories?.join(', ')
)

return (
<Box
flex={false}
gap="small"
<div
css={{
display: 'flex',
flexDirection: 'column',
rowGap: theme.spacing.medium,
}}
>
<ValidatedInput
label="Name"
Expand Down Expand Up @@ -68,6 +73,6 @@ export function GeneralAttributes({
)
}
/>
</Box>
</div>
)
}
105 changes: 78 additions & 27 deletions www/src/components/account/RoleForm.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Box } from 'grommet'
import { Span, Switch } from 'honorable'
import { Tab, TabList, TabPanel } from '@pluralsh/design-system'
import { Switch, Tab, TabList, TabPanel } from '@pluralsh/design-system'
import { useCallback, useRef, useState } from 'react'

import { ListItem } from '../profile/ListItem'
import { useTheme } from 'styled-components'

import { GqlError } from '../utils/Alert'

import { List, ListItem } from '../utils/List'

import { PermissionTypes } from './types'

import { GeneralAttributes } from './Role'
Expand All @@ -18,6 +19,7 @@ function PermissionToggle({
first,
last,
}: any) {
const theme = useTheme()
const toggle = useCallback(
(enable) => {
if (enable) {
Expand All @@ -41,15 +43,37 @@ function PermissionToggle({
<ListItem
first={first}
last={last}
background="fill-two"
>
<Box fill="horizontal">
<Span fontWeight={500}>{permission.toLowerCase()}</Span>
<Span color="text-light">{description}</Span>
</Box>
<div
css={{
display: 'flex',
flexDirection: 'column',
width: '100%',
}}
>
<h4
className="stuff"
css={{
...theme.partials.text.body1Bold,
margin: 0,
}}
>
{permission.toLowerCase()}
</h4>
<p
css={{
...theme.partials.text.body2,
color: theme.colors['text-light'],
margin: 0,
}}
color="text-light"
>
{description}
</p>
</div>
<Switch
checked={!!attributes.permissions.find((perm) => perm === permission)}
onChange={({ target: { checked } }) => toggle(checked)}
onChange={(checked) => toggle(checked)}
/>
</ListItem>
)
Expand All @@ -61,24 +85,31 @@ const TABS = {
}

export function RoleForm({
// eslint-disable-next-line
error,
attributes,
setAttributes,
bindings,
setBindings,
...box
}): any {
}: {
error: any
attributes: any
setAttributes: any
bindings: any
setBindings: any
}) {
const theme = useTheme()
const [view, setView] = useState('General')
const permissions = Object.entries(PermissionTypes)
const len = permissions.length
const tabStateRef = useRef<any>(null)

return (
<Box
flex={false}
gap="small"
{...box}
<div
css={{
display: 'flex',
flexDirection: 'column',
gap: theme.spacing.medium,
}}
>
{error && (
<GqlError
Expand Down Expand Up @@ -108,14 +139,34 @@ export function RoleForm({
/>
)}
{view === 'Permissions' && (
<Box gap="small">
<Box>
<Span fontWeight="bold">Permissions</Span>
<Span>
<div
css={{
display: 'flex',
flexDirection: 'column',
gap: theme.spacing.small,
}}
>
<div
css={{
display: 'flex',
flexDirection: 'column',
gap: theme.spacing.xxsmall,
}}
>
<h3 css={{ ...theme.partials.text.body1Bold, margin: 0 }}>
Permissions
</h3>
<p
css={{
...theme.partials.text.body2,
margin: 0,
color: theme.colors['text-light'],
}}
>
Grant permissions to all users and groups bound to this role
</Span>
</Box>
<Box>
</p>
</div>
<List hue="lighter">
{permissions.map(([perm, description], i) => (
<PermissionToggle
key={perm}
Expand All @@ -127,10 +178,10 @@ export function RoleForm({
last={i === len - 1}
/>
))}
</Box>
</Box>
</List>
</div>
)}
</TabPanel>
</Box>
</div>
)
}
Loading

0 comments on commit a2eef51

Please sign in to comment.