Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various UI improvements #279

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,6 @@ AUTH_BASIC_PASSWORD=password
For full documentation on the platform and more information on deployment, check out our docs.

**[Explore the Docs »](https://docs.parcelvoy.com)**

### Contributing
You can report bugs, suggest features, or just say hi on [Github discussions](https://github.com/parcelvoy/platform/discussions/new/choose)
2 changes: 2 additions & 0 deletions apps/platform/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export default class Api extends Koa {
ctx.status = error.statusCode ?? 400
ctx.body = error
return
} else if (error.status === 404) {
return
} else {
ctx.status = 400
ctx.body = process.env.NODE_ENV === 'production'
Expand Down
1 change: 1 addition & 0 deletions apps/ui/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export interface UserEvent {
id: number
name: string
data: Record<string, any>
created_at: string
}

export type ListState = 'ready' | 'loading'
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/ui/Modal.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.modal {
position: absolute;
position: fixed;
height: 100vh;
width: 100vw;
top: 0;
Expand Down
4 changes: 4 additions & 0 deletions apps/ui/src/ui/Tag.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
border-radius: var(--border-radius-inner);
}

.ui-tag.large {
padding: 10px;
}

.ui-tag.tiny .icon {
width: 12px;
height: 12px;
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/ui/Tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import './Tag.css'
import clsx from 'clsx'

export type TagVariant = 'info' | 'plain' | 'success' | 'error' | 'warn'
export type TagSize = 'tiny' | 'regular'
export type TagSize = 'tiny' | 'regular' | 'large'

export type TagProps = PropsWithChildren<{
onClick?: () => void
Expand Down
5 changes: 3 additions & 2 deletions apps/ui/src/views/journey/JourneyEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -528,12 +528,13 @@ export default function JourneyEditor() {
onClose={() => navigate('../journeys')}
actions={
<>
<Tag variant={journey.published ? 'success' : 'plain'}>
<Tag
variant={journey.published ? 'success' : 'plain'}
size="large">
{journey.published ? 'Published' : 'Draft'}
</Tag>
<Button
variant="secondary"
style={{ marginRight: 5 }}
onClick={() => setEditOpen(true)}
>
{'Edit Details'}
Expand Down
9 changes: 7 additions & 2 deletions apps/ui/src/views/settings/ApiKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ export default function ProjectApiKeys() {
{...state}
columns={[
{ key: 'name' },
{ key: 'scope' },
{
key: 'scope',
cell: ({ item }) => snakeToTitle(item.scope),
},
{
key: 'role',
cell: ({ item }) => item.scope === 'public' ? undefined : item.role,
cell: ({ item }) => item.scope === 'public'
? undefined
: snakeToTitle(item.role ?? ''),
},
{
key: 'value',
Expand Down
10 changes: 8 additions & 2 deletions apps/ui/src/views/settings/Subscriptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import TextInput from '../../ui/form/TextInput'
import { SingleSelect } from '../../ui/form/SingleSelect'
import Button from '../../ui/Button'
import { PlusIcon } from '../../ui/icons'
import { snakeToTitle } from '../../utils'

export default function Subscriptions() {
const navigate = useNavigate()
Expand All @@ -23,7 +24,10 @@ export default function Subscriptions() {
{...state}
columns={[
{ key: 'name' },
{ key: 'channel' },
{
key: 'channel',
cell: ({ item }) => snakeToTitle(item.channel),
},
]}
itemKey={({ item }) => item.id}
onSelectRow={(row) => navigate(`${row.id}`)}
Expand All @@ -48,6 +52,7 @@ export default function Subscriptions() {
>
<FormWrapper<Pick<Subscription, 'name' | 'channel'>>
onSubmit={async ({ name, channel }) => {
console.log(channel)
await api.subscriptions.create(project.id, { name, channel })
await state.reload()
setOpen(false)
Expand All @@ -69,7 +74,8 @@ export default function Subscriptions() {
form={form}
name="channel"
label="Channel"
options={['email', 'push', 'text', 'webhook']}
options={['email', 'push', 'text', 'webhook'].map((channel) => ({ key: channel, label: snakeToTitle(channel) }))}
toValue={x => x.key}
/>
</>
)
Expand Down
33 changes: 10 additions & 23 deletions apps/ui/src/views/settings/Tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,14 @@ export default function Tags() {

const [project] = useContext(ProjectContext)
const search = useSearchTableState(useCallback(async params => await api.tags.search(project.id, params), [project]))
const [editing, setEditing] = useState<null | Tag>(null)
const [editing, setEditing] = useState<Tag>()

return (
<>
<SearchTable
{...search}
columns={[
{
key: 'name',
},
{
key: 'usage',
title: 'Usage',
cell: () => 'TODO',
},
{ key: 'name' },
]}
title="Tags"
description="Use tags to organize and report on your campaigns, journeys, lists, and users."
Expand All @@ -47,30 +40,24 @@ export default function Tags() {
/>
<Modal
open={!!editing}
onClose={() => setEditing(null)}
onClose={() => setEditing(undefined)}
title={editing?.id ? 'Update Tag' : 'Create Tag'}
>
{
editing && (
<FormWrapper<Tag>
onSubmit={async ({ id, name }) => {
if (id) {
await api.tags.update(project.id, id, { name })
} else {
await api.tags.create(project.id, { name })
}
id != null
? await api.tags.update(project.id, id, { name })
: await api.tags.create(project.id, { name })
await search.reload()
setEditing(null)
setEditing(undefined)
}}
defaultValues={editing}
>
{
form => (
<>
<TextInput.Field form={form} name="name" required />
</>
)
}
{form => (
<TextInput.Field form={form} name="name" required />
)}
</FormWrapper>
)
}
Expand Down
27 changes: 16 additions & 11 deletions apps/ui/src/views/users/UserDetailEvents.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { JsonViewer } from '@textea/json-viewer'
import { useCallback, useContext, useState } from 'react'
import api from '../../api'
import { ProjectContext, UserContext } from '../../contexts'
import { useResolver } from '../../hooks'
import { SearchParams, UserEvent } from '../../types'
import Modal from '../../ui/Modal'
import { SearchTable } from '../../ui/SearchTable'
import { JsonPreview } from '../../ui'
import { PreferencesContext } from '../../ui/PreferencesContext'
import { formatDate } from '../../utils'

export default function UserDetailEvents() {
const [preferences] = useContext(PreferencesContext)
const [project] = useContext(ProjectContext)
const [user] = useContext(UserContext)
const [params, setParams] = useState<SearchParams>({
Expand All @@ -30,16 +33,18 @@ export default function UserDetailEvents() {
{ key: 'name' },
{ key: 'created_at' },
]}
onSelectRow={(event) => {
setEvent(event)
}}
onSelectRow={setEvent}
/>
<Modal title={event?.name}
size="large"
open={event != null}
onClose={() => setEvent(undefined)}
>
<JsonViewer value={{ name: event?.name, ...event?.data }} rootName={false} />
</Modal>
{event && (
<Modal
title={event.name}
description={formatDate(preferences, event.created_at)}
size="large"
open={event != null}
onClose={() => setEvent(undefined)}
>
<JsonPreview value={{ name: event.name, ...event.data, created_at: event.created_at }} />
</Modal>
)}
</>
}
Loading