Skip to content

Commit 8d5d4e0

Browse files
Pollepsjoepio
authored andcommitted
#747 New Resource Refactor
1 parent 22e5399 commit 8d5d4e0

26 files changed

+272
-437
lines changed

browser/data-browser/src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BrowserRouter } from 'react-router-dom';
22
import { HelmetProvider } from 'react-helmet-async';
33
import { StoreContext, Store } from '@tomic/react';
4+
import { StyleSheetManager } from 'styled-components';
45

56
import { GlobalStyle, ThemeWrapper } from './styling';
67
import { AppRoutes } from './routes/Routes';
@@ -22,7 +23,7 @@ import { PopoverContainer } from './components/Popover';
2223
import { SkipNav } from './components/SkipNav';
2324
import { ControlLockProvider } from './hooks/useControlLock';
2425
import { FormValidationContextProvider } from './components/forms/formValidation/FormValidationContextProvider';
25-
import { StyleSheetManager } from 'styled-components';
26+
import { registerCustomCreateActions } from './components/forms/NewForm/CustomCreateActions';
2627

2728
function fixDevUrl(url: string) {
2829
if (isDev()) {
@@ -60,6 +61,7 @@ const ErrBoundary = window.bugsnagApiKey
6061
// Fetch all the Properties and Classes - this helps speed up the app.
6162
store.preloadPropsAndClasses();
6263

64+
registerCustomCreateActions();
6365
// Register global event handlers.
6466
registerHandlers(store);
6567

browser/data-browser/src/components/NewInstanceButton/NewBookmarkButton.tsx

Lines changed: 0 additions & 102 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { useResource } from '@tomic/react';
2+
3+
import { useSettings } from '../../helpers/AppSettings';
4+
import { useNewResourceUI } from '../forms/NewForm/useNewResourceUI';
5+
import { Base } from './Base';
6+
import { IconType } from 'react-icons';
7+
8+
interface NewInstanceButtonProps {
9+
/** URL of the Class to be instantiated */
10+
klass: string;
11+
subtle?: boolean;
12+
icon?: boolean;
13+
IconComponent?: IconType;
14+
/** subject of the parent Resource, which will be passed to the form */
15+
parent?: string;
16+
/** Give explicit label. If missing, uses the Shortname of the Class */
17+
label?: string;
18+
className?: string;
19+
}
20+
21+
/** A button for creating a new instance of some thing */
22+
export function NewInstanceButton({
23+
klass,
24+
subtle,
25+
icon,
26+
IconComponent,
27+
parent,
28+
children,
29+
label,
30+
className,
31+
}: React.PropsWithChildren<NewInstanceButtonProps>): JSX.Element {
32+
const { drive } = useSettings();
33+
const classResource = useResource(klass);
34+
const showNewResourceUI = useNewResourceUI();
35+
36+
const onClick = () => {
37+
showNewResourceUI(klass, parent ?? drive);
38+
};
39+
40+
return (
41+
<Base
42+
className={className}
43+
onClick={onClick}
44+
IconComponent={IconComponent}
45+
title={classResource.title}
46+
icon={icon}
47+
subtle={subtle}
48+
label={label}
49+
>
50+
{children}
51+
</Base>
52+
);
53+
}

browser/data-browser/src/components/NewInstanceButton/NewInstanceButtonDefault.tsx

Lines changed: 0 additions & 35 deletions
This file was deleted.

browser/data-browser/src/components/NewInstanceButton/NewInstanceButtonProps.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

browser/data-browser/src/components/NewInstanceButton/NewOntologyButton.tsx

Lines changed: 0 additions & 37 deletions
This file was deleted.

browser/data-browser/src/components/NewInstanceButton/NewTableButton.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './NewInstanceButton';

browser/data-browser/src/components/NewInstanceButton/index.tsx

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)