-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QoL: Add "Rename/Move" action to "Edit Group" and "Edit Series" modal (…
…#1179) * QoL: Add "Rename/Move" action to "Edit Group" and "Edit Series" modal This allow to call default renamer, on related files from Collection tab, making easier to rename files after organized in shoko groups * refactor to use the dedicated endpoint * Display message when targeting unsupported server version * Apply suggestions from code review Co-authored-by: Harshith Mohan <26010946+harshithmohan@users.noreply.github.com> * Apply suggestions from code review --------- Co-authored-by: ElementalCrisis <9443295+ElementalCrisis@users.noreply.github.com> Co-authored-by: Harshith Mohan <26010946+harshithmohan@users.noreply.github.com>
- Loading branch information
1 parent
b8bdeac
commit 650680b
Showing
7 changed files
with
96 additions
and
1 deletion.
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 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,23 @@ | ||
import React from 'react'; | ||
import cx from 'classnames'; | ||
|
||
const Action = ( | ||
{ description, name, onClick, scroll }: { name: string, description: string, scroll?: boolean, onClick: () => void }, | ||
) => ( | ||
<div | ||
className={cx( | ||
'flex flex-row justify-between gap-y-2 cursor-pointer hover:text-panel-text-primary transition-colors', | ||
scroll ? 'mr-4' : '', | ||
)} | ||
onClick={onClick} | ||
> | ||
<div className="flex w-full flex-col gap-y-1"> | ||
<div className="flex justify-between"> | ||
<div>{name}</div> | ||
</div> | ||
<div className="text-sm text-panel-text opacity-65">{description}</div> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default React.memo(Action); |
29 changes: 29 additions & 0 deletions
29
src/components/Collection/Group/EditGroupTabs/FileActionsTab.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 React from 'react'; | ||
|
||
import Action from '@/components/Collection/Group/EditGroupTabs/Action'; | ||
import toast from '@/components/Toast'; | ||
import { useRelocateGroupFilesMutation } from '@/core/react-query/group/mutations'; | ||
import useIsFeatureSupported, { FeatureType } from '@/hooks/useIsFeatureSupported'; | ||
|
||
type Props = { | ||
groupId: number; | ||
}; | ||
|
||
const FileActionsTab = ({ groupId }: Props) => { | ||
const { mutate: relocateGroupFiles } = useRelocateGroupFilesMutation(groupId); | ||
const showUnsupportedToast = () => { | ||
toast.error(`This feature require server version >= ${FeatureType.RelocateSeriesFiles}`); | ||
}; | ||
|
||
return ( | ||
<div className="flex h-[22rem] grow flex-col gap-y-4 overflow-y-auto"> | ||
<Action | ||
name="Rename/Move Files" | ||
description="Rename/Move every file associated with the group." | ||
onClick={useIsFeatureSupported(FeatureType.RelocateSeriesFiles) ? relocateGroupFiles : showUnsupportedToast} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FileActionsTab; |
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 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 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 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