@ossy/resources 3.0.4 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ossy/resources",
3
3
  "description": "Resource domain — aggregate and events for the Ossy resource model",
4
- "version": "3.0.4",
4
+ "version": "3.0.6",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "main": "./src/index.js",
@@ -23,10 +23,10 @@
23
23
  "src": "./src"
24
24
  },
25
25
  "dependencies": {
26
- "@ossy/event-store": "^3.0.4",
27
- "@ossy/fold": "^3.0.4",
28
- "@ossy/platform": "^3.0.4",
29
- "@ossy/schema": "^3.0.4"
26
+ "@ossy/event-store": "^3.0.6",
27
+ "@ossy/fold": "^3.0.6",
28
+ "@ossy/platform": "^3.0.6",
29
+ "@ossy/schema": "^3.0.6"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@ossy/design-system": ">=1.0.0",
@@ -49,5 +49,5 @@
49
49
  "/src",
50
50
  "README.md"
51
51
  ],
52
- "gitHead": "831c9816bee67c5e53d0a4be4f6401975f23d72a"
52
+ "gitHead": "3e1c558069c7738dd751e429c69b10e52d247d8c"
53
53
  }
@@ -19,7 +19,7 @@ export const AudioResource = ({
19
19
  as="audio"
20
20
  controls
21
21
  data-region="content"
22
- src={resource.content.src}
22
+ src={resource?.content?.src}
23
23
  />
24
24
  </View>
25
25
 
@@ -20,8 +20,8 @@ export const PDFResource = ({
20
20
 
21
21
  <div style={{ display: 'flex', justifyContent: 'center' }}>
22
22
  <embed
23
- src={resource.content.src}
24
- type={resource.type}
23
+ src={resource?.content?.src}
24
+ type={resource?.content?.ContentType || 'application/pdf'}
25
25
  width="100%"
26
26
  height="800px"
27
27
  />
@@ -103,7 +103,7 @@ const ResourceListItem = memo(function ResourceListItem({
103
103
  templateMap,
104
104
  onItemClick,
105
105
  }) {
106
- const { onClick, href, onDrop, dragData, actions, name, type, content } = resource
106
+ const { onClick, href, onDrop, onFilesDrop, dragData, actions, name, type, content } = resource
107
107
 
108
108
  const handleClick = useCallback(() => {
109
109
  onItemClick(resource)
@@ -112,14 +112,14 @@ const ResourceListItem = memo(function ResourceListItem({
112
112
 
113
113
  let Container = ({ children }) => <>{children}</>
114
114
 
115
- if (onDrop) {
115
+ if (onDrop || onFilesDrop) {
116
116
  Container = DropZone
117
117
  } else if (dragData) {
118
118
  Container = DropZone.Dragable
119
119
  }
120
120
 
121
121
  return (
122
- <Container onDrop={onDrop} dragData={dragData}>
122
+ <Container onDrop={onDrop} onFilesDrop={onFilesDrop} dragData={dragData}>
123
123
  <List.Item
124
124
  href={href}
125
125
  onClick={handleClick}
@@ -138,7 +138,7 @@ export const ResourcePanel = memo(function ResourcePanel ({
138
138
  }
139
139
 
140
140
  return (
141
- <View stack surface="primary" bordered style={{ height: '100%', width: '50%' }}>
141
+ <View stack surface="primary" bordered style={{ height: '100%', width: '50%', minHeight: 0, minWidth: 0, flexShrink: 0 }}>
142
142
 
143
143
  <style href="@design-system/scroll" precedence='low'>{`
144
144
  [data-scroll-hide] {
@@ -201,7 +201,7 @@ export const ResourcePanel = memo(function ResourcePanel ({
201
201
 
202
202
  </View.Item>
203
203
 
204
- <View.Item fill={true} data-scroll-hide style={{ display: 'flex', flexDirection: 'column', height: '100%', overflowY: 'auto' }}>
204
+ <View.Item fill={true} data-scroll-hide style={{ display: 'flex', flexDirection: 'column', minHeight: 0, overflowY: 'auto' }}>
205
205
 
206
206
  {panels.map(({ content: Content, ...panel }) => {
207
207
  const isExpanded = [ViewMode.View, ViewMode.Edit].includes(panelViewModes[panel.id])
@@ -41,7 +41,17 @@ export async function uploadFile(sdk, uploadLocation, file) {
41
41
  size: file.size,
42
42
  })
43
43
  if (resource.content?.uploadUrl) {
44
- await fetch(resource.content.uploadUrl, { method: 'PUT', body: file })
44
+ const response = await fetch(resource.content.uploadUrl, {
45
+ method: 'PUT',
46
+ headers: file.type ? { 'Content-Type': file.type } : undefined,
47
+ body: file,
48
+ })
49
+ if (!response.ok) {
50
+ throw Object.assign(
51
+ new Error(`Upload failed: HTTP ${response.status}`),
52
+ { status: response.status, resourceId: resource.id },
53
+ )
54
+ }
45
55
  }
46
56
  invalidateLocation(sdk, location)
47
57
  return resource