Skip to content

Commit 7db6905

Browse files
authored
Merge pull request #453 from AppQuality/share-link-title
Share-link-title
2 parents a6addf3 + 1c1266d commit 7db6905

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

src/common/components/BugDetail/ShareBug.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ export const ShareButton = ({
3636
const [modalIsOpen, setModalIsOpen] = useState<boolean>(false);
3737
const { t } = useTranslation();
3838

39-
const { createLink, link, isLoading, isError } = useShareBug({ bid: bug.id });
39+
const { createLink, link, isLoading, isError } = useShareBug({
40+
bid: bug.id,
41+
reset: modalIsOpen,
42+
});
4043

4144
const getButtonContent = useCallback(() => {
4245
if (isError) {
@@ -72,9 +75,9 @@ export const ShareButton = ({
7275
</Trans>
7376
</StyledMd>
7477
<StyledMd>
75-
ID {bug.id} -
78+
ID {bug.id}{' '}
7679
<Span isBold>
77-
&quot;{bug.title.compact}
80+
&quot;{bug.title.full}
7881
&quot;
7982
</Span>
8083
</StyledMd>

src/common/components/BugDetail/hooks/useShareBug.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
1-
import { useCallback, useState } from 'react';
1+
import { useCallback, useEffect, useState } from 'react';
22
import queryString from 'query-string';
33

4-
export const useShareBug = ({ bid }: { bid: number }) => {
4+
export const useShareBug = ({
5+
bid,
6+
reset,
7+
}: {
8+
bid: number;
9+
reset: boolean;
10+
}) => {
511
const [link, setLink] = useState<string | undefined>(undefined);
612
const [isLoading, setisLoading] = useState<boolean>(false);
713
const [error, setError] = useState<Error | undefined>(undefined);
814

15+
useEffect(() => {
16+
if (reset) {
17+
setLink(undefined);
18+
setError(undefined);
19+
setisLoading(false);
20+
}
21+
}, [reset]);
22+
923
const createLink = useCallback(() => {
1024
setisLoading(true);
1125
setError(undefined);

src/pages/Bugs/Content/components/BugHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default ({
7070
/>
7171

7272
<ActionDetailPreview>
73-
<IconButton onClick={goToBug}>
73+
<IconButton size="small" onClick={goToBug}>
7474
<LinkIcon />
7575
</IconButton>
7676
<ShareButton bug={bug} />

0 commit comments

Comments
 (0)