Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

[C-2997] Disable delete on the last collection upload track #3954

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ const messages = {
type CollectionTrackFieldProps = {
index: number
remove: (index: number) => void
disableDelete: boolean
}

export const CollectionTrackField = (props: CollectionTrackFieldProps) => {
const { index, remove } = props
const { disableDelete = false, index, remove } = props
const [{ value: track }] = useField<CollectionTrackForUpload>(
`tracks.${index}`
)
Expand Down Expand Up @@ -94,6 +95,7 @@ export const CollectionTrackField = (props: CollectionTrackFieldProps) => {
iconLeft={IconPlay}
/>
<HarmonyButton
disabled={disableDelete}
variant={HarmonyButtonType.GHOST}
size={HarmonyButtonSize.SMALL}
text={messages.delete}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ export const CollectionTrackFieldArray = () => {
{...provided.draggableProps}
{...provided.dragHandleProps}
>
<CollectionTrackField index={index} remove={remove} />
<CollectionTrackField
index={index}
remove={remove}
disableDelete={tracks.length === 1}
/>
</div>
)}
</Draggable>
Expand Down