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

Register using e-mail address #238

Draft
wants to merge 34 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
31f7b4f
#236-update-url
joepio Oct 10, 2022
4281c7e
Open new folders without dialog
joepio Oct 12, 2022
2c4953b
Fix empty agent
joepio Oct 12, 2022
677edf2
Fix redirect after file upload
joepio Oct 15, 2022
c9b19a4
#248 open only one menu on keyboard shortcut
joepio Oct 16, 2022
8a2c2be
Fix base url default
joepio Oct 16, 2022
80a7832
Add extra icons and fix spec
joepio Oct 19, 2022
67fe563
#208 Sign in guards WIP
joepio Oct 25, 2022
474dfcb
Update PR template
joepio Oct 27, 2022
7d27dfc
Prettier error
joepio Nov 2, 2022
4cde06c
Fix compile error
joepio Nov 2, 2022
4d32a73
WIP
joepio Nov 27, 2022
d07bc96
Fix authenticate ws before connection bug
joepio Nov 30, 2022
d372517
Refactor register
joepio Dec 27, 2022
bbaaa80
Confirm Email
joepio Dec 27, 2022
72ca84a
Remove console log and update changelog
joepio Dec 29, 2022
ac4cc79
Various registration UX improvements #238
joepio Dec 31, 2022
37252d2
Add-pubkey modal, refactor register comps #238
joepio Jan 3, 2023
c755770
#282 remove cookie automatically
joepio Jan 16, 2023
b25fb08
Fix localhost detection for subdomains
joepio Jan 17, 2023
9c261a2
use consts for query param keys
joepio Jan 17, 2023
d9eb9ea
Fix ChatRoom message input height and autoresize
joepio Jan 17, 2023
d78cf0c
fix node test
joepio Jan 17, 2023
8616053
Fix e2e tests
joepio Jan 17, 2023
f71c942
#282 cookie clean up
joepio Jan 20, 2023
6bbfbf3
Fix imports
joepio Jan 20, 2023
9c4584d
`store.createSubject` allows creating nested paths
joepio Feb 5, 2023
19d0696
Improve error handler
joepio Feb 14, 2023
dfb39fe
Add article URLs
joepio Feb 14, 2023
dc2a64c
Add `useChildren` hook and `Store.getChildren` method
joepio Feb 14, 2023
9a54a79
Importer uses Post
joepio Feb 14, 2023
5bcbb0c
Add script tag for atomic-server
joepio Feb 14, 2023
f4242c8
Drive doesn't need a parent
joepio Feb 14, 2023
869818f
Update changelog
joepio Feb 14, 2023
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
11 changes: 11 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
"isBackground": true,
"group": "build"
},
{
"type": "npm",
"script": "build-server",
"problemMatcher": [
"$tsc-watch"
],
"label": "build server JS assets",
"detail": "pnpm workspace @tomic/data-browser build-server",
"isBackground": true,
"group": "build"
},
{
"type": "npm",
"script": "test",
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ This changelog covers all three packages, as they are (for now) updated as a who

## UNRELEASED

- Let users register using e-mail address, improve sign-up UX.
- Add `Store.parseMetaTags` to load JSON-AD objects stored in the DOM. Speeds up initial page load by allowing server to set JSON-AD objects in the initial HTML response.
- Move static assets around, align build with server and fix PWA #292
- `store.createSubject` allows creating nested paths
- Add `useChildren` hook and `Store.getChildren` method

## v0.35.0

Expand Down
2 changes: 2 additions & 0 deletions data-browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
</style>
<!-- Meta tags and code added by Atomic-Server -->
<!-- { inject_html_head } -->
<!-- Javascript added by Atomic-Server -->
<!-- { inject_script } -->
</head>

<body>
Expand Down
8 changes: 6 additions & 2 deletions data-browser/src/components/ClassDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { properties, Resource, useString } from '@tomic/react';
import { ResourceInline } from '../views/ResourceInline';
import { Detail } from './Detail';
import { getIconForClass } from '../views/FolderPage/iconMap';

type Props = {
resource: Resource;
Expand All @@ -15,8 +16,11 @@ export function ClassDetail({ resource }: Props): JSX.Element {
<React.Fragment>
{klass && (
<Detail>
{'is a '}
<ResourceInline subject={klass} />
<>
{'is a '}
{getIconForClass(klass)}
<ResourceInline subject={klass} />
</>
</Detail>
)}
</React.Fragment>
Expand Down
14 changes: 11 additions & 3 deletions data-browser/src/components/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import { Button } from './Button';
interface CodeBlockProps {
content?: string;
loading?: boolean;
wrapContent?: boolean;
}

export function CodeBlock({ content, loading }: CodeBlockProps) {
/** Codeblock with copy feature */
export function CodeBlock({ content, loading, wrapContent }: CodeBlockProps) {
const [isCopied, setIsCopied] = useState<string | undefined>(undefined);

function copyToClipboard() {
Expand All @@ -19,7 +21,7 @@ export function CodeBlock({ content, loading }: CodeBlockProps) {
}

return (
<CodeBlockStyled data-code-content={content}>
<CodeBlockStyled data-code-content={content} wrapContent={wrapContent}>
{loading ? (
'loading...'
) : (
Expand All @@ -46,7 +48,11 @@ export function CodeBlock({ content, loading }: CodeBlockProps) {
);
}

export const CodeBlockStyled = styled.pre`
interface Props {
wrapContent?: boolean;
}

export const CodeBlockStyled = styled.pre<Props>`
position: relative;
background-color: ${p => p.theme.colors.bg1};
border-radius: ${p => p.theme.radius};
Expand All @@ -55,4 +61,6 @@ export const CodeBlockStyled = styled.pre`
font-family: monospace;
width: 100%;
overflow-x: auto;
word-wrap: ${p => (p.wrapContent ? 'break-word' : 'initial')};
white-space: ${p => (p.wrapContent ? 'pre-wrap' : 'initial')};
`;
14 changes: 7 additions & 7 deletions data-browser/src/components/Dialog/useDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { useCallback, useMemo, useState } from 'react';
import { InternalDialogProps } from './index';

export type UseDialogReturnType = [
export type UseDialogReturnType = {
/** Props meant to pass to a {@link Dialog} component */
dialogProps: InternalDialogProps,
dialogProps: InternalDialogProps;
/** Function to show the dialog */
show: () => void,
show: () => void;
/** Function to close the dialog */
close: () => void,
close: () => void;
/** Boolean indicating wether the dialog is currently open */
isOpen: boolean,
];
isOpen: boolean;
};

/** Sets up state, and functions to use with a {@link Dialog} */
export const useDialog = (): UseDialogReturnType => {
Expand Down Expand Up @@ -40,5 +40,5 @@ export const useDialog = (): UseDialogReturnType => {
[showDialog, close, handleClosed],
);

return [dialogProps, show, close, visible];
return { dialogProps, show, close, isOpen: visible };
};
5 changes: 4 additions & 1 deletion data-browser/src/components/Dropdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ interface DropdownMenuProps {
/** The list of menu items */
items: Item[];
trigger: DropdownTriggerRenderFunction;
/** Enables the keyboard shortcut */
isMainMenu?: boolean;
}

/** Gets the index of an array and loops around when at the beginning or end */
Expand Down Expand Up @@ -88,6 +90,7 @@ function normalizeItems(items: Item[]) {
export function DropdownMenu({
items,
trigger,
isMainMenu,
}: DropdownMenuProps): JSX.Element {
const menuId = useId();
const dropdownRef = useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -167,7 +170,7 @@ export function DropdownMenu({
handleToggle();
setUseKeys(true);
},
{},
{ enabled: !!isMainMenu },
[isActive],
);
// Click / open the item
Expand Down
23 changes: 16 additions & 7 deletions data-browser/src/components/ErrorLook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { lighten } from 'polished';
import styled from 'styled-components';
import React from 'react';
import { FaExclamationTriangle } from 'react-icons/fa';
import { Column } from './Row';

export const ErrorLook = styled.span`
color: ${props => props.theme.colors.alert};
Expand All @@ -20,13 +21,21 @@ export function ErrorBlock({ error, showTrace }: ErrorBlockProps): JSX.Element {
<FaExclamationTriangle />
Something went wrong
</BiggerText>
<CodeBlock>{error.message}</CodeBlock>
{showTrace && (
<>
<span>Stack trace:</span>
<CodeBlock>{error.stack}</CodeBlock>
</>
)}
<Column>
<CodeBlock>{error.message}</CodeBlock>
{showTrace && (
<>
Stack trace:
<CodeBlock
style={{
maxHeight: '10rem',
}}
>
{error.stack}
</CodeBlock>
</>
)}
</Column>
</ErrorLookBig>
);
}
Expand Down
17 changes: 17 additions & 0 deletions data-browser/src/components/Guard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { useSettings } from '../helpers/AppSettings';
import { RegisterSignIn } from './RegisterSignIn';

/**
* The Guard can be wrapped around a Component that depends on a user being logged in.
* If the user is not logged in, it will show a button to sign up / sign in.
* Show to users after a new Agent has been created.
* Instructs them to save their secret somewhere safe
*/
export function Guard({ children }: React.PropsWithChildren<any>): JSX.Element {
const { agent } = useSettings();

if (agent) {
return <>{children}</>;
} else return <RegisterSignIn />;
}
1 change: 1 addition & 0 deletions data-browser/src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ function NavBar(): JSX.Element {

{showButtons && subject && (
<ResourceContextMenu
isMainMenu
subject={subject}
trigger={MenuBarDropdownTrigger}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function NewBookmarkButton({

const [url, setUrl] = useState('');

const [dialogProps, show, hide] = useDialog();
const { dialogProps, show, close } = useDialog();

const createResourceAndNavigate = useCreateAndNavigate(klass, parent);

Expand Down Expand Up @@ -86,7 +86,7 @@ export function NewBookmarkButton({
</form>
</DialogContent>
<DialogActions>
<Button onClick={hide} subtle>
<Button onClick={close} subtle>
Cancel
</Button>
<Button onClick={onDone} disabled={url.trim() === ''}>
Expand Down
88 changes: 0 additions & 88 deletions data-browser/src/components/NewInstanceButton/NewFolderButton.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions data-browser/src/components/NewInstanceButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import { NewBookmarkButton } from './NewBookmarkButton';
import { NewInstanceButtonProps } from './NewInstanceButtonProps';
import { NewInstanceButtonDefault } from './NewInstanceButtonDefault';
import { useSettings } from '../../helpers/AppSettings';
import { NewFolderButton } from './NewFolderButton';

type InstanceButton = (props: NewInstanceButtonProps) => JSX.Element;

/** If your New Instance button requires custom logic, such as a custom dialog */
const classMap = new Map<string, InstanceButton>([
[classes.bookmark, NewBookmarkButton],
[classes.folder, NewFolderButton],
]);

/** A button for creating a new instance of some thing */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { useNavigate } from 'react-router-dom';
import { constructOpenURL } from '../../helpers/navigation';

/**
* Hook that builds a function that will create a new resoure with the given
* Hook that builds a function that will create a new resource with the given
* properties and then navigate to it.
*
* @param klass The type of resource to create a new instance of.
Expand All @@ -34,7 +34,7 @@ export function useCreateAndNavigate(klass: string, parent?: string) {
/** Do not set a parent for the new resource. Useful for top-level resources */
noParent?: boolean,
): Promise<Resource> => {
const subject = store.createSubject(className);
const subject = store.createSubject(className, parent);
const resource = new Resource(subject, true);

await Promise.all([
Expand Down
Loading