@ossy/storage 3.0.4 → 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.4",
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": "831c9816bee67c5e53d0a4be4f6401975f23d72a"
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 {
@@ -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,16 +268,23 @@ export const ResourcesPage = () => {
255
268
  </style>
256
269
 
257
270
  <Page
271
+ scroll
258
272
  title="storage.resources.title"
259
273
  description="storage.resources.description"
260
274
  near={<Tags tags={[t('storage.resources.beta')]} size="s" />}
261
275
  style={{ minHeight: 0 }}
276
+ contentStyle={{
277
+ overflow: 'hidden',
278
+ display: 'flex',
279
+ flexDirection: 'column',
280
+ minHeight: 0,
281
+ }}
262
282
  >
263
283
 
264
- <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' }}>
265
285
 
266
- <View.Item fill surface="primary" roundness="xs" >
267
- <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 }}>
268
288
 
269
289
  <View.Item
270
290
  data-surface="primary"
@@ -280,7 +300,10 @@ export const ResourcesPage = () => {
280
300
  >
281
301
 
282
302
  <Breadcrumbs>
283
- <DropZone onDrop={activePath === '/' ? undefined : onMoveResource('/')}>
303
+ <DropZone
304
+ onDrop={activePath === '/' ? undefined : onMoveResource('/')}
305
+ onFilesDrop={onUploadFiles('/')}
306
+ >
284
307
  <Button prefix="home-alt" variant="command" onClick={openLocation('/')} href={storageHomeHref()} />
285
308
  </DropZone>
286
309
 
@@ -311,75 +334,79 @@ export const ResourcesPage = () => {
311
334
 
312
335
  </View.Item>
313
336
 
314
- <View.Item fill data-scrollbar="hide" style={{ overflowY: 'auto' }}>
315
- <Switch on={resourcesListStatus}>
316
-
317
- <Switch.Case match={[ResourcesListStatus.Error]}>
318
- <View layout="off-center" style={{ height: '100%' }}>
319
- <Guide
320
- data-region="content"
321
- title={t('storage.resources.errorTitle')}
322
- text={t('storage.resources.errorText')}
323
- style={{ width: '100vw', maxWidth: '350px' }}
324
- />
325
- </View>
326
- </Switch.Case>
327
-
328
- <Switch.Case match={[ResourcesListStatus.Loading]}>
329
- <DelayedRender>
330
- {[1, 2, 3].map(n => (
331
- <View.Item key={n}>
332
- <div
333
- className="inset-m cursor-pointer sans-serif d-flex align-center justify-between"
334
- style={{ height: '56px', }}
335
- >
336
- <div className="d-flex align-center">
337
- <span
338
- className="inline-m"
339
- style={{
340
- width: '24px',
341
- height: '24px',
342
- flexShrink: 0,
343
- background: 'hsl(0, 0%, 50%)',
344
- borderRadius: '16px'
345
- }}
346
- />
347
- <span
348
- style={{
349
- width: '300px',
350
- height: '18px',
351
- background: 'hsl(0, 0%, 50%)',
352
- borderRadius: '16px'
353
- }}
354
- />
355
- </div>
356
- </div>
357
- </View.Item>
358
- ))}
359
- </DelayedRender>
360
- </Switch.Case>
361
-
362
- <Switch.Case match={[ResourcesListStatus.Empty]}>
363
- {isCreatingFolder
364
- ? <ResourceList resources={[]} inlineFolder={inlineFolder} />
365
- : (
366
- <Guide
367
- data-region="content"
368
- title={t('storage.resources.emptyTitle')}
369
- titleVariant="heading-tertiary"
370
- text={t('storage.resources.emptyText')}
371
- align="left"
372
- style={{ maxWidth: '350px', padding: 'var(--space-m)' }}
373
- />
374
- )
375
- }
376
- </Switch.Case>
377
-
378
- <Switch.Case match={[ResourcesListStatus.Success]}>
379
- <ResourceList resources={filterResources} inlineFolder={inlineFolder} />
380
- </Switch.Case>
381
-
382
- </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>
383
410
  </View.Item>
384
411
 
385
412
  </View>
@@ -12,7 +12,7 @@
12
12
  "storage.resources.errorTitle": "Something went wrong",
13
13
  "storage.resources.errorText": "We could not fetch the data to display",
14
14
  "storage.resources.emptyTitle": "Empty folder",
15
- "storage.resources.emptyText": "Create a folder or upload a file to get started.",
15
+ "storage.resources.emptyText": "Create a folder, upload a file, or drop files here to get started.",
16
16
  "storage.resources.removeDirectoryTitle": "Remove directory",
17
17
  "storage.resources.removeDirectoryText": "Are you sure you want to remove this directory and everything in it?",
18
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
  }
@@ -12,7 +12,7 @@
12
12
  "storage.resources.errorTitle": "Något gick fel",
13
13
  "storage.resources.errorText": "Vi kunde inte hämta data att visa",
14
14
  "storage.resources.emptyTitle": "Tom mapp",
15
- "storage.resources.emptyText": "Skapa en mapp eller ladda upp en fil för att komma igång.",
15
+ "storage.resources.emptyText": "Skapa en mapp, ladda upp en fil eller släpp filer här för att komma igång.",
16
16
  "storage.resources.removeDirectoryTitle": "Ta bort mapp",
17
17
  "storage.resources.removeDirectoryText": "Är du säker på att du vill ta bort den här mappen och allt innehåll?",
18
18
  "storage.resources.cancel": "Avbryt",