-
Notifications
You must be signed in to change notification settings - Fork 202
Refactor: change create file from modal to wizard #313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e325665
refactor: change create file from modal to wizard
TGlide 46de1b8
fix: text and small changes
TGlide affc529
fix: file input element and state not syncing
TGlide 8fff4ed
fix: wizard spacing issues
TGlide f6ff291
fix: more spacings
TGlide 1cb498b
Merge pull request #320 from appwrite/refactor/wizards
TorstenDittmann 448719c
refactor: wizard spacings
TGlide 192bb8c
refactor: change wizard title
TGlide 800d5c0
fix: file input overflow
TGlide fdff33e
refactor: update copy
TGlide 583b4ed
Merge branch 'main' into refactor/create-file-wizard
TGlide 6bb5229
fix: fix merge breaking changes
TGlide 6948485
Merge branch 'billing' of github.com:appwrite/console into refactor/c…
ArmanNik ce48638
fix: some stuff after merge
ArmanNik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
60 changes: 60 additions & 0 deletions
60
src/routes/console/project-[project]/storage/bucket-[bucket]/create-file/create.svelte
This file contains hidden or 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,60 @@ | ||
| <script lang="ts"> | ||
| import { invalidate } from '$app/navigation'; | ||
| import { page } from '$app/stores'; | ||
| import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; | ||
| import { Dependencies } from '$lib/constants'; | ||
| import type { WizardStepsType } from '$lib/layout/wizard.svelte'; | ||
| import Wizard from '$lib/layout/wizard.svelte'; | ||
| import { addNotification } from '$lib/stores/notifications'; | ||
| import { uploader } from '$lib/stores/uploader'; | ||
| import { wizard } from '$lib/stores/wizard'; | ||
| import { ID } from '@appwrite.io/console'; | ||
| import Step1 from './step1.svelte'; | ||
| import Step2 from './step2.svelte'; | ||
| import { createFile } from './store'; | ||
|
|
||
| const bucketId = $page.params.bucket; | ||
|
|
||
| const stepComponents: WizardStepsType = new Map(); | ||
|
|
||
| stepComponents.set(1, { | ||
| component: Step1, | ||
| label: 'Create' | ||
| }); | ||
|
|
||
| stepComponents.set(2, { | ||
| component: Step2, | ||
| label: 'Permissions' | ||
| }); | ||
|
|
||
| async function create() { | ||
| try { | ||
| await uploader.uploadFile( | ||
| bucketId, | ||
| $createFile.id ?? ID.unique(), | ||
| $createFile.files[0], | ||
| $createFile.permissions | ||
| ); | ||
|
|
||
| createFile.reset(); | ||
| wizard.hide(); | ||
| invalidate(Dependencies.FILES); | ||
|
|
||
| addNotification({ | ||
| type: 'success', | ||
| message: `File has been uploaded` | ||
| }); | ||
| trackEvent(Submit.FileCreate, { | ||
| customId: !!$createFile.id | ||
| }); | ||
| } catch (e) { | ||
| addNotification({ | ||
| type: 'error', | ||
| message: e.message | ||
| }); | ||
| trackError(e, Submit.FileCreate); | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <Wizard title="Create file" steps={stepComponents} on:exit={createFile.reset} on:finish={create} /> |
44 changes: 44 additions & 0 deletions
44
src/routes/console/project-[project]/storage/bucket-[bucket]/create-file/step1.svelte
This file contains hidden or 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,44 @@ | ||
| <script lang="ts"> | ||
| import { CustomId } from '$lib/components'; | ||
| import { Pill } from '$lib/elements'; | ||
| import { FormList, InputFile } from '$lib/elements/forms'; | ||
| import WizardStep from '$lib/layout/wizardStep.svelte'; | ||
| import { bucket } from '../store'; | ||
| import { createFile } from './store'; | ||
|
|
||
| let showCustomId = false; | ||
| </script> | ||
|
|
||
| <WizardStep> | ||
| <svelte:fragment slot="title">Create file</svelte:fragment> | ||
| <svelte:fragment slot="subtitle">Upload a file to add it to your bucket.</svelte:fragment> | ||
| <FormList> | ||
| <div class="u-width-full-line u-overflow-hidden"> | ||
| <InputFile | ||
| required | ||
| bind:files={$createFile.files} | ||
| allowedFileExtensions={$bucket.allowedFileExtensions} | ||
| maxSize={$bucket.maximumFileSize} /> | ||
| </div> | ||
|
|
||
| {#if !showCustomId} | ||
| <div> | ||
| <Pill button on:click={() => (showCustomId = !showCustomId)}> | ||
| <span class="icon-pencil" aria-hidden="true" /><span class="text"> | ||
| File ID | ||
| </span> | ||
| </Pill> | ||
| </div> | ||
| {:else} | ||
| <div class="custom-id-wrapper"> | ||
| <CustomId bind:show={showCustomId} name="File" bind:id={$createFile.id} /> | ||
| </div> | ||
| {/if} | ||
| </FormList> | ||
| </WizardStep> | ||
|
|
||
| <style lang="scss"> | ||
| .custom-id-wrapper :global(.is-inner-modal) { | ||
| inline-size: auto; | ||
| } | ||
TGlide marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </style> | ||
39 changes: 39 additions & 0 deletions
39
src/routes/console/project-[project]/storage/bucket-[bucket]/create-file/step2.svelte
This file contains hidden or 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,39 @@ | ||
| <script lang="ts"> | ||
| import Alert from '$lib/components/alert.svelte'; | ||
| import Permissions from '$lib/components/permissions/permissions.svelte'; | ||
| import WizardStep from '$lib/layout/wizardStep.svelte'; | ||
| import { bucket } from '../store'; | ||
| import { createFile } from './store'; | ||
| </script> | ||
|
|
||
| <WizardStep> | ||
| <svelte:fragment slot="title">Update Permissions</svelte:fragment> | ||
| <svelte:fragment slot="subtitle"> | ||
| Choose who can access your buckets and files. For more information, check out the | ||
| <a | ||
| href="https://appwrite.io/docs/advanced/platform/permissions" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| class="link"> | ||
| Permissions Guide | ||
| </a>.</svelte:fragment> | ||
|
|
||
| {#if $bucket.fileSecurity} | ||
| <div class="common-section"> | ||
| <Alert type="info"> | ||
| <svelte:fragment slot="title">File security enabled</svelte:fragment> | ||
| Users will be able to access this file if they have been granted | ||
| <b>either File or Bucket permissions</b>. | ||
| </Alert> | ||
| </div> | ||
| <div class="common-section"> | ||
| <Permissions bind:permissions={$createFile.permissions} /> | ||
| </div> | ||
| {:else} | ||
| <Alert type="info"> | ||
| <svelte:fragment slot="title">File security disabled</svelte:fragment> | ||
| If you want to assign file permissions, navigate to Bucket settings and enable file security. | ||
| Otherwise, only Bucket permissions will be used. | ||
| </Alert> | ||
| {/if} | ||
| </WizardStep> |
24 changes: 24 additions & 0 deletions
24
src/routes/console/project-[project]/storage/bucket-[bucket]/create-file/store.ts
This file contains hidden or 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,24 @@ | ||
| import { writable } from 'svelte/store'; | ||
|
|
||
| type CreateFile = { | ||
| files: FileList | null; | ||
| id: string | null; | ||
| permissions: string[]; | ||
| }; | ||
|
|
||
| const initialState: CreateFile = { | ||
| files: null, | ||
| id: null, | ||
| permissions: [] | ||
| }; | ||
|
|
||
| export const createFile = (function initialize() { | ||
| const store = writable<CreateFile>({ ...initialState }); | ||
|
|
||
| return { | ||
| ...store, | ||
| reset() { | ||
| store.set({ ...initialState }); | ||
| } | ||
| }; | ||
| })(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add this in pink? @elad2412