({
type Props = {
alias: string;
- aliasUnchanged: boolean;
+ hasAliasChanged: boolean;
isAvailableLoading: boolean;
shortLinkAvailable?: ShortLinkAvailable;
onValidAlias: (isValid: boolean) => void;
@@ -25,7 +25,7 @@ type Props = {
const AliasValidation = ({
alias,
- aliasUnchanged,
+ hasAliasChanged,
isAvailableLoading,
shortLinkAvailable,
onValidAlias,
@@ -50,7 +50,7 @@ const AliasValidation = ({
if (!isValid) {
const msgKey = messageKey ?? BUILDER.SHORT_LINK_UNKOWN_ERROR;
setMessage(translateBuilder(msgKey, { data }));
- } else if (aliasUnchanged) {
+ } else if (!hasAliasChanged) {
setMessage(ALIAS_UNCHANGED_MSG);
setAvailable(true);
} else if (isAvailableLoading) {
@@ -60,20 +60,24 @@ const AliasValidation = ({
setMessage(aliasAvailable ? ALIAS_VALID_MSG : ALIAS_ALREADY_EXIST);
setAvailable(aliasAvailable);
}
+
+ onValidAlias(valid);
+ onError(hasError);
}, [
alias,
- aliasUnchanged,
+ hasAliasChanged,
isAvailableLoading,
shortLinkAvailable?.available,
translateBuilder,
ALIAS_UNCHANGED_MSG,
ALIAS_VALID_MSG,
ALIAS_ALREADY_EXIST,
+ onValidAlias,
+ valid,
+ onError,
+ hasError,
]);
- useEffect(() => onValidAlias(valid), [valid, onValidAlias]);
- useEffect(() => onError(hasError), [hasError, onError]);
-
return {message};
};
diff --git a/src/components/item/sharing/shortLink/PlatformIcon.tsx b/src/components/item/sharing/shortLink/PlatformIcon.tsx
index 1394fa5a6..0b43d1ad1 100644
--- a/src/components/item/sharing/shortLink/PlatformIcon.tsx
+++ b/src/components/item/sharing/shortLink/PlatformIcon.tsx
@@ -1,5 +1,5 @@
import { Context } from '@graasp/sdk';
-import { BuildIcon, LibraryIcon, PlayIcon } from '@graasp/ui';
+import { BuildIcon, GraaspLogo, LibraryIcon, PlayIcon } from '@graasp/ui';
import { ShortLinkPlatform } from '@/utils/shortLink';
@@ -24,7 +24,8 @@ const PlatformIcon = ({
case Context.Library:
return ;
default:
- return Undefined platform {platform}
;
+ console.error(`Undefined platform ${platform}.`);
+ return ;
}
};
diff --git a/src/components/item/sharing/shortLink/ShortLink.tsx b/src/components/item/sharing/shortLink/ShortLink.tsx
index 38441f1c6..31290c467 100644
--- a/src/components/item/sharing/shortLink/ShortLink.tsx
+++ b/src/components/item/sharing/shortLink/ShortLink.tsx
@@ -11,7 +11,11 @@ import {
SHORT_LINK_CONTAINER_BORDER_WIDTH,
} from '@/config/constants';
import { mutations } from '@/config/queryClient';
-import { SHORT_LINK_COMPONENT } from '@/config/selectors';
+import {
+ SHORT_LINK_COMPONENT,
+ buildShortLinkPlatformTextId,
+ buildShortLinkUrlTextId,
+} from '@/config/selectors';
import { ShortLinkPlatform } from '@/utils/shortLink';
import ConfirmDeleteLink from './ConfirmDeleteLink';
@@ -63,8 +67,11 @@ const ShortLink = ({
const [modalOpen, setModalOpen] = useState(false);
const handleDeleteAlias = () => {
- if (!canAdminShortLink) return;
- deleteShortLink(alias);
+ if (canAdminShortLink) {
+ deleteShortLink(alias);
+ } else {
+ console.error('Only administrators can delete short link.');
+ }
};
const responsiveDirection = {
@@ -101,9 +108,19 @@ const ShortLink = ({
platform={platform}
accentColor={AccentColors[platform]}
/>
- {platform}
+
+ {platform}
+
- {url}
+
+ {url}
+