Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent user from altering the pin state of 'fixed' items as per api spec #15360

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions website/client/src/components/tasks/column.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
>
<span
class="badge-top"
:class="{'disabled': !ctx.item.pinTogglable}"
@click.prevent.stop="togglePinned(ctx.item)"
@keypress.enter.prevent.stop="togglePinned(ctx.item)"
>
Expand All @@ -157,6 +158,13 @@
display: none;
}

.badge-top.disabled {
.badge-pin {
background-color: $gray-50;
cursor: default;
}
}

.item:hover .badge-pin {
display: block;
}
Expand Down Expand Up @@ -790,6 +798,10 @@ export default {
return;
}

if (!item.pinTogglable) {
return;
}

try {
if (!this.$store.dispatch('user:togglePinnedItem', { type: item.pinType, path: item.path })) {
this.text(this.$t('unpinnedItem', { item: item.text }));
Expand Down
8 changes: 8 additions & 0 deletions website/common/script/libs/getItemInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ function isItemSuggested (officialPinnedItems, itemInfo) {
}) > -1;
}

function pinIsTogglable (itemInfo) {
if (itemInfo.path === 'armoire' || itemInfo.path === 'potion' || itemInfo.type === 'debuffPotion') {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also referenced in the api.
Maybe this could be centralised.

API:

if (path === 'armoire' || path === 'potion' || type === 'debuffPotion') {
// @TODO: take into considertation debuffPotion type in message
throw new BadRequest(i18n.t('cannotUnpinItem', req.language));

return false;
}
return true;
}

function getDefaultGearProps (item, language) {
return {
key: item.key,
Expand Down Expand Up @@ -483,6 +490,7 @@ export default function getItemInfo (user, type, item, officialPinnedItems, lang
if (itemInfo) {
itemInfo.isSuggested = isItemSuggested(officialPinnedItems, itemInfo);
itemInfo.pinned = isPinned(user, itemInfo, officialPinnedItems);
itemInfo.pinTogglable = pinIsTogglable(itemInfo);
} else {
throw new BadRequest(i18n.t('wrongItemType', { type }, language));
}
Expand Down
Loading