Skip to content

Commit e83a734

Browse files
authored
Merge branch 'develop' into 543-s3-uploads
2 parents 3ac37e5 + 6337c2f commit e83a734

21 files changed

+230
-140
lines changed

Earthfile

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
VERSION --try --global-cache 0.7
22
PROJECT ontola/atomic-server
33
IMPORT ./browser AS browser
4-
IMPORT github.com/earthly/lib/rust:2.2.11 AS rust
4+
IMPORT github.com/earthly/lib/rust AS rust
55
FROM rust:1.73.0-buster
66
WORKDIR /code
77

@@ -41,20 +41,20 @@ source:
4141
COPY --keep-ts Cargo.toml Cargo.lock ./
4242
COPY --keep-ts --dir server lib cli ./
4343
COPY browser+build/dist /code/browser/data-browser/dist
44+
DO rust+CARGO --args=fetch
4445

4546
cross-build:
4647
FROM +source
4748
ARG --required TARGET
48-
# This does not yet cache properly
49-
# https://github.com/earthly/lib/issues/34
49+
DO rust+GET_RUST_CACHE_MOUNTS
5050
WITH DOCKER
51-
RUN cross build --target $TARGET --release
51+
RUN --mount=$EARTHLY_RUST_CARGO_HOME_CACHE --mount=$EARTHLY_RUST_TARGET_CACHE cross build --target $TARGET --release
5252
END
5353
SAVE ARTIFACT ./target/$TARGET/release/atomic-server AS LOCAL artifact/bin/atomic-server-$TARGET
5454

5555
build:
5656
FROM +source
57-
DO rust+CARGO --args="build --release" --output="release/[^/\.]+"
57+
DO rust+CARGO --args="build --offline --release" --output="release/[^/\.]+"
5858
RUN ./target/release/atomic-server --version
5959
SAVE ARTIFACT ./target/release/atomic-server AS LOCAL artifact/bin/atomic-server-x86_64-unknown-linux-gnu
6060

browser/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ This changelog covers all three packages, as they are (for now) updated as a who
77
### Atomic Browser
88

99
- [#747](https://github.com/atomicdata-dev/atomic-server/issues/747) Show ontology classes on new resource page.
10+
- [#770](https://github.com/atomicdata-dev/atomic-server/issues/770) Display more info on search result page.
11+
- [#771](https://github.com/atomicdata-dev/atomic-server/issues/771) Tables: Don't paste in multiple rows when focussed on an input
12+
- [#758](https://github.com/atomicdata-dev/atomic-server/issues/758) Fix Relation column forms to close when clicking on the searchbox
1013
- Fix server not rebuilding client when files changed.
1114

1215
## v0.36.2

browser/data-browser/src/components/Card.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,19 @@ type CardProps = {
1111
/** A Card with a border. */
1212
export const Card = styled.div<CardProps>`
1313
background-color: ${props => props.theme.colors.bg};
14-
/** Don't put side margins in this component - use a wrapping component */
15-
border: solid 1px ${props => props.theme.colors.bg2};
16-
box-shadow: ${props => props.theme.boxShadow};
14+
15+
border: solid 1px
16+
${props =>
17+
props.highlight ? props.theme.colors.main : props.theme.colors.bg2};
18+
box-shadow: ${props =>
19+
props.highlight
20+
? `0 0 0 1px ${props.theme.colors.main}, ${props.theme.boxShadow}`
21+
: props.theme.boxShadow};
22+
1723
padding: ${props => props.theme.margin}rem;
18-
/* margin-bottom: ${props => props.theme.margin}rem; */
19-
padding-bottom: 0;
2024
border-radius: ${props => props.theme.radius};
2125
max-height: ${props => (props.small ? '10rem' : 'none')};
2226
overflow: ${props => (props.small ? 'hidden' : 'visible')};
23-
border-color: ${props =>
24-
props.highlight ? props.theme.colors.main : props.theme.colors.bg2};
2527
2628
${p => transitionName('resource-page', p.about)};
2729
`;

browser/data-browser/src/components/Navigation.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ const NavBarBase = styled.div<NavBarStyledProps>`
166166
/** Width of the floating navbar in rem */
167167
const NavBarFloating = styled(NavBarBase)`
168168
box-shadow: ${props => props.theme.boxShadow};
169-
box-sizing: border-box;
170169
border-radius: 999px;
171170
overflow: hidden;
172171
max-width: calc(100% - 2rem);
@@ -179,6 +178,11 @@ const NavBarFloating = styled(NavBarBase)`
179178
top: ${props => (props.top ? '2rem' : 'auto')};
180179
bottom: ${props => (props.top ? 'auto' : '1rem')};
181180
181+
&:has(input:focus) {
182+
box-shadow: 0px 0px 0px 1px ${props => props.theme.colors.main};
183+
border-color: ${props => props.theme.colors.main};
184+
}
185+
182186
@media (max-width: ${props => props.theme.containerWidth}rem) {
183187
max-width: calc(100% - 1rem);
184188
left: auto;
@@ -198,6 +202,10 @@ const NavBarFixed = styled(NavBarBase)`
198202
props.top ? 'solid 1px ' + props.theme.colors.bg2 : 'none'};
199203
border-top: ${props =>
200204
!props.top ? 'solid 1px ' + props.theme.colors.bg2 : 'none'};
205+
206+
&:has(input:focus) {
207+
box-shadow: 0px 0px 0px 2px ${props => props.theme.colors.main};
208+
}
201209
`;
202210

203211
const SideBarWrapper = styled('div')`

browser/data-browser/src/components/PropVal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function PropVal({
6161
</PropertyLabel>
6262
</AtomicLink>
6363
{editable ? (
64-
<ValueForm resource={resource} propertyURL={propertyURL} noMargin />
64+
<ValueForm resource={resource} propertyURL={propertyURL} />
6565
) : (
6666
<ValueComp
6767
datatype={property.datatype}

browser/data-browser/src/components/Searchbar.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ const Input = styled.input`
159159
flex: 1;
160160
min-width: 1rem;
161161
background-color: ${props => props.theme.colors.bg};
162-
outline: 0;
162+
// Outline is handled by the Navbar.
163+
outline: none;
163164
color: ${p => p.theme.colors.textLight};
164165
`;
165166

@@ -172,9 +173,7 @@ const Form = styled.form`
172173
border-radius: 999px;
173174
174175
:hover {
175-
box-shadow: inset 0 0 0 2px
176-
${props => transparentize(0.6, props.theme.colors.main)};
177-
176+
${props => transparentize(0.6, props.theme.colors.main)};
178177
${Input} {
179178
color: ${p => p.theme.colors.text};
180179
}
@@ -183,8 +182,9 @@ const Form = styled.form`
183182
${Input} {
184183
color: ${p => p.theme.colors.text};
185184
}
185+
186+
// Outline is handled by the Navbar.
186187
outline: none;
187-
box-shadow: inset 0 0 0 2px ${props => props.theme.colors.main};
188188
}
189189
`;
190190

browser/data-browser/src/components/TableEditor/hooks/usePasteCommand.ts

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ export function usePasteCommand<T>(
3838
return;
3939
}
4040

41+
// Don't use custom paste logic when the user is focussed on an input
42+
if (document.activeElement?.tagName === 'INPUT') {
43+
return;
44+
}
45+
4146
const htmlData = event.clipboardData?.getData('text/html');
4247

4348
if (htmlData) {

browser/data-browser/src/components/ValueComp.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ import { ErrMessage } from './forms/InputStyles';
1616
type Props = {
1717
value: JSONValue;
1818
datatype: Datatype;
19-
noMargin?: boolean;
2019
};
2120

2221
/** Renders a value in a fitting way, depending on its DataType */
23-
function ValueComp({ value, datatype, noMargin }: Props): JSX.Element {
22+
function ValueComp({ value, datatype }: Props): JSX.Element {
2423
try {
2524
switch (datatype) {
2625
case Datatype.ATOMIC_URL: {
@@ -36,7 +35,7 @@ function ValueComp({ value, datatype, noMargin }: Props): JSX.Element {
3635
case (Datatype.DATE, Datatype.TIMESTAMP):
3736
return <DateTime date={valToDate(value)} />;
3837
case Datatype.MARKDOWN:
39-
return <Markdown text={valToString(value)} noMargin={noMargin} />;
38+
return <Markdown text={valToString(value)} />;
4039
case Datatype.RESOURCEARRAY:
4140
return <ResourceArray subjects={valToArray(value)} />;
4241
default:

browser/data-browser/src/components/datatypes/Markdown.tsx

+6-20
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,21 @@ import { styled } from 'styled-components';
33
import remarkGFM from 'remark-gfm';
44
import { Button } from '../Button';
55
import { truncateMarkdown } from '../../helpers/markdown';
6-
import { useState } from 'react';
6+
import { FC, useState } from 'react';
77

88
type Props = {
99
text: string;
10-
/**
11-
* By default, all bottom Markdown elements have some margin (e.g. the last
12-
* paragraph). If you set noMargin, this is corrected.
13-
*/
14-
noMargin?: boolean;
1510
renderGFM?: boolean;
1611
/**
1712
* If this is set, and the markdown is more characters than this number, the
1813
* text will be truncated and a button will be shown
1914
*/
2015
maxLength?: number;
16+
className?: string;
2117
};
2218

2319
/** Renders a markdown value */
24-
function Markdown({
25-
text,
26-
noMargin,
27-
renderGFM,
28-
maxLength,
29-
}: Props): JSX.Element | null {
20+
const Markdown: FC<Props> = ({ text, renderGFM, maxLength, className }) => {
3021
const [collapsed, setCollapsed] = useState(true);
3122

3223
maxLength = maxLength || 5000;
@@ -36,7 +27,7 @@ function Markdown({
3627
}
3728

3829
return (
39-
<MarkdownWrapper noMargin={noMargin}>
30+
<MarkdownWrapper className={className}>
4031
<ReactMarkdown remarkPlugins={renderGFM ? [remarkGFM] : []}>
4132
{collapsed ? truncateMarkdown(text, maxLength) : text}
4233
</ReactMarkdown>
@@ -47,19 +38,14 @@ function Markdown({
4738
)}
4839
</MarkdownWrapper>
4940
);
50-
}
41+
};
5142

5243
Markdown.defaultProps = {
5344
renderGFM: true,
5445
};
5546

56-
interface MarkdownWrapperProps {
57-
noMargin?: boolean;
58-
}
59-
60-
const MarkdownWrapper = styled.div<MarkdownWrapperProps>`
47+
const MarkdownWrapper = styled.div`
6148
/* Corrects the margin added by <p> and other HTML elements */
62-
margin-bottom: -${p => (p.noMargin ? p.theme.margin : 0)}rem;
6349
6450
width: 100%;
6551
overflow-x: hidden;

browser/data-browser/src/components/forms/SearchBox/SearchBox.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export function SearchBox({
120120
invalid={!!error}
121121
>
122122
<TriggerButton
123+
type='button'
123124
autoFocus={autoFocus}
124125
disabled={disabled}
125126
ref={triggerRef}

browser/data-browser/src/components/forms/ValueForm.tsx

+2-12
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,13 @@ interface ValueFormProps {
2626
* also override it manually
2727
*/
2828
datatype?: Datatype;
29-
noMargin?: boolean;
3029
}
3130

3231
/**
3332
* A form for a single Value. Presents a normal value, but let's the user click
3433
* on a button to turn it into an input.
3534
*/
36-
export function ValueForm({
37-
resource,
38-
noMargin,
39-
propertyURL,
40-
datatype,
41-
}: ValueFormProps) {
35+
export function ValueForm({ resource, propertyURL, datatype }: ValueFormProps) {
4236
const [editMode, setEditMode] = useState(false);
4337
const property = useProperty(propertyURL);
4438
const [value] = useValue(resource, propertyURL);
@@ -86,11 +80,7 @@ export function ValueForm({
8680
if (!editMode) {
8781
return (
8882
<ValueFormWrapper>
89-
<ValueComp
90-
value={value}
91-
datatype={datatype || property.datatype}
92-
noMargin={noMargin}
93-
/>
83+
<ValueComp value={value} datatype={datatype || property.datatype} />
9484
<EditButton title='Edit value'>
9585
<FaEdit onClick={() => setEditMode(!editMode)} />
9686
</EditButton>

browser/data-browser/src/routes/SearchRoute.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ export function Search(): JSX.Element {
142142
{results.map((subject, index) => (
143143
<ResourceCard
144144
initialInView={index < 5}
145-
small
146145
subject={subject}
147146
key={subject}
148147
highlight={index === selectedIndex}

browser/data-browser/src/views/Card/BookmarkCard.tsx

+6-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
import { urls, useString, useTitle } from '@tomic/react';
1+
import { urls, useString } from '@tomic/react';
22

33
import { styled } from 'styled-components';
4-
import { AtomicLink } from '../../components/AtomicLink';
54
import Markdown from '../../components/datatypes/Markdown';
65
import {
76
ExternalLink,
87
ExternalLinkVariant,
98
} from '../../components/ExternalLink';
109
import { CardViewProps } from './CardViewProps';
10+
import { ResourceCardTitle } from './ResourceCardTitle';
11+
import { Column } from '../../components/Row';
1112

1213
export function BookmarkCard({ resource }: CardViewProps): JSX.Element {
13-
const [title] = useTitle(resource);
1414
const [url] = useString(resource, urls.properties.bookmark.url);
1515
const [preview] = useString(resource, urls.properties.bookmark.preview);
1616

1717
return (
18-
<>
19-
<AtomicLink subject={resource.getSubject()}>
20-
<Title>{title}</Title>
21-
</AtomicLink>
18+
<Column gap='0.5rem'>
19+
<ResourceCardTitle resource={resource} />
2220
<ExternalLink to={url!} variant={ExternalLinkVariant.Button}>
2321
Open site
2422
</ExternalLink>
@@ -27,17 +25,10 @@ export function BookmarkCard({ resource }: CardViewProps): JSX.Element {
2725
<Markdown maxLength={1000} renderGFM text={preview} />
2826
</MarkdownWrapper>
2927
)}
30-
</>
28+
</Column>
3129
);
3230
}
3331

34-
const Title = styled.h2`
35-
white-space: nowrap;
36-
overflow: hidden;
37-
text-overflow: ellipsis;
38-
line-height: 1.2;
39-
`;
40-
4132
const MarkdownWrapper = styled.div`
4233
margin-top: ${p => p.theme.margin}rem;
4334
margin-inline: -${p => p.theme.margin}rem;

0 commit comments

Comments
 (0)