Skip to content

Commit 86fe304

Browse files
authored
feat(edit): show tavle url in copyable text (#1799)
* feat(edit): show tavle url in copyable text * fix(edit): rename duplicate button * feat(edit): link not crunching on mobile screen * fix(edit): not show copyable text if link is undefined
1 parent c16ef70 commit 86fe304

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

tavla/app/(admin)/edit/[id]/components/ActionsMenu/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import { OverflowMenu } from '@entur/menu'
33
import { TBoard, TOrganizationID } from 'types/settings'
44
import { DuplicateBoard } from '../DuplicateBoard'
5-
import { Delete } from 'app/(admin)/boards/components/Column/Delete'
65

76
function ActionsMenu({ board, oid }: { board: TBoard; oid?: TOrganizationID }) {
87
return (
@@ -22,9 +21,8 @@ function OverflowActionsMenu({
2221
}) {
2322
return (
2423
<div className="hidden md:flex">
25-
<OverflowMenu position="left">
24+
<OverflowMenu placement="bottom-left">
2625
<DuplicateBoard board={board} oid={oid} />
27-
<Delete board={board} type="action" />
2826
</OverflowMenu>
2927
</div>
3028
)
@@ -34,7 +32,6 @@ function ButtonsMenu({ board, oid }: { board: TBoard; oid?: TOrganizationID }) {
3432
return (
3533
<div className="flex flex-col md:flex-row md:items-center gap-4 md:hidden">
3634
<DuplicateBoard board={board} oid={oid} type="button" />
37-
<Delete board={board} type="button" />
3835
</div>
3936
)
4037
}

tavla/app/(admin)/edit/[id]/components/Buttons/Copy.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client'
2-
import { useToast } from '@entur/alert'
3-
import { Button, IconButton } from '@entur/button'
2+
import { CopyableText, useToast } from '@entur/alert'
3+
import { IconButton } from '@entur/button'
44
import { CopyIcon } from '@entur/icons'
55
import { Tooltip } from '@entur/tooltip'
66
import { useLink } from 'hooks/useLink'
@@ -10,20 +10,22 @@ function Copy({ type, bid }: { type?: 'button' | 'icon'; bid?: string }) {
1010
const link = useLink(bid)
1111
const copy = () => {
1212
navigator.clipboard.writeText(link ?? '')
13-
addToast('Lenke til Tavla kopiert')
13+
addToast('Lenken til tavlen ble kopiert!')
1414
}
1515

1616
if (type === 'button') {
17-
return (
18-
<Button
19-
variant="secondary"
20-
aria-label="Kopier lenken til tavlen"
21-
onClick={copy}
22-
>
23-
Kopier lenke
24-
<CopyIcon className="!top-[-1px]" />
25-
</Button>
26-
)
17+
if (link) {
18+
return (
19+
<CopyableText
20+
successHeading=""
21+
successMessage="Lenken til tavlen ble kopiert!"
22+
aria-label="Kopier lenken til tavlen"
23+
>
24+
{link.toString()}
25+
</CopyableText>
26+
)
27+
}
28+
return
2729
}
2830
return (
2931
<Tooltip

tavla/app/(admin)/edit/[id]/components/DuplicateBoard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function DuplicateBoard({
3737
aria-label="Dupliser tavle"
3838
onClick={handleSelect}
3939
>
40-
Dupliser Tavle
40+
Dupliser tavle
4141
<AddIcon />
4242
</Button>
4343
)

tavla/app/(admin)/edit/[id]/page.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { ThemeSelect } from './components/ThemeSelect'
2020
import { TileList } from './components/TileList'
2121
import { getBoard } from 'Board/scenarios/Board/firebase'
2222
import { getUserFromSessionCookie } from 'app/(admin)/utils/server'
23+
import { Delete } from 'app/(admin)/boards/components/Column/Delete'
2324

2425
export type TProps = {
2526
params: Promise<{ id: TBoardID }>
@@ -60,10 +61,13 @@ export default async function EditPage(props: TProps) {
6061
<div className="flex flex-col md:flex-row md:items-center gap-4">
6162
<Open bid={board.id} type="button" />
6263
<RefreshButton board={board} />
63-
<Copy bid={board.id} type="button" />
64+
<Delete board={board} type="button" />
6465
<ActionsMenu board={board} oid={organization?.id} />
6566
</div>
6667
</div>
68+
<div className="md:w-fit">
69+
<Copy bid={board.id} type="button" />
70+
</div>
6771

6872
<div className="bg-background rounded-md py-8 px-6 flex flex-col gap-4">
6973
<Heading2>Stoppesteder</Heading2>

0 commit comments

Comments
 (0)