@ossy/storage 3.0.3 → 3.0.5

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/storage",
3
3
  "description": "Analytics module — workspace analytics for website traffic",
4
- "version": "3.0.3",
4
+ "version": "3.0.5",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
7
7
  "module": "./src/index.js",
@@ -30,5 +30,5 @@
30
30
  "ramda": "*",
31
31
  "react": "*"
32
32
  },
33
- "gitHead": "8d098a04b595b2d1f54788c5c7ed7f310e9cd7e1"
33
+ "gitHead": "e12eb33b42db8ba8a7e1a34f6b0fe30b6879f91b"
34
34
  }
@@ -1,5 +1,5 @@
1
1
  import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react'
2
- import { ListResources, createDirectory, moveResource, removeResource } from '@ossy/resources'
2
+ import { ListResources, createDirectory, moveResource, removeResource, uploadFile } from '@ossy/resources'
3
3
  import { GetWorkspace } from '@ossy/workspaces'
4
4
  import { AsyncStatus, useSdk } from '@ossy/sdk-react'
5
5
  import {
@@ -9,7 +9,7 @@ import {
9
9
  identity,
10
10
  last,
11
11
  } from 'ramda'
12
- import { Text, Overlay, Switch, DropZone, Breadcrumbs, Guide, DelayedRender, useDocumentTitle, View, Button, ContextMenu, Dropdown, EmptyState, Page, Tags, useLocale, preloadStorageIcons } from '@ossy/design-system'
12
+ import { Text, Overlay, Switch, DropZone, Breadcrumbs, Guide, DelayedRender, useDocumentTitle, View, Button, ContextMenu, Dropdown, Page, Tags, useLocale, preloadStorageIcons } from '@ossy/design-system'
13
13
  import { useActivePath, ResourcePanel, ResourceList, ResourceDialogMove, useSelectedResourceId } from '@ossy/resources'
14
14
  import { useRouter, useSearchParams } from '@ossy/router-react'
15
15
 
@@ -124,6 +124,13 @@ export const ResourcesPage = () => {
124
124
  moveResource(sdk, resourceId, newLocation, activePath)
125
125
  }
126
126
 
127
+ const onUploadFiles = useCallback((location) => (files) => {
128
+ if (!files?.length) return
129
+ Promise.all(files.map((file) => uploadFile(sdk, location, file))).catch((error) => {
130
+ console.error('[storage] upload failed', error)
131
+ })
132
+ }, [sdk])
133
+
127
134
  const onRemoveResource = resource => {
128
135
  setSelectedResourceId(resource.id)
129
136
 
@@ -146,7 +153,11 @@ export const ResourcesPage = () => {
146
153
  const isLast = i === (paths.length - 1)
147
154
  if (isLast) return <Path key={path} path={path} onClick={goTo(path)} />
148
155
  return (
149
- <DropZone onDrop={onMoveResource(`${path}/`)} key={path}>
156
+ <DropZone
157
+ key={path}
158
+ onDrop={onMoveResource(`${path}/`)}
159
+ onFilesDrop={onUploadFiles(`${path}/`)}
160
+ >
150
161
  <Path path={path} onClick={openLocation(`${path}/`)} href={storageHomeHref(`location=${path}`)} />
151
162
  </DropZone>
152
163
  )
@@ -160,11 +171,13 @@ export const ResourcesPage = () => {
160
171
 
161
172
  if (resource.type === '@ossy/platform/schema/directory' || resource.type === 'directory') {
162
173
  const folderLocation = `${activePath}${resource.name}`
174
+ const dropLocation = `${resource.location}${resource.name}/`
163
175
  return {
164
176
  ...resource,
165
177
  href: storageHomeHref(`location=${folderLocation}`),
166
178
  onClick: openLocation(folderLocation),
167
- onDrop: onMoveResource(`${resource.location}${resource.name}/`),
179
+ onDrop: onMoveResource(dropLocation),
180
+ onFilesDrop: onUploadFiles(dropLocation),
168
181
  actions: [
169
182
  <ContextMenu.Item
170
183
  prefix="mail-forward"
@@ -236,7 +249,7 @@ export const ResourcesPage = () => {
236
249
  const bDir = b.type === '@ossy/platform/schema/directory' || b.type === 'directory'
237
250
  if (aDir && !bDir) return -1
238
251
  if (!aDir && bDir) return 1
239
- }), [displayResources, activePath, storageHomeHref, openLocation, onMoveResource, onRemoveResource, setSelectedResourceId, t])
252
+ }), [displayResources, activePath, storageHomeHref, openLocation, onMoveResource, onUploadFiles, onRemoveResource, setSelectedResourceId, t])
240
253
 
241
254
  return (
242
255
  <>
@@ -255,17 +268,23 @@ export const ResourcesPage = () => {
255
268
  </style>
256
269
 
257
270
  <Page
258
- inset="none"
271
+ scroll
259
272
  title="storage.resources.title"
260
273
  description="storage.resources.description"
261
274
  near={<Tags tags={[t('storage.resources.beta')]} size="s" />}
262
275
  style={{ minHeight: 0 }}
276
+ contentStyle={{
277
+ overflow: 'hidden',
278
+ display: 'flex',
279
+ flexDirection: 'column',
280
+ minHeight: 0,
281
+ }}
263
282
  >
264
283
 
265
- <View stack horizontal gap="xs" style={{ flexGrow: 1, minHeight: 0 }}>
284
+ <View stack horizontal gap="xs" style={{ height: '100%', minHeight: 0, flex: '1 1 auto' }}>
266
285
 
267
- <View.Item fill surface="primary" roundness="xs" >
268
- <View stack bordered style={{ height: '100%' }}>
286
+ <View.Item fill surface="primary" roundness="xs" style={{ minHeight: 0, minWidth: 0 }}>
287
+ <View stack bordered style={{ height: '100%', minHeight: 0 }}>
269
288
 
270
289
  <View.Item
271
290
  data-surface="primary"
@@ -281,7 +300,10 @@ export const ResourcesPage = () => {
281
300
  >
282
301
 
283
302
  <Breadcrumbs>
284
- <DropZone onDrop={activePath === '/' ? undefined : onMoveResource('/')}>
303
+ <DropZone
304
+ onDrop={activePath === '/' ? undefined : onMoveResource('/')}
305
+ onFilesDrop={onUploadFiles('/')}
306
+ >
285
307
  <Button prefix="home-alt" variant="command" onClick={openLocation('/')} href={storageHomeHref()} />
286
308
  </DropZone>
287
309
 
@@ -312,66 +334,79 @@ export const ResourcesPage = () => {
312
334
 
313
335
  </View.Item>
314
336
 
315
- <View.Item fill data-scrollbar="hide" style={{ overflowY: 'auto' }}>
316
- <Switch on={resourcesListStatus}>
317
-
318
- <Switch.Case match={[ResourcesListStatus.Error]}>
319
- <View layout="off-center" style={{ height: '100%' }}>
320
- <Guide
321
- data-region="content"
322
- title={t('storage.resources.errorTitle')}
323
- text={t('storage.resources.errorText')}
324
- style={{ width: '100vw', maxWidth: '350px' }}
325
- />
326
- </View>
327
- </Switch.Case>
328
-
329
- <Switch.Case match={[ResourcesListStatus.Loading]}>
330
- <DelayedRender>
331
- {[1, 2, 3].map(n => (
332
- <View.Item key={n}>
333
- <div
334
- className="inset-m cursor-pointer sans-serif d-flex align-center justify-between"
335
- style={{ height: '56px', }}
336
- >
337
- <div className="d-flex align-center">
338
- <span
339
- className="inline-m"
340
- style={{
341
- width: '24px',
342
- height: '24px',
343
- flexShrink: 0,
344
- background: 'hsl(0, 0%, 50%)',
345
- borderRadius: '16px'
346
- }}
347
- />
348
- <span
349
- style={{
350
- width: '300px',
351
- height: '18px',
352
- background: 'hsl(0, 0%, 50%)',
353
- borderRadius: '16px'
354
- }}
355
- />
356
- </div>
357
- </div>
358
- </View.Item>
359
- ))}
360
- </DelayedRender>
361
- </Switch.Case>
362
-
363
- <Switch.Case match={[ResourcesListStatus.Empty]}>
364
- {isCreatingFolder
365
- ? <ResourceList resources={[]} inlineFolder={inlineFolder} />
366
- : <EmptyState message={t('storage.resources.emptyDirectory')} />
367
- }
368
- </Switch.Case>
369
-
370
- <Switch.Case match={[ResourcesListStatus.Success]}>
371
- <ResourceList resources={filterResources} inlineFolder={inlineFolder} />
372
- </Switch.Case>
373
-
374
- </Switch>
337
+ <View.Item fill data-scrollbar="hide" style={{ overflowY: 'auto', minHeight: 0 }}>
338
+ <DropZone onFilesDrop={onUploadFiles(activePath)}>
339
+ <View style={{ minHeight: '100%' }}>
340
+ <Switch on={resourcesListStatus}>
341
+
342
+ <Switch.Case match={[ResourcesListStatus.Error]}>
343
+ <View layout="off-center" style={{ height: '100%' }}>
344
+ <Guide
345
+ data-region="content"
346
+ title={t('storage.resources.errorTitle')}
347
+ text={t('storage.resources.errorText')}
348
+ style={{ width: '100vw', maxWidth: '350px' }}
349
+ />
350
+ </View>
351
+ </Switch.Case>
352
+
353
+ <Switch.Case match={[ResourcesListStatus.Loading]}>
354
+ <DelayedRender>
355
+ {[1, 2, 3].map(n => (
356
+ <View.Item key={n}>
357
+ <div
358
+ className="inset-m cursor-pointer sans-serif d-flex align-center justify-between"
359
+ style={{ height: '56px', }}
360
+ >
361
+ <div className="d-flex align-center">
362
+ <span
363
+ className="inline-m"
364
+ style={{
365
+ width: '24px',
366
+ height: '24px',
367
+ flexShrink: 0,
368
+ background: 'hsl(0, 0%, 50%)',
369
+ borderRadius: '16px'
370
+ }}
371
+ />
372
+ <span
373
+ style={{
374
+ width: '300px',
375
+ height: '18px',
376
+ background: 'hsl(0, 0%, 50%)',
377
+ borderRadius: '16px'
378
+ }}
379
+ />
380
+ </div>
381
+ </div>
382
+ </View.Item>
383
+ ))}
384
+ </DelayedRender>
385
+ </Switch.Case>
386
+
387
+ <Switch.Case match={[ResourcesListStatus.Empty]}>
388
+ {isCreatingFolder
389
+ ? <ResourceList resources={[]} inlineFolder={inlineFolder} />
390
+ : (
391
+ <Guide
392
+ data-region="content"
393
+ title={t('storage.resources.emptyTitle')}
394
+ titleVariant="heading-tertiary"
395
+ text={t('storage.resources.emptyText')}
396
+ align="left"
397
+ style={{ maxWidth: '350px', padding: 'var(--space-m)' }}
398
+ />
399
+ )
400
+ }
401
+ </Switch.Case>
402
+
403
+ <Switch.Case match={[ResourcesListStatus.Success]}>
404
+ <ResourceList resources={filterResources} inlineFolder={inlineFolder} />
405
+ </Switch.Case>
406
+
407
+ </Switch>
408
+ </View>
409
+ </DropZone>
375
410
  </View.Item>
376
411
 
377
412
  </View>
@@ -11,7 +11,8 @@
11
11
  "storage.resources.newFolderDefault": "New folder",
12
12
  "storage.resources.errorTitle": "Something went wrong",
13
13
  "storage.resources.errorText": "We could not fetch the data to display",
14
- "storage.resources.emptyDirectory": "Empty directory",
14
+ "storage.resources.emptyTitle": "Empty folder",
15
+ "storage.resources.emptyText": "Create a folder, upload a file, or drop files here to get started.",
15
16
  "storage.resources.removeDirectoryTitle": "Remove directory",
16
17
  "storage.resources.removeDirectoryText": "Are you sure you want to remove this directory and everything in it?",
17
18
  "storage.resources.cancel": "Cancel",
@@ -1,9 +1,7 @@
1
- import React from 'react'
2
- import { useLocale } from '@ossy/design-system'
1
+ import React, { useEffect } from 'react'
3
2
  import { ResourcesPage } from './ResourcesPage.jsx'
4
3
  import { useApp } from '@ossy/app/shell'
5
- import { features } from './features.js'
6
- import SalesSection from './SalesSection.jsx'
4
+ import { useRouter } from '@ossy/router-react'
7
5
 
8
6
  export const metadata = {
9
7
  id: 'storage/home',
@@ -11,19 +9,25 @@ export const metadata = {
11
9
  sv: '/storage',
12
10
  en: '/storage',
13
11
  },
12
+ layout: '@ossy/app/layout/workspace',
14
13
  }
15
14
 
16
- function StorageSalesSection () {
17
- const { t } = useLocale()
18
- const cover = {
19
- title: t('storage.home.cover.title'),
20
- titleVariant: 'primary',
21
- text: t('storage.home.cover.text'),
22
- }
23
- return <SalesSection cover={cover} features={features} />
15
+ const PACKAGE_DETAIL = {
16
+ id: 'packages/detail',
17
+ params: { packageSlug: 'storage' },
24
18
  }
25
19
 
26
20
  export default function StorageHomePage () {
27
21
  const app = useApp()
28
- return app?.isAuthenticated ? <ResourcesPage /> : <StorageSalesSection />
22
+ const router = useRouter()
23
+
24
+ useEffect(() => {
25
+ if (app && !app.isAuthenticated) {
26
+ router.navigate(PACKAGE_DETAIL)
27
+ }
28
+ }, [app, router])
29
+
30
+ if (!app?.isAuthenticated) return null
31
+
32
+ return <ResourcesPage />
29
33
  }
@@ -11,7 +11,8 @@
11
11
  "storage.resources.newFolderDefault": "Ny mapp",
12
12
  "storage.resources.errorTitle": "Något gick fel",
13
13
  "storage.resources.errorText": "Vi kunde inte hämta data att visa",
14
- "storage.resources.emptyDirectory": "Tom katalog",
14
+ "storage.resources.emptyTitle": "Tom mapp",
15
+ "storage.resources.emptyText": "Skapa en mapp, ladda upp en fil eller släpp filer här för att komma igång.",
15
16
  "storage.resources.removeDirectoryTitle": "Ta bort mapp",
16
17
  "storage.resources.removeDirectoryText": "Är du säker på att du vill ta bort den här mappen och allt innehåll?",
17
18
  "storage.resources.cancel": "Avbryt",