Skip to content

Commit 6c277ac

Browse files
authored
Merge pull request #86 from cytechmobile/refactor/fa31a13-address-walkthrough-comments
refactor(repo): address walkthrough comments
2 parents 3137995 + 74f4b12 commit 6c277ac

28 files changed

+382
-353
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ Requests, Issues, etc, via a peer-to-peer, free and open-source network built on
2020
- Move Cards between Columns
2121
- Create New Issues
2222
- Filter by Issues or Patches
23-
- [Radicle Interface Integration](#radicle-interface-integration)
23+
- [Radicle Explorer Integration](#radicle-explorer-integration)
2424

25-
### Radicle Interface Integration
25+
### Radicle Explorer Integration
2626

27-
Radicle Planning Boards is built with [Radicle Interface](https://app.radicle.xyz/nodes/seed.radicle.garden/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5)
27+
Radicle Planning Boards is built with [Radicle Explorer](https://app.radicle.xyz/nodes/seed.radicle.garden/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5)
2828
integration in mind, a web-based client for the [Radicle](https://radicle.xyz/) peer-to-peer
2929
network. This allows it to leverage features like authentication, themes, and more to provide a
3030
seamless experience for users.
@@ -38,10 +38,10 @@ feature set and not require its own database.
3838

3939
## Self hosting
4040

41-
You will need two domains, one for the Radicle Planning Boards and another for the Radicle Interface.
41+
You will need two domains, one for the Radicle Planning Boards and another for the Radicle Explorer.
4242

4343
1. Deploy the `radicle-planning-boards` repository
44-
- Set the `NUXT_PUBLIC_PARENT_ORIGIN` environment variable to your Radicle Interface domain
44+
- Set the `NUXT_PUBLIC_PARENT_ORIGIN` environment variable to your Radicle Explorer domain
4545
2. Deploy the [radicle-interface-with-planning-boards](https://github.com/maninak/radicle-interface-with-planning-boards)
4646
repository
4747
- Update `src/config.json` with your Radicle Planning Boards domain e.g.

assets/css/tailwind.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@tailwind utilities;
44

55
/*
6-
* Radicle theme colors copied over from `radicle-interface`
6+
* Radicle theme colors copied over from `radicle-explorer`
77
* https://app.radicle.xyz/nodes/seed.radicle.xyz/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5/tree/public/colors.css
88
* then sorted alphabetically
99
*/

components/ColumnCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { taskTruncatedIdLength } from '~/constants/tasks'
2+
import { truncatedHashLength } from '~/constants/config'
33
import type { TaskHighlights } from '~/types/tasks'
44
55
interface Props {
@@ -61,7 +61,7 @@ function truncateSegmentedText(segments: string[], limit: number): string[] {
6161

6262
<pre
6363
class="text-xs font-medium text-rad-foreground-emphasized"
64-
><TextWithHighlights :content="highlights?.id ? truncateSegmentedText(highlights?.id, taskTruncatedIdLength) : id.slice(0, taskTruncatedIdLength)" /></pre>
64+
><TextWithHighlights :content="highlights?.id ? truncateSegmentedText(highlights?.id, truncatedHashLength) : id.slice(0, truncatedHashLength)" /></pre>
6565
</small>
6666

6767
<h4>

components/ColumnIssueCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const status = computed<ColumnCardStatus>(() => ({
2121
icon: statusIconMap[props.issue.state.status],
2222
}))
2323
24-
const radicleInterfaceBaseUrl = useRadicleInterfaceBaseUrl()
24+
const hostAppBaseUrl = useHostAppBaseUrl()
2525
const isDebugging = useIsDebugging()
2626
2727
// TODO: zac reduce duplication between ColumnIssueCard and ColumnPatchCard
@@ -53,7 +53,7 @@ const highlights = computed(() => {
5353
const href = computed(() =>
5454
new URL(
5555
`/nodes/${route.params.node}/${route.params.rid}/issues/${props.issue.id}`,
56-
radicleInterfaceBaseUrl,
56+
hostAppBaseUrl,
5757
).toString(),
5858
)
5959
</script>

components/ColumnPatchCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const status = computed<ColumnCardStatus>(() => ({
2626
icon: statusIconMap[props.patch.state.status],
2727
}))
2828
29-
const radicleInterfaceBaseUrl = useRadicleInterfaceBaseUrl()
29+
const hostAppBaseUrl = useHostAppBaseUrl()
3030
const isDebugging = useIsDebugging()
3131
3232
// TODO: zac reduce duplication between ColumnIssueCard and ColumnPatchCard
@@ -58,7 +58,7 @@ const highlights = computed(() => {
5858
const href = computed(() =>
5959
new URL(
6060
`/nodes/${route.params.node}/${route.params.rid}/patches/${props.patch.id}`,
61-
radicleInterfaceBaseUrl,
61+
hostAppBaseUrl,
6262
).toString(),
6363
)
6464
</script>

components/NewColumn.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script setup lang="ts">
22
const board = useBoardStore()
33
4-
const formRef = ref<HTMLFormElement | null>(null)
5-
const titleInputRef = ref<HTMLInputElement | null>(null)
4+
const formRef = ref<HTMLFormElement>()
5+
const titleInputRef = ref<HTMLInputElement>()
66
const isCreatingNewColumn = ref(false)
77
const title = ref('')
88

components/NewColumnIssueCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const emit = defineEmits<{
44
close: []
55
}>()
66
7-
const formRef = ref<HTMLFormElement | null>(null)
8-
const titleInputRef = ref<HTMLInputElement | null>(null)
7+
const formRef = ref<HTMLFormElement>()
8+
const titleInputRef = ref<HTMLInputElement>()
99
const title = ref('')
1010
1111
onClickOutside(formRef, () => {

composables/use-host-app-base-url.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { useStorage } from '@vueuse/core'
2+
3+
const defaultBaseUrl = 'https://app.radicle.xyz'
4+
5+
export function useHostAppBaseUrl(): string {
6+
const { baseUrl } = useRoute().query
7+
const configuredBaseUrl = useStorage('RPB_config-host-app-base-url', defaultBaseUrl)
8+
9+
try {
10+
if (typeof baseUrl === 'string') {
11+
return new URL(baseUrl).origin
12+
}
13+
14+
return new URL(configuredBaseUrl.value).origin
15+
} catch {
16+
return defaultBaseUrl
17+
}
18+
}

composables/use-host-app-messaging.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import * as v from 'valibot'
2+
3+
type Message<
4+
Type extends string,
5+
Payload extends object | undefined = undefined,
6+
> = Payload extends object ? { type: Type } & Payload : { type: Type }
7+
8+
export type MessageToHostApp =
9+
| Message<'request-auth-token'>
10+
| Message<'request-query-params'>
11+
| Message<'set-query-params', { queryParams: Record<string, string | undefined> }>
12+
13+
const messageFromHostApp = v.union([
14+
v.object({
15+
type: v.literal('theme'),
16+
theme: v.picklist(['light', 'dark']),
17+
}),
18+
v.object({
19+
type: v.literal('set-auth-token'),
20+
authToken: v.string(),
21+
}),
22+
v.object({
23+
type: v.literal('remove-auth-token'),
24+
}),
25+
v.object({
26+
type: v.literal('query-params-updated'),
27+
queryParams: v.record(v.string(), v.string()),
28+
}),
29+
])
30+
31+
export type MessageFromHostApp = v.InferInput<typeof messageFromHostApp>
32+
33+
export function useHostAppMessaging() {
34+
const { parentOrigin } = useRuntimeConfig().public
35+
36+
function onHostAppMessage<MessageType extends MessageFromHostApp['type']>(
37+
type: MessageType,
38+
callback: (message: Extract<MessageFromHostApp, { type: MessageType }>) => void,
39+
): void {
40+
useEventListener('message', (event) => {
41+
if (event.origin !== parentOrigin) {
42+
return
43+
}
44+
45+
const result = v.safeParse(messageFromHostApp, event.data)
46+
if (!result.success || result.output.type !== type) {
47+
return
48+
}
49+
50+
callback(result.output as Extract<MessageFromHostApp, { type: MessageType }>)
51+
})
52+
}
53+
54+
function notifyHostApp(message: MessageToHostApp): void {
55+
globalThis.window.parent.postMessage(message, parentOrigin)
56+
}
57+
58+
return {
59+
onHostAppMessage,
60+
notifyHostApp,
61+
}
62+
}

composables/use-post-message-to-radicle-interface.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)