-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44c8d3f
commit dab236f
Showing
23 changed files
with
422 additions
and
407 deletions.
There are no files selected for viewing
103 changes: 103 additions & 0 deletions
103
docs/src/pages/[platform]/connected-components/storage/storage-browser/examples/Composed.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import * as React from 'react'; | ||
import { Button, Flex, Text } from '@aws-amplify/ui-react'; | ||
import { IconChevronRight } from '@aws-amplify/ui-react/internal'; | ||
import { StorageBrowser, useView } from './MockStorageBrowser'; | ||
import { ComposedCopyView } from './ComposedCopyView'; | ||
import { ComposedCreateFolderView } from './ComposedCreateFolderView'; | ||
import { ComposedDeleteView } from './ComposedDeleteView'; | ||
import { ComposedUploadView } from './ComposedUploadView'; | ||
|
||
function LocationsView() { | ||
const state = useView('Locations'); | ||
|
||
return ( | ||
<Flex direction="column" padding="medium"> | ||
<Text fontWeight="bold">Locations</Text> | ||
{state.pageItems.map((location) => { | ||
return ( | ||
<Button | ||
key={location.id} | ||
justifyContent="flex-start" | ||
onClick={() => { | ||
state.onNavigate(location); | ||
}} | ||
> | ||
<Text flex="1"> | ||
s3://{location.bucket}/{location.prefix} | ||
</Text> | ||
<Text as="span" color="font.tertiary" fontWeight="normal"> | ||
{location.permissions.includes('list') ? 'Read' : null}{' '} | ||
{location.permissions.includes('write') ? 'Write' : null} | ||
</Text> | ||
<IconChevronRight color="font.tertiary" /> | ||
</Button> | ||
); | ||
})} | ||
</Flex> | ||
); | ||
} | ||
|
||
const { LocationActionView } = StorageBrowser; | ||
|
||
function MyLocationActionView({ | ||
type, | ||
onExit, | ||
}: { | ||
type?: string; | ||
onExit: () => void; | ||
}) { | ||
let DialogContent = null; | ||
if (!type) return DialogContent; | ||
|
||
switch (type) { | ||
case 'copy': | ||
return <ComposedCopyView onExit={onExit} />; | ||
case 'createFolder': | ||
return <ComposedCreateFolderView onExit={onExit} />; | ||
case 'delete': | ||
return <ComposedDeleteView onExit={onExit} />; | ||
case 'upload': | ||
return <ComposedUploadView onExit={onExit} />; | ||
default: | ||
return <LocationActionView onExit={onExit} />; | ||
} | ||
} | ||
|
||
function MyStorageBrowser() { | ||
const state = useView('LocationDetail'); | ||
const [currentAction, setCurrentAction] = React.useState<string>(); | ||
const ref = React.useRef<HTMLDialogElement>(null); | ||
|
||
if (!state.location.current) { | ||
return <LocationsView />; | ||
} | ||
|
||
return ( | ||
<> | ||
<StorageBrowser.LocationDetailView | ||
key={currentAction} | ||
onActionSelect={(action) => { | ||
setCurrentAction(action); | ||
ref.current?.showModal(); | ||
}} | ||
/> | ||
<dialog ref={ref}> | ||
<MyLocationActionView | ||
type={currentAction} | ||
onExit={() => { | ||
setCurrentAction(undefined); | ||
ref.current?.close(); | ||
}} | ||
/> | ||
</dialog> | ||
</> | ||
); | ||
} | ||
|
||
export default function Example() { | ||
return ( | ||
<StorageBrowser.Provider> | ||
<MyStorageBrowser /> | ||
</StorageBrowser.Provider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 3 additions & 17 deletions
20
...tform]/connected-components/storage/storage-browser/examples/ComposedCreateFolderView.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,15 @@ | ||
import * as React from 'react'; | ||
import { createStorageBrowser } from '@aws-amplify/ui-react-storage/browser'; | ||
import { mockConfig } from './mockConfig'; // IGNORE | ||
import { StorageBrowser, useView } from './MockStorageBrowser'; | ||
|
||
const { StorageBrowser, useView } = createStorageBrowser({ | ||
//... | ||
config: mockConfig, // IGNORE | ||
}); | ||
|
||
function CreateFolderView() { | ||
export function ComposedCreateFolderView({ onExit }: { onExit: () => void }) { | ||
const state = useView('CreateFolder'); | ||
|
||
return ( | ||
<StorageBrowser.CreateFolderView.Provider {...state}> | ||
<StorageBrowser.CreateFolderView.Provider {...state} onActionExit={onExit}> | ||
<StorageBrowser.CreateFolderView.Exit /> | ||
<StorageBrowser.CreateFolderView.NameField /> | ||
<StorageBrowser.CreateFolderView.Start /> | ||
<StorageBrowser.CreateFolderView.Message /> | ||
</StorageBrowser.CreateFolderView.Provider> | ||
); | ||
} | ||
|
||
export default function Example() { | ||
return ( | ||
<StorageBrowser.Provider> | ||
<CreateFolderView /> | ||
</StorageBrowser.Provider> | ||
); | ||
} |
20 changes: 3 additions & 17 deletions
20
...s/[platform]/connected-components/storage/storage-browser/examples/ComposedDeleteView.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,15 @@ | ||
import * as React from 'react'; | ||
import { createStorageBrowser } from '@aws-amplify/ui-react-storage/browser'; | ||
import { mockConfig } from './mockConfig'; // IGNORE | ||
import { StorageBrowser, useView } from './MockStorageBrowser'; | ||
|
||
const { StorageBrowser, useView } = createStorageBrowser({ | ||
//... | ||
config: mockConfig, // IGNORE | ||
}); | ||
|
||
function DeleteView() { | ||
export function ComposedDeleteView({ onExit }: { onExit: () => void }) { | ||
const state = useView('Delete'); | ||
|
||
return ( | ||
<StorageBrowser.DeleteView.Provider {...state}> | ||
<StorageBrowser.DeleteView.Provider {...state} onActionExit={onExit}> | ||
<StorageBrowser.DeleteView.Exit /> | ||
<StorageBrowser.DeleteView.TasksTable /> | ||
<StorageBrowser.DeleteView.Start /> | ||
<StorageBrowser.DeleteView.Message /> | ||
</StorageBrowser.DeleteView.Provider> | ||
); | ||
} | ||
|
||
export default function Example() { | ||
return ( | ||
<StorageBrowser.Provider> | ||
<DeleteView /> | ||
</StorageBrowser.Provider> | ||
); | ||
} |
9 changes: 2 additions & 7 deletions
9
...orm]/connected-components/storage/storage-browser/examples/ComposedLocationDetailView.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 2 additions & 7 deletions
9
...platform]/connected-components/storage/storage-browser/examples/ComposedLocationsView.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 44 additions & 53 deletions
97
docs/src/pages/[platform]/connected-components/storage/storage-browser/examples/Custom.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.