Skip to content

Commit f7e5982

Browse files
committed
Various PR comment improvements, thanks @Polleps
1 parent d675447 commit f7e5982

File tree

8 files changed

+10
-16
lines changed

8 files changed

+10
-16
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function Base({
4444
subtle={subtle}
4545
title={agent ? `Create a new ${title}` : 'No User set - sign in first'}
4646
>
47-
{icon ? <FaPlus /> : label || title}
47+
{icon ? <FaPlus /> : label ?? title}
4848
{children}
4949
</Button>
5050
);

data-browser/src/components/Parent.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ function NestedParent({ subject, depth }: NestedParentProps): JSX.Element {
6565
const [parent] = useString(resource, properties.parent);
6666
const navigate = useNavigate();
6767
const [title] = useTitle(resource);
68-
depth = depth + 1;
6968

7069
// Prevent infinite recursion, set a limit to parent breadcrumbs
7170
if (depth > 5) {
@@ -79,7 +78,7 @@ function NestedParent({ subject, depth }: NestedParentProps): JSX.Element {
7978

8079
return (
8180
<>
82-
{parent && <NestedParent subject={parent} depth={depth} />}
81+
{parent && <NestedParent subject={parent} depth={depth + 1} />}
8382
<Breadcrumb href={subject} onClick={handleClick}>
8483
{title}
8584
</Breadcrumb>

data-browser/src/components/forms/hooks/useSaveResource.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ export const useSaveResource = (
2929
setErr(null);
3030

3131
try {
32-
if (resource.new) {
33-
store.notifyResourceManuallyCreated(resource);
34-
}
35-
3632
await resource.save(store);
3733
setSaving(false);
3834
onSaveSucces();
3935
toast.success('Resource saved');
36+
37+
if (resource.new) {
38+
store.notifyResourceManuallyCreated(resource);
39+
}
4040
} catch (err) {
4141
setErr(err);
4242
setSaving(false);

data-browser/src/views/ErrorPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class ErrorBoundary extends React.Component<
9191
return (
9292
<CrashPage
9393
error={this.state.error}
94-
clearError={() => this.setState(() => ({ error: undefined }))}
94+
clearError={() => this.setState({ error: undefined })}
9595
info={{} as React.ErrorInfo}
9696
/>
9797
);

data-browser/src/views/ImporterPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
InputWrapper,
1010
TextAreaStyled,
1111
} from '../components/forms/InputStyles.jsx';
12-
import Parent from '../components/Parent';
1312
import ResourceCard from './Card/ResourceCard';
1413
import { ErrorLook } from './ResourceInline.jsx';
1514
import { ResourcePageProps } from './ResourcePage';

data-browser/src/views/ResourcePageDefault.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import AllProps from '../components/AllProps';
44
import { ClassDetail } from '../components/ClassDetail';
55
import { ContainerNarrow } from '../components/Containers';
66
import { ValueForm } from '../components/forms/ValueForm';
7-
import Parent from '../components/Parent';
87
import { ResourcePageProps } from './ResourcePage';
98
import { CommitDetail } from '../components/CommitDetail';
109
import { Details } from '../components/Detail';

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
"lib",
4848
"react",
4949
"data-browser"
50-
],
51-
"packageManager": "pnpm@7.11.0"
50+
]
5251
},
52+
"packageManager": "pnpm@7.11.0",
5353
"dependencies": {
5454
"eslint-plugin-import": "^2.26.0"
5555
}

react/src/hooks.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ const titleHookOpts: useValueOptions = {
367367
*/
368368
export function useTitle(
369369
resource: Resource,
370-
truncateLength?: number,
370+
truncateLength = 40,
371371
): [string, (string: string) => Promise<void>] {
372372
const [name, setName] = useString(
373373
resource,
@@ -385,9 +385,6 @@ export function useTitle(
385385
titleHookOpts,
386386
);
387387

388-
// TODO: truncate non urls
389-
truncateLength = truncateLength ? truncateLength : 40;
390-
391388
if (resource.loading) {
392389
return ['...', setName];
393390
}

0 commit comments

Comments
 (0)