-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Removed unused multiple paths logic * Extracted DeleteFiles dialog * Improved loading indication * Added resetState * Fixed dialog spacing * Normalized dilaog naming * Implemented proper RenameFile * Removed unused CopyFile/Folder * Added secondary text to the Remove action * Properly implemented CreateFolder * Normalized action list * Fixed SaveChanges * Fixed rename primary title * Movde LinearProgress to library * Reverted context menu changes
- Loading branch information
Showing
31 changed files
with
448 additions
and
459 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
client/components/Application/Dialogs/CreateFolder/CreateFolder.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,29 @@ | ||
import { LinearProgress } from '@client/components/Library/LinearProgress' | ||
import InputDialog from '@client/components/Parts/Dialogs/Input' | ||
import * as appStore from '@client/store' | ||
import * as React from 'react' | ||
import * as store from './store' | ||
|
||
export function CreateFolderDialog() { | ||
const folderPath = appStore.useStore(appStore.getFolderPath) | ||
const dialog = appStore.useStore((state) => state.dialog) | ||
const { progress } = store.useState() | ||
|
||
React.useEffect(() => { | ||
store.resetState() | ||
}, [dialog]) | ||
|
||
return ( | ||
<InputDialog | ||
open={true} | ||
value={folderPath} | ||
title="Create new folder" | ||
label="Create" | ||
placholder="Name of the new folder" | ||
onCancel={store.closeDialog} | ||
onConfirm={store.createFolder} | ||
> | ||
<LinearProgress progress={progress} /> | ||
</InputDialog> | ||
) | ||
} |
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 @@ | ||
export { CreateFolderDialog } from './CreateFolder' |
43 changes: 43 additions & 0 deletions
43
client/components/Application/Dialogs/CreateFolder/store.ts
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,43 @@ | ||
import { client } from '@client/client' | ||
import * as helpers from '@client/helpers' | ||
import * as appStore from '@client/store' | ||
import * as types from '@client/types' | ||
|
||
class State { | ||
progress?: types.IProgress | ||
} | ||
|
||
export const { state, useState, resetState } = helpers.createState( | ||
'CreateFolderDialog', | ||
new State() | ||
) | ||
|
||
export function closeDialog() { | ||
if (!state.progress?.blocking) { | ||
appStore.closeDialog() | ||
} | ||
} | ||
|
||
export async function createFolder(path: string) { | ||
state.progress = { | ||
type: 'creating', | ||
title: 'Creating a folder', | ||
blocking: true, | ||
hidden: true, | ||
} | ||
|
||
const result = await client.folderCreate({ path, deduplicate: true }) | ||
|
||
if (result instanceof client.Error) { | ||
state.progress = { | ||
type: 'error', | ||
title: `Error creating a folder`, | ||
message: result.detail, | ||
} | ||
} else { | ||
appStore.onFileCreated([result.path]) | ||
} | ||
|
||
state.progress = undefined | ||
closeDialog() | ||
} |
35 changes: 35 additions & 0 deletions
35
client/components/Application/Dialogs/DeleteFile/DeleteFile.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,35 @@ | ||
import { LinearProgress } from '@client/components/Library/LinearProgress' | ||
import TwoButtonDialog from '@client/components/Parts/Dialogs/TwoButton' | ||
import * as appStore from '@client/store' | ||
import * as React from 'react' | ||
import * as store from './store' | ||
|
||
export function DeleteFileDialog() { | ||
const isFolder = appStore.useStore(appStore.getIsFolder) | ||
const dialog = appStore.useStore((state) => state.dialog) | ||
const { progress } = store.useState() | ||
|
||
React.useEffect(() => { | ||
store.resetState() | ||
}, [dialog]) | ||
|
||
const title = isFolder ? 'Delete Folder' : 'Delete File' | ||
const description = !progress | ||
? `Are you sure you want to delete this ${isFolder ? 'folder' : 'file'}?` | ||
: undefined | ||
|
||
return ( | ||
<TwoButtonDialog | ||
open={true} | ||
title={title} | ||
description={description} | ||
label="Delete" | ||
hoverBgButtonColor="OKFNRed600" | ||
cancelLabel="No" | ||
onCancel={store.closeDialog} | ||
onConfirm={store.deleteFile} | ||
> | ||
<LinearProgress progress={progress} /> | ||
</TwoButtonDialog> | ||
) | ||
} |
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 @@ | ||
export { DeleteFileDialog } from './DeleteFile' |
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,50 @@ | ||
import { client } from '@client/client' | ||
import * as helpers from '@client/helpers' | ||
import * as appStore from '@client/store' | ||
import * as types from '@client/types' | ||
|
||
class State { | ||
progress?: types.IProgress | ||
} | ||
|
||
export const { state, useState, resetState } = helpers.createState( | ||
'DeleteFileDialog', | ||
new State() | ||
) | ||
|
||
export function closeDialog() { | ||
if (!state.progress?.blocking) { | ||
appStore.closeDialog() | ||
} | ||
} | ||
|
||
export async function deleteFile() { | ||
const isFolder = appStore.getIsFolder(appStore.getState()) | ||
const { path } = appStore.getState() | ||
if (!path) return | ||
|
||
const target = isFolder ? 'folder' : 'file' | ||
|
||
state.progress = { | ||
type: 'deleting', | ||
title: `Deleting selected ${target}`, | ||
blocking: true, | ||
} | ||
|
||
const result = isFolder | ||
? await client.folderDelete({ path }) | ||
: await client.fileDelete({ path }) | ||
|
||
if (result instanceof client.Error) { | ||
state.progress = { | ||
type: 'error', | ||
title: `Error deleting ${target}`, | ||
message: result.detail, | ||
} | ||
} else { | ||
appStore.onFileDeleted([path]) | ||
} | ||
|
||
state.progress = undefined | ||
closeDialog() | ||
} |
51 changes: 0 additions & 51 deletions
51
client/components/Application/Dialogs/DeleteFilesFolders.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
client/components/Application/Dialogs/RenameFile/RenameFile.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,32 @@ | ||
import { LinearProgress } from '@client/components/Library/LinearProgress' | ||
import InputDialog from '@client/components/Parts/Dialogs/Input' | ||
import * as appStore from '@client/store' | ||
import * as React from 'react' | ||
import * as store from './store' | ||
|
||
export function RenameFileDialog() { | ||
const isFolder = appStore.useStore(appStore.getIsFolder) | ||
const dialog = appStore.useStore((state) => state.dialog) | ||
const { progress } = store.useState() | ||
|
||
React.useEffect(() => { | ||
store.resetState() | ||
}, [dialog]) | ||
|
||
const title = `Rename ${isFolder ? 'folder' : 'file'}` | ||
const placeholder = `Name of new ${isFolder ? 'folder' : 'file'}` | ||
|
||
return ( | ||
<InputDialog | ||
open={true} | ||
value="" | ||
title={title} | ||
label="Save" | ||
placholder={placeholder} | ||
onCancel={store.closeDialog} | ||
onConfirm={store.renameFile} | ||
> | ||
<LinearProgress progress={progress} /> | ||
</InputDialog> | ||
) | ||
} |
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 @@ | ||
export { RenameFileDialog } from './RenameFile' |
Oops, something went wrong.