Skip to content

Commit

Permalink
Cleanup old sites code
Browse files Browse the repository at this point in the history
  • Loading branch information
ericvicenti committed Sep 17, 2023
1 parent 831c3c1 commit 9d0d591
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 1,517 deletions.
126 changes: 0 additions & 126 deletions frontend/apps/site/pages/invite/[inviteToken].tsx

This file was deleted.

44 changes: 37 additions & 7 deletions frontend/packages/app/src/components/changes-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ import {formattedDate, pluralS} from '@mintter/shared'
import {Button, SizableText, XStack} from '@mintter/ui'
import {getAvatarUrl} from '../utils/account-url'
import {AccessoryContainer} from './accessory-sidebar'
import {useAllChanges} from '@mintter/app/models/changes'

function ChangeItem({
change,
docId,
activeVersion,
entityId,
active,
}: {
change: SmartChangeInfo
docId: string
activeVersion?: string
entityId: string
active?: boolean
}) {
const author = useAccount(change.author)
Expand All @@ -32,7 +31,7 @@ function ChangeItem({
onPress={() => {
navigate({
key: 'publication',
documentId: docId,
documentId: entityId,
versionId: change.version,
accessory: {
key: 'versions',
Expand Down Expand Up @@ -113,13 +112,44 @@ export function VersionsAccessory() {
<AccessoryContainer title={`${count} Doc ${pluralS(count, 'Version')}`}>
{data?.changes?.map((change) => (
<ChangeItem
docId={docId}
entityId={docId}
key={change.id}
change={change}
activeVersion={version}
active={change.version === version}
/>
))}
</AccessoryContainer>
)
}

export function EntityVersionsAccessory({
id,
activeVersion,
}: {
id?: string
activeVersion?: string
}) {
const route = useNavRoute()
// const version = route.key === 'publication' ? route.versionId : undefined
// const docId = route.key === 'publication' ? route.documentId : undefined
const {data} = useAllChanges(id)
if (!id) return null
const count = Object.keys(data?.changes || {})?.length || 0
return (
<AccessoryContainer title={`${count} Doc ${pluralS(count, 'Version')}`}>
{Object.entries(data?.changes || {}).map(([changeId, change]) => {
return (
<ChangeItem
entityId={id}
key={changeId}
change={change}
active={
!!activeVersion &&
!!activeVersion.split('.').find((chId) => change.id === chId)
}
/>
)
})}
</AccessoryContainer>
)
}
45 changes: 3 additions & 42 deletions frontend/packages/app/src/components/titlebar/common.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
copyTextToClipboard,
copyToClipboardWithFeedback,
} from '@mintter/app/copy-to-clipboard'
import {copyToClipboardWithFeedback} from '@mintter/app/copy-to-clipboard'
import {useGRPCClient, useIPC} from '@mintter/app/src/app-context'
import {Avatar} from '@mintter/app/src/components/avatar'
import {ContactsPrompt} from '@mintter/app/src/components/contacts-prompt'
Expand All @@ -10,27 +7,19 @@ import {Tooltip} from '@mintter/ui'
import appError from '@mintter/app/src/errors'
import {useMyAccount} from '@mintter/app/src/models/accounts'
import {useDraftList} from '@mintter/app/src/models/documents'
import {useSiteList} from '@mintter/app/src/models/sites'
import {useDaemonReady} from '@mintter/app/src/node-status-context'
import {usePopoverState} from '@mintter/app/src/use-popover-state'
import {
NavRoute,
PublicationRoute,
useNavRoute,
useNavigate,
useNavigationDispatch,
useNavigationState,
} from '@mintter/app/src/utils/navigation'
import {useOpenDraft} from '@mintter/app/src/utils/open-draft'
import {hostnameStripProtocol} from '@mintter/app/src/utils/site-hostname'
import {getAvatarUrl} from '@mintter/app/utils/account-url'
import {NavMode, PublicationRouteContext} from '@mintter/app/utils/navigation'
import {
Account,
SiteConfig,
createPublicWebHmUrl,
unpackHmId,
} from '@mintter/shared'
import {Account, createPublicWebHmUrl, unpackHmId} from '@mintter/shared'
import {
Back,
Button,
Expand Down Expand Up @@ -66,6 +55,7 @@ import {useEditGroupInfoDialog} from '../edit-group-info'
import {AddGroupButton} from '../new-group'
import {usePublishGroupDialog} from '../publish-group'
import {DraftPublicationButtons, PageContextButton} from './publish-share'
import {usePublicationInContext} from '@mintter/app/models/publication'

function getRoutePubContext(
route: NavRoute,
Expand Down Expand Up @@ -285,30 +275,6 @@ export function PageContextButtons(props: TitleBarProps) {
)
}

export function SitesNavDropdownItems({
sites,
onRoute,
}: {
sites?: SiteConfig[]
onRoute: (route: NavRoute) => void
}) {
if (!sites) return null
if (sites.length == 0) return null
return (
<>
{sites.map((site) => (
<YGroup.Item key={site.hostname}>
<MenuItem
onPress={() => onRoute({key: 'site', hostname: site.hostname})}
icon={Globe}
title={hostnameStripProtocol(site.hostname)}
/>
</YGroup.Item>
))}
</>
)
}

export function AccountDropdownItem({
account,
onRoute,
Expand Down Expand Up @@ -342,11 +308,9 @@ export function AccountDropdownItem({

function NavMenuContentUnpure({
onClose,
sites,
onRoute,
}: {
onClose: () => void
sites?: SiteConfig[]
onRoute: (route: NavRoute) => void
}) {
const route = useNavRoute()
Expand Down Expand Up @@ -450,7 +414,6 @@ function NavMenuContentUnpure({
}
/>
</YGroup.Item>
<SitesNavDropdownItems sites={sites} onRoute={onRoute} />
<YGroup.Item>
<MenuItem
onPress={() => {
Expand Down Expand Up @@ -487,7 +450,6 @@ function NavMenuContentUnpure({
const NavMenuContent = memo(NavMenuContentUnpure)

export function NavMenu() {
const sites = useSiteList()
const popoverState = usePopoverState()

const navigate = useNavigate()
Expand All @@ -500,7 +462,6 @@ export function NavMenu() {
</Popover.Trigger>

<NavMenuContent
sites={sites.data}
onRoute={(route) => {
popoverState.onOpenChange(false)
setTimeout(() => {
Expand Down
Loading

0 comments on commit 9d0d591

Please sign in to comment.