Skip to content

Commit

Permalink
Remove Update button from DuplicateAssetsModal on LocalBackend
Browse files Browse the repository at this point in the history
  • Loading branch information
MrFlashAccount committed Sep 24, 2024
1 parent 9f0a4b3 commit 56d1b00
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
3 changes: 2 additions & 1 deletion 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 { isSpecialReadonlyDirectoryId } from '#/services/RemoteBackend'
import RemoteBackend, { isSpecialReadonlyDirectoryId } from '#/services/RemoteBackend'

import { ErrorDisplay } from '#/components/ErrorBoundary'
import { useEventCallback } from '#/hooks/eventCallbackHooks'
Expand Down Expand Up @@ -1839,6 +1839,7 @@ export default function AssetsTable(props: AssetsTableProps) {
})
setModal(
<DuplicateAssetsModal
canUpdate={backend instanceof RemoteBackend}
parentKey={event.parentKey}
parentId={event.parentId}
conflictingFiles={conflictingFiles}
Expand Down
34 changes: 22 additions & 12 deletions app/dashboard/src/modals/DuplicateAssetsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ 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 } = props
const { conflictingFiles: conflictingFilesRaw, canUpdate = true } = props
const { conflictingProjects: conflictingProjectsRaw, doUpdateConflicting } = props
const { siblingFileNames: siblingFileNamesRaw } = props
const { siblingProjectNames: siblingProjectNamesRaw } = props
Expand Down Expand Up @@ -194,7 +200,7 @@ export default function DuplicateAssetsModal(props: DuplicateAssetsModalProps) {
className="relative"
/>
</div>
{count > 1 && (
{count > 1 && canUpdate && (
<ariaComponents.ButtonGroup>
<ariaComponents.Button
variant="outline"
Expand All @@ -214,6 +220,7 @@ export default function DuplicateAssetsModal(props: DuplicateAssetsModalProps) {
>
{getText('update')}
</ariaComponents.Button>

<ariaComponents.Button
variant="outline"
onPress={() => {
Expand Down Expand Up @@ -252,17 +259,20 @@ export default function DuplicateAssetsModal(props: DuplicateAssetsModalProps) {
: getText('andOtherProjects', otherProjectsCount)}
</aria.Text>
)}

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

Please sign in to comment.