Skip to content

Commit

Permalink
Merge pull request #10288 from chehitskenniexd/loadouts_copy_and_edit…
Browse files Browse the repository at this point in the history
…_button

[Loadouts][Enhancements] Copy and Edit Loadout
  • Loading branch information
bhollis authored May 24, 2024
2 parents 3f60838 + 59324d0 commit 87791be
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@
"ClearSpaceWeapons": "Move other weapons away",
"ClearSpaceArmor": "Move other armor away",
"ClearUnsetMods": "Remove other mods",
"CopyAndEdit": "Edit Copy",
"Create": "Create Loadout",
"CurrentlyEquipped": "Currently Equipped",
"Delete": "Delete",
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Added an overload to the `inloadout:` search which allows searching items based on how many loadouts they are in, for example `inloadout:>2`.
* Added `is:fashiononly` and `is:modsonly` search keywords to loadouts search.
* Pages such as "About" and "Settings" now respect device safe areas when the device is in landscape mode.
* You can now edit a copy of a Loadout directly, with no risk of overwriting the existing loadout.
* Fixed some bounties showing as "Arc" that were not, in fact, Arc.
* Fixed the too-narrow width of the sidebar on the Loadout Optimizer on app.destinyitemmanager.com.
* Fixed distorted icons for owned mods in collections.
Expand Down
17 changes: 17 additions & 0 deletions src/app/loadout-drawer/loadout-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export const editLoadout$ = new EventBus<{
storeId: string;
}>();
export const addItem$ = new EventBus<DimItem>();
export const copyAndEditLoadout$ = new EventBus<{
loadout: Loadout;
showClass?: boolean;
storeId: string;
}>();

/**
* Start editing a loadout.
Expand All @@ -32,3 +37,15 @@ export function editLoadout(
export function addItemToLoadout(item: DimItem) {
addItem$.next(item);
}

/**
* Copy and Edit Loadout
*/
export function copyAndEditLoadout(
loadout: Loadout,
storeId: string,
{ showClass = true }: { showClass?: boolean } = {},
) {
const copiedLoadout = { ...loadout, name: `${loadout.name} - Copy` };
editLoadout(copiedLoadout, storeId, { showClass, isNew: true });
}
12 changes: 11 additions & 1 deletion src/app/loadout/LoadoutsRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { t } from 'app/i18next-t';
import { DimStore } from 'app/inventory/store-types';
import { deleteLoadout } from 'app/loadout-drawer/actions';
import { applyLoadout } from 'app/loadout-drawer/loadout-apply';
import { editLoadout } from 'app/loadout-drawer/loadout-events';
import { copyAndEditLoadout, editLoadout } from 'app/loadout-drawer/loadout-events';
import { Loadout } from 'app/loadout-drawer/loadout-types';
import { AppIcon, deleteIcon } from 'app/shell/icons';
import { useThunkDispatch } from 'app/store/thunk-dispatch';
Expand Down Expand Up @@ -38,6 +38,7 @@ export default memo(function LoadoutRow({

const handleEdit = () => editLoadout(loadout, store.id, { isNew: !saved });
const handleShare = () => onShare(loadout);
const handleCopyAndEdit = () => copyAndEditLoadout(loadout, store.id);

const actionButtons: ReactNode[] = [];

Expand All @@ -55,6 +56,15 @@ export default memo(function LoadoutRow({
</button>,
);

if (equippable) {
// add button here to copy and edit the loadout
actionButtons.push(
<button key="copyAndEdit" type="button" className="dim-button" onClick={handleCopyAndEdit}>
{t('Loadouts.CopyAndEdit')}
</button>,
);
}

actionButtons.push(
<button key="share" type="button" className="dim-button" onClick={handleShare}>
{t('Loadouts.ShareLoadout')}
Expand Down
1 change: 1 addition & 0 deletions src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,7 @@
"ClearSpaceWeapons": "Move other weapons away",
"ClearUnsetMods": "Remove other mods",
"ClearingSpace": "Moving other items away",
"CopyAndEdit": "Edit Copy",
"Create": "Create Loadout",
"CurrentlyEquipped": "Currently Equipped",
"Deequip": "De-equipping items from other characters",
Expand Down

0 comments on commit 87791be

Please sign in to comment.