Skip to content

Commit

Permalink
fix: revert usage of short links in QRcode and displayed link (#834)
Browse files Browse the repository at this point in the history
* fix: revert usage of short links in QRcode and displayed link

* chore(test): adapt tests for revert
  • Loading branch information
spaenleh authored Oct 23, 2023
1 parent 77ee600 commit cda2071
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
7 changes: 2 additions & 5 deletions cypress/e2e/item/share/shareItem.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Context, ItemLoginSchemaType, ItemTagType } from '@graasp/sdk';

import shortUUID from 'short-uuid';

import { buildItemPath } from '@/config/paths';

import { SETTINGS } from '../../../../src/config/constants';
Expand Down Expand Up @@ -41,17 +39,16 @@ describe('Share Item', () => {
cy.visit(buildItemPath(item.id));
openShareItemTab(item.id);

const { fromUUID } = shortUUID();
// sharing link
cy.get(`#${SHARE_ITEM_DIALOG_LINK_ID}`).should(
'contain',
`${buildGraaspPlayerView(fromUUID(item.id))}`,
`${buildGraaspPlayerView(item.id)}`,
);
cy.get(`#${SHARE_ITEM_DIALOG_LINK_SELECT_ID}`).click();
cy.get(`li[data-value="${Context.Builder}"]`).click();
cy.get(`#${SHARE_ITEM_DIALOG_LINK_ID}`).should(
'have.text',
`${buildGraaspBuilderView(fromUUID(item.id))}`,
`${buildGraaspBuilderView(item.id)}`,
);

const visiblitySelect = cy.get(
Expand Down
21 changes: 4 additions & 17 deletions src/components/item/sharing/SharingLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import Tooltip from '@mui/material/Tooltip';
import { Context } from '@graasp/sdk';
import { FAILURE_MESSAGES, SUCCESS_MESSAGES } from '@graasp/translations';

import shortUUID from 'short-uuid';

import QRCode from '@/components/common/QRCode';
import {
SHARE_LINK_COLOR,
Expand Down Expand Up @@ -60,7 +58,6 @@ type Props = {
itemId?: string;
};

const { fromUUID } = shortUUID();
const SharingLink = ({ itemId }: Props): JSX.Element => {
const { t: translateMessages } = useMessagesTranslation();
const { t: translateBuilder } = useBuilderTranslation();
Expand All @@ -73,11 +70,11 @@ const SharingLink = ({ itemId }: Props): JSX.Element => {
if (itemId) {
switch (linkType) {
case Context.Builder: {
setLink(buildGraaspBuilderView(fromUUID(itemId || '')));
setLink(buildGraaspBuilderView(itemId || ''));
break;
}
case Context.Player: {
setLink(buildGraaspPlayerView(fromUUID(itemId || '')));
setLink(buildGraaspPlayerView(itemId || ''));
break;
}
default:
Expand Down Expand Up @@ -137,18 +134,8 @@ const SharingLink = ({ itemId }: Props): JSX.Element => {
renderValue={(value) => enumT(value)}
id={SHARE_ITEM_DIALOG_LINK_SELECT_ID}
>
<MenuItem
// sx={{ textTransform: 'capitalize' }}
value={Context.Builder}
>
{enumT(Context.Builder)}
</MenuItem>
<MenuItem
// sx={{ textTransform: 'capitalize' }}
value={Context.Player}
>
{enumT(Context.Player)}
</MenuItem>
<MenuItem value={Context.Builder}>{enumT(Context.Builder)}</MenuItem>
<MenuItem value={Context.Player}>{enumT(Context.Player)}</MenuItem>
</Select>
<Tooltip title={translateBuilder(BUILDER.SHARE_ITEM_LINK_COPY_TOOLTIP)}>
<span>
Expand Down

0 comments on commit cda2071

Please sign in to comment.