tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
28
pulls
pipelines
reorganized Actions in leaflet a bit
cozylittle.house
4 months ago
c3407e44
94182057
+79
-70
13 changed files
expand all
collapse all
unified
split
app
(home-pages)
home
Actions
Actions.tsx
[leaflet_id]
Footer.tsx
Sidebar.tsx
actions
BackToPubButton.tsx
HelpButton.tsx
HomeButton.tsx
PublishButton.tsx
ShareOptions
DomainOptions.tsx
getShareLink.ts
index.tsx
lish
[did]
[publication]
dashboard
PublishedPostsLists.tsx
components
Blocks
RSVPBlock
SendUpdate.tsx
Pages
PageShareMenu.tsx
+2
-2
app/(home-pages)/home/Actions/Actions.tsx
···
1
1
"use client";
2
2
import { ThemePopover } from "components/ThemeManager/ThemeSetter";
3
3
import { CreateNewLeafletButton } from "./CreateNewButton";
4
4
-
import { HelpPopover } from "components/HelpPopover";
4
4
+
import { HelpButton } from "app/[leaflet_id]/actions/HelpButton";
5
5
import { AccountSettings } from "./AccountSettings";
6
6
import { useIdentityData } from "components/IdentityProvider";
7
7
import { useReplicache } from "src/replicache";
···
16
16
{identity ? <AccountSettings /> : <LoginActionButton />}
17
17
{/*<HelpPopover noShortcuts />*/}
18
18
<ThemePopover entityID={rootEntity} home />
19
19
-
<HelpPopover />
19
19
+
<HelpButton />
20
20
</>
21
21
);
22
22
};
+11
-29
app/[leaflet_id]/Actions.tsx
app/[leaflet_id]/actions/PublishButton.tsx
···
1
1
import { publishToPublication } from "actions/publishToPublication";
2
2
-
import {
3
3
-
getBasePublicationURL,
4
4
-
getPublicationURL,
5
5
-
} from "app/lish/createPub/getPublicationURL";
2
2
+
import { getPublicationURL } from "app/lish/createPub/getPublicationURL";
6
3
import { ActionButton } from "components/ActionBar/ActionButton";
7
7
-
import { GoBackSmall } from "components/Icons/GoBackSmall";
8
4
import { PublishSmall } from "components/Icons/PublishSmall";
9
5
import { useLeafletPublicationData } from "components/PageSWRDataProvider";
10
6
import { SpeedyLink } from "components/SpeedyLink";
11
7
import { useToaster } from "components/Toast";
12
8
import { DotLoader } from "components/utils/DotLoader";
13
13
-
import { useParams, useRouter } from "next/navigation";
9
9
+
import { useParams } from "next/navigation";
10
10
+
import { useRouter } from "next/router";
14
11
import { useState } from "react";
15
12
import { useReplicache } from "src/replicache";
16
16
-
import { Json } from "supabase/database.types";
17
17
-
18
18
-
export const BackToPubButton = (props: {
19
19
-
publication: {
20
20
-
identity_did: string;
21
21
-
indexed_at: string;
22
22
-
name: string;
23
23
-
record: Json;
24
24
-
uri: string;
25
25
-
};
26
26
-
}) => {
27
27
-
return (
28
28
-
<SpeedyLink
29
29
-
href={`${getBasePublicationURL(props.publication)}/dashboard`}
30
30
-
className="hover:no-underline!"
31
31
-
>
32
32
-
<ActionButton
33
33
-
icon={<GoBackSmall className="shrink-0" />}
34
34
-
label="To Pub"
35
35
-
/>
36
36
-
</SpeedyLink>
37
37
-
);
38
38
-
};
39
13
40
14
export const PublishButton = () => {
41
15
let { data: pub } = useLeafletPublicationData();
42
16
let params = useParams();
43
17
let router = useRouter();
18
18
+
if (!pub)
19
19
+
return (
20
20
+
<ActionButton
21
21
+
primary
22
22
+
icon={<PublishSmall className="shrink-0" />}
23
23
+
label={"Publish on ATP"}
24
24
+
/>
25
25
+
);
44
26
if (!pub?.doc)
45
27
return (
46
28
<ActionButton
+7
-6
app/[leaflet_id]/Footer.tsx
···
4
4
import { Media } from "components/Media";
5
5
import { ThemePopover } from "components/ThemeManager/ThemeSetter";
6
6
import { Toolbar } from "components/Toolbar";
7
7
-
import { ShareOptions } from "components/ShareOptions";
8
8
-
import { HomeButton } from "components/HomeButton";
7
7
+
import { ShareOptions } from "app/[leaflet_id]/actions/ShareOptions";
8
8
+
import { HomeButton } from "app/[leaflet_id]/actions/HomeButton";
9
9
+
import { PublishButton } from "./actions/PublishButton";
9
10
import { useEntitySetContext } from "components/EntitySetProvider";
10
10
-
import { HelpPopover } from "components/HelpPopover";
11
11
+
import { HelpButton } from "app/[leaflet_id]/actions/HelpButton";
11
12
import { Watermark } from "components/Watermark";
12
12
-
import { BackToPubButton, PublishButton } from "./Actions";
13
13
+
import { BackToPubButton } from "./actions/BackToPubButton";
13
14
import { useLeafletPublicationData } from "components/PageSWRDataProvider";
14
15
import { useIdentityData } from "components/IdentityProvider";
15
16
···
43
44
<BackToPubButton publication={pub.publications} />
44
45
<PublishButton />
45
46
<ShareOptions />
46
46
-
<HelpPopover />
47
47
+
<HelpButton />
47
48
<ThemePopover entityID={props.entityID} />
48
49
</ActionFooter>
49
50
) : (
50
51
<ActionFooter>
51
52
<HomeButton />
52
53
<ShareOptions />
53
53
-
<HelpPopover />
54
54
+
<HelpButton />
54
55
<ThemePopover entityID={props.entityID} />
55
56
</ActionFooter>
56
57
)
+7
-6
app/[leaflet_id]/Sidebar.tsx
···
2
2
import { ActionButton } from "components/ActionBar/ActionButton";
3
3
import { Sidebar } from "components/ActionBar/Sidebar";
4
4
import { useEntitySetContext } from "components/EntitySetProvider";
5
5
-
import { HelpPopover } from "components/HelpPopover";
6
6
-
import { HomeButton } from "components/HomeButton";
5
5
+
import { HelpButton } from "app/[leaflet_id]/actions/HelpButton";
6
6
+
import { HomeButton } from "app/[leaflet_id]/actions/HomeButton";
7
7
import { Media } from "components/Media";
8
8
import { useLeafletPublicationData } from "components/PageSWRDataProvider";
9
9
-
import { ShareOptions } from "components/ShareOptions";
9
9
+
import { ShareOptions } from "app/[leaflet_id]/actions/ShareOptions";
10
10
import { ThemePopover } from "components/ThemeManager/ThemeSetter";
11
11
+
import { PublishButton } from "./actions/PublishButton";
11
12
import { Watermark } from "components/Watermark";
12
13
import { useUIState } from "src/useUIState";
13
13
-
import { BackToPubButton, PublishButton } from "./Actions";
14
14
+
import { BackToPubButton } from "./actions/BackToPubButton";
14
15
import { useIdentityData } from "components/IdentityProvider";
15
16
import { useReplicache } from "src/replicache";
16
17
···
36
37
<PublishButton />
37
38
<ShareOptions />
38
39
<ThemePopover entityID={rootEntity} />
39
39
-
<HelpPopover />
40
40
+
<HelpButton />
40
41
<hr className="text-border" />
41
42
<BackToPubButton publication={pub.publications} />
42
43
</>
···
44
45
<>
45
46
<ShareOptions />
46
47
<ThemePopover entityID={rootEntity} />
47
47
-
<HelpPopover />
48
48
+
<HelpButton />
48
49
<hr className="text-border" />
49
50
<HomeButton />
50
51
</>
+27
app/[leaflet_id]/actions/BackToPubButton.tsx
···
1
1
+
import { getBasePublicationURL } from "app/lish/createPub/getPublicationURL";
2
2
+
import { ActionButton } from "components/ActionBar/ActionButton";
3
3
+
import { GoBackSmall } from "components/Icons/GoBackSmall";
4
4
+
import { SpeedyLink } from "components/SpeedyLink";
5
5
+
import { Json } from "supabase/database.types";
6
6
+
7
7
+
export const BackToPubButton = (props: {
8
8
+
publication: {
9
9
+
identity_did: string;
10
10
+
indexed_at: string;
11
11
+
name: string;
12
12
+
record: Json;
13
13
+
uri: string;
14
14
+
};
15
15
+
}) => {
16
16
+
return (
17
17
+
<SpeedyLink
18
18
+
href={`${getBasePublicationURL(props.publication)}/dashboard`}
19
19
+
className="hover:no-underline!"
20
20
+
>
21
21
+
<ActionButton
22
22
+
icon={<GoBackSmall className="shrink-0" />}
23
23
+
label="To Pub"
24
24
+
/>
25
25
+
</SpeedyLink>
26
26
+
);
27
27
+
};
+2
-6
app/lish/[did]/[publication]/dashboard/PublishedPostsLists.tsx
···
13
13
import { MoreOptionsVerticalTiny } from "components/Icons/MoreOptionsVerticalTiny";
14
14
import { DeleteSmall } from "components/Icons/DeleteSmall";
15
15
import { ShareSmall } from "components/Icons/ShareSmall";
16
16
-
import { ShareButton } from "components/ShareOptions";
16
16
+
import { ShareButton } from "app/[leaflet_id]/actions/ShareOptions";
17
17
import { SpeedyLink } from "components/SpeedyLink";
18
18
import { QuoteTiny } from "components/Icons/QuoteTiny";
19
19
import { CommentTiny } from "components/Icons/CommentTiny";
···
237
237
day: "2-digit",
238
238
});
239
239
240
240
-
return (
241
241
-
<p className="text-sm text-tertiary">
242
242
-
Published {formattedDate}
243
243
-
</p>
244
244
-
);
240
240
+
return <p className="text-sm text-tertiary">Published {formattedDate}</p>;
245
241
}
+2
-2
components/Blocks/RSVPBlock/SendUpdate.tsx
···
9
9
import { sendUpdateToRSVPS } from "actions/sendUpdateToRSVPS";
10
10
import { useReplicache } from "src/replicache";
11
11
import { Checkbox } from "components/Checkbox";
12
12
-
import { usePublishLink } from "components/ShareOptions";
12
12
+
import { useReadOnlyShareLink } from "app/[leaflet_id]/actions/ShareOptions";
13
13
14
14
export function SendUpdateButton(props: { entityID: string }) {
15
15
-
let publishLink = usePublishLink();
15
15
+
let publishLink = useReadOnlyShareLink();
16
16
let { permissions } = useEntitySetContext();
17
17
let { permission_token } = useReplicache();
18
18
let [input, setInput] = useState("");
+6
-6
components/HelpPopover.tsx
app/[leaflet_id]/actions/HelpButton.tsx
···
1
1
"use client";
2
2
-
import { ShortcutKey } from "./Layout";
3
3
-
import { Media } from "./Media";
4
4
-
import { Popover } from "./Popover";
2
2
+
import { ShortcutKey } from "../../../components/Layout";
3
3
+
import { Media } from "../../../components/Media";
4
4
+
import { Popover } from "../../../components/Popover";
5
5
import { metaKey } from "src/utils/metaKey";
6
6
-
import { useEntitySetContext } from "./EntitySetProvider";
6
6
+
import { useEntitySetContext } from "../../../components/EntitySetProvider";
7
7
import { useState } from "react";
8
8
import { ActionButton } from "components/ActionBar/ActionButton";
9
9
-
import { HelpSmall } from "./Icons/HelpSmall";
9
9
+
import { HelpSmall } from "../../../components/Icons/HelpSmall";
10
10
import { isMac } from "src/utils/isDevice";
11
11
import { useIsMobile } from "src/hooks/isMobile";
12
12
13
13
-
export const HelpPopover = (props: { noShortcuts?: boolean }) => {
13
13
+
export const HelpButton = (props: { noShortcuts?: boolean }) => {
14
14
let entity_set = useEntitySetContext();
15
15
let isMobile = useIsMobile();
16
16
+6
-7
components/HomeButton.tsx
app/[leaflet_id]/actions/HomeButton.tsx
···
1
1
"use client";
2
2
import Link from "next/link";
3
3
-
import { useEntitySetContext } from "./EntitySetProvider";
3
3
+
import { useEntitySetContext } from "../../../components/EntitySetProvider";
4
4
import { ActionButton } from "components/ActionBar/ActionButton";
5
5
-
import { useParams, useSearchParams } from "next/navigation";
6
6
-
import { useIdentityData } from "./IdentityProvider";
5
5
+
import { useSearchParams } from "next/navigation";
6
6
+
import { useIdentityData } from "../../../components/IdentityProvider";
7
7
import { useReplicache } from "src/replicache";
8
8
import { addLeafletToHome } from "actions/addLeafletToHome";
9
9
-
import { useSmoker } from "./Toast";
10
10
-
import { AddToHomeSmall } from "./Icons/AddToHomeSmall";
11
11
-
import { HomeSmall } from "./Icons/HomeSmall";
12
12
-
import { permission } from "process";
9
9
+
import { useSmoker } from "../../../components/Toast";
10
10
+
import { AddToHomeSmall } from "../../../components/Icons/AddToHomeSmall";
11
11
+
import { HomeSmall } from "../../../components/Icons/HomeSmall";
13
12
14
13
export function HomeButton() {
15
14
let { permissions } = useEntitySetContext();
+5
-2
components/Pages/PageShareMenu.tsx
···
1
1
import { useLeafletDomains } from "components/PageSWRDataProvider";
2
2
-
import { ShareButton, usePublishLink } from "components/ShareOptions";
2
2
+
import {
3
3
+
ShareButton,
4
4
+
useReadOnlyShareLink,
5
5
+
} from "app/[leaflet_id]/actions/ShareOptions";
3
6
import { useEffect, useState } from "react";
4
7
5
8
export const PageShareMenu = (props: { entityID: string }) => {
6
6
-
let publishLink = usePublishLink();
9
9
+
let publishLink = useReadOnlyShareLink();
7
10
let { data: domains } = useLeafletDomains();
8
11
let [collabLink, setCollabLink] = useState<null | string>(null);
9
12
useEffect(() => {
+2
-2
components/ShareOptions/DomainOptions.tsx
app/[leaflet_id]/actions/ShareOptions/DomainOptions.tsx
···
8
8
import { addDomain } from "actions/domains/addDomain";
9
9
import { callRPC } from "app/api/rpc/client";
10
10
import { useLeafletDomains } from "components/PageSWRDataProvider";
11
11
-
import { usePublishLink } from ".";
11
11
+
import { useReadOnlyShareLink } from ".";
12
12
import { addDomainPath } from "actions/domains/addDomainPath";
13
13
import { useReplicache } from "src/replicache";
14
14
import { deleteDomain } from "actions/domains/deleteDomain";
···
74
74
75
75
let toaster = useToaster();
76
76
let smoker = useSmoker();
77
77
-
let publishLink = usePublishLink();
77
77
+
let publishLink = useReadOnlyShareLink();
78
78
79
79
return (
80
80
<div className="px-3 py-1 flex flex-col gap-3 max-w-full w-[600px]">
components/ShareOptions/getShareLink.ts
app/[leaflet_id]/actions/ShareOptions/getShareLink.ts
+2
-2
components/ShareOptions/index.tsx
app/[leaflet_id]/actions/ShareOptions/index.tsx
···
22
22
23
23
export type ShareMenuStates = "default" | "login" | "domain";
24
24
25
25
-
export let usePublishLink = () => {
25
25
+
export let useReadOnlyShareLink = () => {
26
26
let { permission_token, rootEntity } = useReplicache();
27
27
let entity_set = useEntitySetContext();
28
28
let { data: publishLink } = useSWR(
···
98
98
pub?.publications && pub.documents
99
99
? `${getPublicationURL(pub.publications)}/${new AtUri(pub?.documents.uri).rkey}`
100
100
: null;
101
101
-
let publishLink = usePublishLink();
101
101
+
let publishLink = useReadOnlyShareLink();
102
102
let [collabLink, setCollabLink] = useState<null | string>(null);
103
103
useEffect(() => {
104
104
// strip leading '/' character from pathname