Skip to content

Commit

Permalink
Allow duplicate on local backend
Browse files Browse the repository at this point in the history
  • Loading branch information
MrFlashAccount committed Sep 25, 2024
1 parent 56d1b00 commit af3db4e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
3 changes: 1 addition & 2 deletions app/dashboard/src/layouts/AssetsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ import type Backend from '#/services/Backend'
import * as backendModule from '#/services/Backend'
import LocalBackend, * as localBackendModule from '#/services/LocalBackend'
import * as projectManager from '#/services/ProjectManager'
import RemoteBackend, { isSpecialReadonlyDirectoryId } from '#/services/RemoteBackend'
import { isSpecialReadonlyDirectoryId } from '#/services/RemoteBackend'

import { ErrorDisplay } from '#/components/ErrorBoundary'
import { useEventCallback } from '#/hooks/eventCallbackHooks'
Expand Down Expand Up @@ -1839,7 +1839,6 @@ export default function AssetsTable(props: AssetsTableProps) {
})
setModal(
<DuplicateAssetsModal
canUpdate={backend instanceof RemoteBackend}
parentKey={event.parentKey}
parentId={event.parentId}
conflictingFiles={conflictingFiles}
Expand Down
33 changes: 13 additions & 20 deletions app/dashboard/src/modals/DuplicateAssetsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,11 @@ export interface DuplicateAssetsModalProps {
readonly nonConflictingProjectCount: number
readonly doUploadNonConflicting: () => void
readonly doUpdateConflicting: (toUpdate: ConflictingAsset[]) => void
/**
* Whether the user can update the assets.
* Usually it's not possible to update assets in local backends.
* @default true
*/
readonly canUpdate?: boolean
}

/** A modal for creating a new label. */
export default function DuplicateAssetsModal(props: DuplicateAssetsModalProps) {
const { conflictingFiles: conflictingFilesRaw, canUpdate = true } = props
const { conflictingFiles: conflictingFilesRaw } = props
const { conflictingProjects: conflictingProjectsRaw, doUpdateConflicting } = props
const { siblingFileNames: siblingFileNamesRaw } = props
const { siblingProjectNames: siblingProjectNamesRaw } = props
Expand Down Expand Up @@ -200,7 +194,7 @@ export default function DuplicateAssetsModal(props: DuplicateAssetsModalProps) {
className="relative"
/>
</div>
{count > 1 && canUpdate && (
{count > 1 && (
<ariaComponents.ButtonGroup>
<ariaComponents.Button
variant="outline"
Expand Down Expand Up @@ -261,18 +255,17 @@ export default function DuplicateAssetsModal(props: DuplicateAssetsModalProps) {
)}

<ariaComponents.ButtonGroup className="relative">
{canUpdate && (
<ariaComponents.Button
variant="submit"
onPress={() => {
doUploadNonConflicting()
doUpdateConflicting([...conflictingFiles, ...conflictingProjects])
unsetModal()
}}
>
{count === 1 ? getText('update') : getText('updateAll')}
</ariaComponents.Button>
)}
<ariaComponents.Button
variant="submit"
onPress={() => {
doUploadNonConflicting()
doUpdateConflicting([...conflictingFiles, ...conflictingProjects])
unsetModal()
}}
>
{count === 1 ? getText('update') : getText('updateAll')}
</ariaComponents.Button>

<ariaComponents.Button
variant="accent"
onPress={() => {
Expand Down

0 comments on commit af3db4e

Please sign in to comment.