Skip to content

feat: Improve source editing UX #805

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

Open
wants to merge 3 commits into
base: v2
Choose a base branch
from
Open
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
54 changes: 42 additions & 12 deletions packages/app/src/DBSearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
useState,
} from 'react';
import dynamic from 'next/dynamic';
import Link from 'next/link';
import router from 'next/router';
import {
parseAsBoolean,
Expand Down Expand Up @@ -37,6 +38,7 @@ import {
Flex,
Grid,
Group,
Menu,
Modal,
Paper,
Stack,
Expand Down Expand Up @@ -746,7 +748,7 @@ function DBSearchPage() {
[setRowId, setIsLive],
);

const [modelFormExpanded, setModelFormExpanded] = useState(false);
const [modelFormExpanded, setModelFormExpanded] = useState(false); // Used in local mode
const [saveSearchModalState, setSaveSearchModalState] = useState<
'create' | 'update' | undefined
>(undefined);
Expand Down Expand Up @@ -1003,17 +1005,45 @@ function DBSearchPage() {
setNewSourceModalOpened(true);
}}
/>
<ActionIcon
variant="subtle"
color="dark.2"
size="sm"
onClick={() => setModelFormExpanded(v => !v)}
title="Edit Source"
>
<Text size="xs">
<i className="bi bi-gear" />
</Text>
</ActionIcon>
<Menu withArrow position="bottom-start">
<Menu.Target>
<ActionIcon
variant="subtle"
color="dark.2"
size="sm"
title="Edit Source"
>
<Text size="xs">
<i className="bi bi-gear" />
</Text>
</ActionIcon>
</Menu.Target>
<Menu.Dropdown>
<Menu.Label>Sources</Menu.Label>
<Menu.Item
leftSection={<i className="bi bi-plus-circle" />}
onClick={() => setNewSourceModalOpened(true)}
>
Create New Source
</Menu.Item>
{IS_LOCAL_MODE ? (
<Menu.Item
leftSection={<i className="bi bi-gear" />}
onClick={() => setModelFormExpanded(v => !v)}
>
Edit Source
</Menu.Item>
) : (
<Menu.Item
leftSection={<i className="bi bi-gear" />}
component={Link}
href="/team"
>
Edit Sources
</Menu.Item>
)}
</Menu.Dropdown>
</Menu>
</Group>
<Box style={{ minWidth: 100, flexGrow: 1 }}>
<SQLInlineEditorControlled
Expand Down
17 changes: 6 additions & 11 deletions packages/app/src/TeamPage.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { Fragment, useCallback, useMemo, useState } from 'react';
import Head from 'next/head';
import { HTTPError } from 'ky';
import {
Button as BSButton,
Form,
Modal as BSModal,
Spinner,
} from 'react-bootstrap';
import { Button as BSButton, Modal as BSModal } from 'react-bootstrap';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import { SubmitHandler, useForm } from 'react-hook-form';
import { json, jsonParseLinter } from '@codemirror/lang-json';
Expand All @@ -19,10 +14,12 @@ import {
Box,
Button,
Card,
Center,
Container,
Divider,
Flex,
Group,
Loader,
Modal as MModal,
Radio,
Stack,
Expand All @@ -46,8 +43,6 @@ import { useSources } from './source';
import { useConfirm } from './useConfirm';
import { capitalizeFirstLetter } from './utils';

import styles from '../styles/TeamPage.module.scss';

const DEFAULT_GENERIC_WEBHOOK_BODY = ['{{title}}', '{{body}}', '{{link}}'];
const DEFAULT_GENERIC_WEBHOOK_BODY_TEMPLATE =
DEFAULT_GENERIC_WEBHOOK_BODY.join(' | ');
Expand Down Expand Up @@ -1223,9 +1218,9 @@ export default function TeamPage() {
<div>
<Container>
{isLoading && (
<Spinner animation="border" role="status">
<span className="visually-hidden">Loading...</span>
</Spinner>
<Center mt="xl">
<Loader color="dimmed" />
</Center>
)}
{!isLoading && team != null && (
<Stack my={20} gap="xl">
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/components/ConfirmDeleteMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function ConfirmDeleteMenu({
onDelete: () => void;
}) {
return (
<Menu>
<Menu withArrow>
<Menu.Target>
<Button variant="outline" color="gray.4" size="xs">
Delete
Expand Down
9 changes: 0 additions & 9 deletions packages/app/styles/TeamPage.module.scss

This file was deleted.