Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(mobile): show only dashboards and insights as views pins (#129645)

Chris Volzer592745be728e
diff --git a/products/mobile/docs/VIEWS.md b/products/mobile/docs/VIEWS.md
index e0854e93bc9b..236bc404ffd8 100644
--- a/products/mobile/docs/VIEWS.md
+++ b/products/mobile/docs/VIEWS.md
@@ -24,6 +24,11 @@ The app never sends `async_except_on_cache_miss`, which the insight endpoint tur
## Pins
Pins are the web's starred rows (`FileSystemShortcut`, default surface), so a phone pin shows as a star on the web.
+Only a dashboard or an insight with a `ref` becomes a pin (`pinKindOf`), because those are the views the list can draw.
+The starred list also holds product pages, such as Dashboards, Web analytics or Feature flags, because the web's sidebar keeps its product list as stars.
+Those rows, folders, and items the phone has no screen for, such as notebooks and flags, stay on the web and do not show on the phone.
+Browse already opens the product pages the app has, and the phone never deletes a star it does not show.
+Web analytics has no pin button for the same reason.
`shortcutInputFor()` writes the exact `path`, `type`, `ref` and `href` the web writes, so the server dedupes the row.
Rows for one view (a sibling environment, a rename) collapse into one pin, and unpin deletes all of them.
The Views list owns the pin list reads: on first paint unless read under a minute ago, on focus when 5 minutes old, and immediately on pull. Pin buttons and error states on view screens read the cached list, so opening a view sends no pin list request.
@@ -93,7 +98,7 @@ A pin shows in one of three modes, chosen on this phone:
| Mode | Shows | Height | Reads data |
| ------ | --------------------------------------------------------------------------------------------------------------------------------- | -------------------- | ---------- |
-| Row | Icon, name, the view type ("Dashboard", "Built-in view" for web analytics, "Notebook · Opens on the web") | 64 pt | No |
+| Row | Icon, name, the view type ("Dashboard" or "Insight") | 64 pt | No |
| Number | The value, a neutral change pill, the tile name, a 14-bucket sparkline, saved range and freshness | Fits visible content | Yes |
| Chart | A compact `MetricChart`, series legend, saved range and freshness; a value and change pill when one number represents the insight | Fits visible content | Yes |
@@ -104,7 +109,6 @@ Chart pins pass `canvasSlot` and sit inside `ChartCanvasBudget`, so at most six
A tap on a Chart pin's plot pins a tooltip, and a tap on its name or value opens the view.
A tap on the pinned tooltip opens the Point sheet. `ViewsScreen` wraps the list in `ChartSheetsProvider`, and the sheet follows the pin's own cache entry, which reads the saved range.
A Chart pin draws every current series and its previous period with `snapshotChartSeries`, using the same palette and legend as the full insight. Compact bars keep their series color before selection; selecting a single-series bar highlights it in ink. Multi-series and breakdown charts omit the headline number rather than showing a dash or presenting one series as the whole insight. Pins whose tile uses its own dates show the resolved range, or "Uses its own range" until dates are available.
-Web analytics and pins that open on the web show as rows only (`pinModes`).
A dashboard pin in Number or Chart mode shows one tile.
The subtitle shows the tile's title.
diff --git a/products/mobile/src/demo/views.ts b/products/mobile/src/demo/views.ts
index 7e14b4698af2..dfdf7ba0cf15 100644
--- a/products/mobile/src/demo/views.ts
+++ b/products/mobile/src/demo/views.ts
@@ -944,8 +944,6 @@ function shortcut(id: string, path: string, type: string, ref: string | null, hr
const DEFAULT_SHORTCUTS: FileSystemShortcutApi[] = [
shortcut('demo-pin-kpis', 'Product KPIs', 'dashboard', DEMO_DASHBOARD_KPIS, `/dashboard/${DEMO_DASHBOARD_KPIS}`, 0),
shortcut('demo-pin-signups', 'Signups', 'insight', DEMO_INSIGHT_SIGNUPS, `/insights/${DEMO_INSIGHT_SIGNUPS}`, 1),
- shortcut('demo-pin-web', 'Web analytics', 'web_analytics', null, '/web', 2),
- shortcut('demo-pin-notes', 'Launch notes', 'notebook', 'demo-nb-launch', '/notebooks/demo-nb-launch', 3),
]
const DEFAULT_DISPLAY: Record<string, PinDisplay> = {
diff --git a/products/mobile/src/features/views/PinButton.tsx b/products/mobile/src/features/views/PinButton.tsx
index 77b1a8d92a5b..b51b48eaf6eb 100644
--- a/products/mobile/src/features/views/PinButton.tsx
+++ b/products/mobile/src/features/views/PinButton.tsx
@@ -35,7 +35,7 @@ export function PinButton({ target, match }: PinButtonProps): ReactElement {
const actions = usePinActions()
const { pins } = usePins()
const key = shortcutMatchKey(match.kind, match.ref)
- const pinView = pins.data?.find((pin) => shortcutMatchKey(pin.type, pin.ref) === key)
+ const pinView = pins.data?.find((pin) => shortcutMatchKey(pin.kind, pin.ref) === key)
const pinned = Boolean(pinView)
const { toast, show, hide } = useToasts()
// Undo runs after the list changed, so it reads the latest pin, not the one from the render that showed the toast.
diff --git a/products/mobile/src/features/views/items.ts b/products/mobile/src/features/views/items.ts
index 750eeda1c914..ceefbe4d718c 100644
--- a/products/mobile/src/features/views/items.ts
+++ b/products/mobile/src/features/views/items.ts
@@ -67,7 +67,7 @@ export function insightItemKey(scope: ProjectScope | null, target: InsightTarget
/** The insight a Number or Chart pin reads, or null for a Row pin and a dashboard pin without a chosen tile. */
export function pinTarget(pin: PinView): InsightTarget | null {
- if (pin.display.mode === 'row' || !pin.native || !pin.ref) {
+ if (pin.display.mode === 'row') {
return null
}
if (pin.kind === 'insight') {
diff --git a/products/mobile/src/features/views/list/EditPinsList.tsx b/products/mobile/src/features/views/list/EditPinsList.tsx
index 50402b9bdba5..f7701aacc432 100644
--- a/products/mobile/src/features/views/list/EditPinsList.tsx
+++ b/products/mobile/src/features/views/list/EditPinsList.tsx
@@ -19,7 +19,6 @@ import { Pressable44 } from '@/ui/Pressable44'
import { createStyles, useTheme } from '@/ui/theme'
import { layout, motion, radii, type } from '@/ui/tokens'
-import { pinModes } from '../pinHooks'
import { ModeSegment } from './ModeSegment'
import { ViewIcon, viewTypeLabel } from './viewMeta'
@@ -188,8 +187,7 @@ function EditRow({
}))
const liftStyle = useAnimatedStyle(() => ({ opacity: dragging.value ? 1 : 0 }))
- const modes = pinModes(pin)
- const key = `${pin.kind}-${pin.ref ?? pin.kind}`
+ const key = `${pin.kind}-${pin.ref}`
return (
<Animated.View style={[styles.rowSlot, rowStyle]}>
<Animated.View style={[StyleSheet.absoluteFill, styles.lift, shadows.card, liftStyle]} />
@@ -213,12 +211,11 @@ function EditRow({
{pin.name}
</Text>
<Text style={styles.meta} numberOfLines={1}>
- {viewTypeLabel(pin.kind) ?? 'Opens on the web'}
+ {viewTypeLabel(pin.kind)}
</Text>
</View>
<ModeSegment
value={pin.display.mode}
- available={modes}
onChange={(mode) => onMode(pin, mode)}
variant="icons"
name={pin.name}
diff --git a/products/mobile/src/features/views/list/ModeSegment.tsx b/products/mobile/src/features/views/list/ModeSegment.tsx
index 12117c9400a8..b5804d477532 100644
--- a/products/mobile/src/features/views/list/ModeSegment.tsx
+++ b/products/mobile/src/features/views/list/ModeSegment.tsx
@@ -14,8 +14,6 @@ const LABEL: Record<PinDisplayMode, string> = { row: 'Row', number: 'Number', ch
interface ModeSegmentProps {
value: PinDisplayMode
- /** The modes this pin offers. The others show disabled. */
- available: readonly PinDisplayMode[]
onChange: (mode: PinDisplayMode) => void
/** `labels` for the long-press menu, `icons` for the compact toggle in Edit pins. */
variant: 'labels' | 'icons'
@@ -25,7 +23,7 @@ interface ModeSegmentProps {
}
/** Row, Number or Chart for one pin. */
-export function ModeSegment({ value, available, onChange, variant, name, testIDFor }: ModeSegmentProps): ReactElement {
+export function ModeSegment({ value, onChange, variant, name, testIDFor }: ModeSegmentProps): ReactElement {
const { colors, shadows } = useTheme()
const styles = useStyles()
const icons = variant === 'icons'
@@ -37,22 +35,14 @@ export function ModeSegment({ value, available, onChange, variant, name, testIDF
>
{MODES.map((mode) => {
const selected = mode === value
- const disabled = !available.includes(mode)
- const color = selected
- ? colors.ink
- : disabled
- ? colors.disabled
- : icons
- ? colors.tertiary
- : colors.secondary
+ const color = selected ? colors.ink : icons ? colors.tertiary : colors.secondary
return (
<Pressable44
key={mode}
onPress={() => onChange(mode)}
- disabled={disabled}
accessibilityRole="radio"
accessibilityLabel={LABEL[mode]}
- accessibilityState={{ checked: selected, disabled }}
+ accessibilityState={{ checked: selected }}
hitSlop={icons ? { top: 7, bottom: 7 } : 6}
haptic="selection"
style={[
diff --git a/products/mobile/src/features/views/list/PinCard.test.tsx b/products/mobile/src/features/views/list/PinCard.test.tsx
index 28b1fe6141cd..21422faad916 100644
--- a/products/mobile/src/features/views/list/PinCard.test.tsx
+++ b/products/mobile/src/features/views/list/PinCard.test.tsx
@@ -31,9 +31,7 @@ const pin: PinView = {
ref: '42',
name: 'Product overview',
href: '/dashboard/42',
- native: true,
rank: null,
- type: 'dashboard',
serverOrder: 0,
display: { mode: 'number', tileId: 9, insightId: 7, insightShortId: 'signups' },
}
@@ -82,7 +80,7 @@ describe('PinCard', () => {
it.each(['number', 'chart'] as const)('shows dashboard and metric context on the actual %s pin', (mode) => {
const shown = { ...pin, display: { ...pin.display, mode } }
- const screen = render(<PinCard pin={shown} index={0} demo={false} {...callbacks} />)
+ const screen = render(<PinCard pin={shown} index={0} {...callbacks} />)
expect(screen.getAllByText('Product overview')).toHaveLength(1)
expect(screen.getAllByText('Daily signups')).toHaveLength(1)
expect(screen.getByText('Last 7 days')).toBeTruthy()
@@ -94,7 +92,7 @@ describe('PinCard', () => {
it('shows a standalone insight range once in its footer', () => {
const shown = { ...pin, kind: 'insight' as const, ref: 'signups', name: 'Daily signups' }
- const screen = render(<PinCard pin={shown} index={0} demo={false} {...callbacks} />)
+ const screen = render(<PinCard pin={shown} index={0} {...callbacks} />)
expect(screen.getByText('Insight')).toBeTruthy()
expect(screen.getAllByText('Last 7 days')).toHaveLength(1)
})
@@ -166,7 +164,7 @@ describe('PinCard', () => {
expect(multi.capabilities).toMatchObject({ chart: true, number: false })
jest.mocked(usePinData).mockReturnValue({ ...data, snapshot: multi })
const shown = { ...pin, display: { ...pin.display, mode: 'chart' as const } }
- const screen = render(<PinCard pin={shown} index={0} demo={false} {...callbacks} />)
+ const screen = render(<PinCard pin={shown} index={0} {...callbacks} />)
expect(screen.queryByTestId('views-pin-value-dashboard-42')).toBeNull()
const first = shape === 'breakdown' ? 'Signups · direct' : 'Signups'
const second = shape === 'breakdown' ? 'Invites · referral' : 'Invites'
@@ -180,7 +178,7 @@ describe('PinCard', () => {
it('unpins the real shortcut when its metric is no longer accessible', () => {
const shown = { ...pin, kind: 'insight' as const, ref: 'signups' }
jest.mocked(usePinData).mockReturnValue({ ...data, snapshot: undefined, error: 'no_access' })
- const screen = render(<PinCard pin={shown} index={0} demo={false} {...callbacks} />)
+ const screen = render(<PinCard pin={shown} index={0} {...callbacks} />)
fireEvent.press(screen.getByLabelText('Unpin'))
expect(callbacks.onUnpin).toHaveBeenCalledWith(shown)
expect(callbacks.onUnpin.mock.calls[0]?.[0].shortcutId).toBe('real-shortcut')
@@ -190,7 +188,6 @@ describe('PinCard', () => {
const screen = render(
<ModeSegment
value="chart"
- available={['row', 'chart']}
onChange={onChange}
variant="icons"
name="Product overview"
@@ -199,6 +196,5 @@ describe('PinCard', () => {
)
fireEvent.press(screen.getByTestId('mode-chart'))
expect(onChange).toHaveBeenCalledWith('chart')
- expect(screen.getByTestId('mode-number').props.accessibilityState.disabled).toBe(true)
})
})
diff --git a/products/mobile/src/features/views/list/PinCard.tsx b/products/mobile/src/features/views/list/PinCard.tsx
index 1a0759ce7a49..26224e7cdf0f 100644
--- a/products/mobile/src/features/views/list/PinCard.tsx
+++ b/products/mobile/src/features/views/list/PinCard.tsx
@@ -18,7 +18,6 @@ import { Sparkline } from '@/ui/chart/Sparkline'
import type { ChartTooltipPoint } from '@/ui/chart/types'
import { COMPACT_CHART_HEIGHT } from '@/ui/chart/variant'
import { ChevronRightIcon } from '@/ui/icons/ChevronRightIcon'
-import { ExternalLinkIcon } from '@/ui/icons/ExternalLinkIcon'
import { Pressable44 } from '@/ui/Pressable44'
import { createStyles, useColors, useTheme } from '@/ui/theme'
import { radii, type } from '@/ui/tokens'
@@ -51,8 +50,6 @@ export interface PinCardProps {
pin: PinView
/** Position in the whole list, for the canvas budget. */
index: number
- /** Demo mode: pins that open on the web cannot open. */
- demo: boolean
onOpen: (pin: PinView) => void
onMenu: (pin: PinView, anchor: RowAnchor) => void
onChooseTile: (pin: PinView) => void
@@ -67,29 +64,17 @@ export function pinTestId(pin: Pick<PinView, 'kind' | 'ref'>, part?: 'value'): s
/** One pin as its display mode shows it. */
export const PinCard = memo(function PinCard(props: PinCardProps): ReactElement {
- if (props.pin.display.mode === 'row' || !props.pin.native) {
+ if (props.pin.display.mode === 'row') {
return <RowPin {...props} />
}
return <DataPin {...props} />
})
-function rowSecondLine(pin: PinView, demo: boolean): string {
- const label = viewTypeLabel(pin.kind)
- if (pin.native) {
- return label ?? ''
- }
- if (demo) {
- return 'Not available in the demo'
- }
- return label ? `${label} · Opens on the web` : 'Opens on the web'
-}
-
-function RowPin({ pin, demo, onOpen, onMenu }: PinCardProps): ReactElement {
+function RowPin({ pin, onOpen, onMenu }: PinCardProps): ReactElement {
const colors = useColors()
const styles = useStyles()
const menu = useMenuTrigger(pin, onMenu)
- const unavailable = !pin.native && demo
- const second = rowSecondLine(pin, demo)
+ const second = viewTypeLabel(pin.kind)
return (
<View ref={menu.ref} style={[styles.card, { height: PIN_ROW_HEIGHT }]} testID={pinTestId(pin)}>
<Pressable44
@@ -97,33 +82,26 @@ function RowPin({ pin, demo, onOpen, onMenu }: PinCardProps): ReactElement {
onLongPress={menu.onLongPress}
accessibilityActions={menu.accessibilityActions}
onAccessibilityAction={menu.onAccessibilityAction}
- disabled={unavailable}
accessibilityLabel={`${pin.name}, ${second}`}
- accessibilityState={{ disabled: unavailable }}
pressedBackground={colors.sunken}
style={styles.head}
>
- <PinHeadContent pin={pin} second={second} dim={unavailable} />
- {pin.native ? (
- <ChevronRightIcon size={13} color={colors.tertiary} />
- ) : (
- <ExternalLinkIcon size={16} color={unavailable ? colors.disabled : colors.tertiary} />
- )}
+ <PinHeadContent pin={pin} second={second} />
+ <ChevronRightIcon size={13} color={colors.tertiary} />
</Pressable44>
</View>
)
}
-function PinHeadContent({ pin, second, dim = false }: { pin: PinView; second: string; dim?: boolean }): ReactElement {
- const colors = useColors()
+function PinHeadContent({ pin, second }: { pin: PinView; second: string }): ReactElement {
const styles = useStyles()
return (
<>
<View style={styles.iconTile}>
- <ViewIcon kind={pin.kind} color={dim ? colors.disabled : colors.muted} />
+ <ViewIcon kind={pin.kind} />
</View>
<View style={styles.headText}>
- <Text style={[styles.title, dim && styles.dimText]} numberOfLines={1}>
+ <Text style={styles.title} numberOfLines={1}>
{pin.name}
</Text>
<Text style={styles.meta} numberOfLines={1}>
@@ -141,7 +119,7 @@ function PinHeadContent({ pin, second, dim = false }: { pin: PinView; second: st
function useTileRemoved(pin: PinView, data: PinData): boolean {
const context = useViewsContext()
const dashboard = useSnapshot<DashboardSnapshot>(
- pin.kind === 'dashboard' && pin.ref ? dashboardQueryKey(context.scope, pin.ref, null) : null
+ pin.kind === 'dashboard' ? dashboardQueryKey(context.scope, pin.ref, null) : null
)
if (pin.kind !== 'dashboard') {
return false
@@ -168,7 +146,7 @@ function dataSecondLine(pin: PinView, data: PinData): string {
if (pin.kind === 'dashboard') {
return data.snapshot ? data.snapshot.name : 'Dashboard'
}
- return viewTypeLabel(pin.kind) ?? ''
+ return viewTypeLabel(pin.kind)
}
function RemovedTilePin({ pin, onMenu, onChooseTile }: PinCardProps): ReactElement {
@@ -491,9 +469,6 @@ const useStyles = createStyles(({ colors }) => ({
...type.rowTitle,
color: colors.ink,
},
- dimText: {
- color: colors.tertiary,
- },
meta: {
...type.meta,
color: colors.tertiary,
diff --git a/products/mobile/src/features/views/list/ViewsMenu.tsx b/products/mobile/src/features/views/list/ViewsMenu.tsx
index a681d0a51872..647791796b7b 100644
--- a/products/mobile/src/features/views/list/ViewsMenu.tsx
+++ b/products/mobile/src/features/views/list/ViewsMenu.tsx
@@ -141,7 +141,6 @@ interface PinMenuProps {
visible: boolean
anchor: RowAnchor
pin: PinView
- modes: readonly PinDisplayMode[]
/** The pin's place in the list, for Move up and Move down. */
position: { index: number; count: number }
/** The name of the tile a dashboard pin shows, if known. */
@@ -158,7 +157,6 @@ export function PinMenu({
visible,
anchor,
pin,
- modes,
position,
tileName,
onClose,
@@ -180,20 +178,17 @@ export function PinMenu({
accessibilityLabel={`${pin.name} actions`}
testID="pin-menu"
>
- {modes.length > 1 ? (
- <View style={styles.section}>
- <Text style={styles.sectionLabel}>Show as</Text>
- <ModeSegment
- value={pin.display.mode}
- available={modes}
- onChange={onShowAs}
- variant="labels"
- name={pin.name}
- testIDFor={(mode) => `pin-menu-show-${mode}`}
- />
- </View>
- ) : null}
- {pin.kind === 'dashboard' && pin.native ? (
+ <View style={styles.section}>
+ <Text style={styles.sectionLabel}>Show as</Text>
+ <ModeSegment
+ value={pin.display.mode}
+ onChange={onShowAs}
+ variant="labels"
+ name={pin.name}
+ testIDFor={(mode) => `pin-menu-show-${mode}`}
+ />
+ </View>
+ {pin.kind === 'dashboard' ? (
<MenuItem label="Choose tile…" meta={tileName} onPress={onChooseTile} testID="pin-menu-choose-tile" />
) : null}
<MenuItem
diff --git a/products/mobile/src/features/views/list/ViewsScreen.tsx b/products/mobile/src/features/views/list/ViewsScreen.tsx
index bc70edd7f6d9..98f9ce899d13 100644
--- a/products/mobile/src/features/views/list/ViewsScreen.tsx
+++ b/products/mobile/src/features/views/list/ViewsScreen.tsx
@@ -1,6 +1,6 @@
import { useIsFocused, useRouter } from 'expo-router'
import { type ReactElement, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
-import { Linking, Platform, RefreshControl, SectionList, Text, View, type ViewToken } from 'react-native'
+import { Platform, RefreshControl, SectionList, Text, View, type ViewToken } from 'react-native'
import type { RowAnchor } from '@/features/inbox/contextMenuPlacement'
import { useMobileProductFlags } from '@/lib/featureFlags'
import { useNow } from '@/lib/useNow'
@@ -30,13 +30,12 @@ import {
trackEditPinsClosed,
trackEditPinsOpened,
trackPinTileSheetOpened,
- trackViewOpenedInWeb,
trackViewsErrorShown,
} from '../analytics'
import { useViewsSearch } from '../browseHooks'
import { type DashboardSnapshot, dashboardQueryKey, insightItemKey, insightQueryKey, pinTarget } from '../items'
import { usePinHint } from '../pinHint'
-import { pinModes, usePinActions, usePinData, useViewsList } from '../pinHooks'
+import { usePinActions, usePinData, useViewsList } from '../pinHooks'
import { ChartSheetsProvider, useChartSheets } from '../pointSheet/ChartSheetsProvider'
import { INITIAL_VISIBLE_ROWS } from '../useViewRefresh'
import { useViewsAccess, type ViewsAccess } from '../useViewsAccess'
@@ -45,7 +44,6 @@ import { ViewsReauthState } from '../ViewsReauthState'
import { useToasts, ViewsToast } from '../ViewsToast'
import { viewHref } from '../viewRoutes'
import { useSnapshot } from '../viewsCache'
-import { viewWebUrl } from '../webLinks'
import { BROWSE_ENTRIES, type BrowseEntry, BrowseEntryRow, browseEntryLabel, browseEntryPin } from './BrowseEntryRow'
import { ChooseTileSheet, type ChooseTileTarget } from './ChooseTileSheet'
import { EditPinsList } from './EditPinsList'
@@ -155,7 +153,6 @@ function ViewsBody(): ReactElement {
const now = useNow()
const context = useViewsContext()
const contentTop = topOffset(insets, TABS_HEADER_BOTTOM)
- const demo = context.mode === 'demo'
const list = useViewsList()
const { width } = useSceneDimensions()
const grid = width >= 740
@@ -300,18 +297,9 @@ function ViewsBody(): ReactElement {
}
const openPin = useCallback((pin: PinView) => {
- const { router: nav, scope } = latest.current
- if (pin.native) {
- const href = viewHref(pin, { from: 'pinned', mode: pin.display.mode })
- if (href) {
- nav.push(href)
- }
- return
- }
- const url = viewWebUrl(scope, pin.href)
- if (url) {
- trackViewOpenedInWeb({ viewType: pin.kind, reason: 'web_only' })
- Linking.openURL(url).catch(() => undefined)
+ const href = viewHref(pin, { from: 'pinned', mode: pin.display.mode })
+ if (href) {
+ latest.current.router.push(href)
}
}, [])
const openView = useCallback((view: ListView, entry: ViewEntry) => {
@@ -517,7 +505,11 @@ function ViewsBody(): ReactElement {
const pinned: ListItem[] =
pins.length > 0 ? pinItems(pins).flatMap(withHint) : [{ type: 'empty-pins', key: 'empty-pins' }]
if (list.pinsTruncated) {
- pinned.push({ type: 'note', key: 'pins-truncated', text: 'Showing 100 pins.' })
+ pinned.push({
+ type: 'note',
+ key: 'pins-truncated',
+ text: 'Showing pins from your first 100 starred items.',
+ })
}
const result: ListSection[] = [
{ key: 'pinned', title: 'Pinned', first: true, editable: pins.length > 0, data: pinned },
@@ -553,10 +545,8 @@ function ViewsBody(): ReactElement {
const second = section.data[index + 1]
if (
first?.type === 'pin' &&
- first.pin.native &&
first.pin.display.mode !== 'row' &&
second?.type === 'pin' &&
- second.pin.native &&
second.pin.display.mode !== 'row'
) {
data.push({ type: 'pin-pair', key: `pair:${first.key}:${second.key}`, items: [first, second] })
@@ -687,7 +677,6 @@ function ViewsBody(): ReactElement {
<PinCard
pin={pin.pin}
index={pin.index}
- demo={demo}
onOpen={openPin}
onMenu={openPinMenu}
onChooseTile={chooseTileFromCard}
@@ -710,7 +699,6 @@ function ViewsBody(): ReactElement {
<PinCard
pin={item.pin}
index={item.index}
- demo={demo}
onOpen={openPin}
onMenu={openPinMenu}
onChooseTile={chooseTileFromCard}
@@ -760,7 +748,6 @@ function ViewsBody(): ReactElement {
[
setPinRow,
onPinLayout,
- demo,
openPin,
openPinMenu,
closeHint,
@@ -1060,7 +1047,7 @@ interface PinMenuForProps {
function PinMenuFor({ pin, ...props }: PinMenuForProps): ReactElement {
const { scope } = useViewsContext()
const dashboard = useSnapshot<DashboardSnapshot>(
- pin.kind === 'dashboard' && pin.ref ? dashboardQueryKey(scope, pin.ref, null) : null
+ pin.kind === 'dashboard' ? dashboardQueryKey(scope, pin.ref, null) : null
)
// A pin reads its tile's insight, so that read names the tile when the dashboard itself is not cached.
const { snapshot } = usePinData(pin)
@@ -1068,7 +1055,7 @@ function PinMenuFor({ pin, ...props }: PinMenuForProps): ReactElement {
pin.kind !== 'dashboard' || pin.display.mode === 'row'
? null
: (dashboard?.view.tiles.find((tile) => tile.tileId === pin.display.tileId)?.name ?? snapshot?.name ?? null)
- return <PinMenu visible pin={pin} modes={pinModes(pin)} tileName={tileName} {...props} />
+ return <PinMenu visible pin={pin} tileName={tileName} {...props} />
}
const useStyles = createStyles(({ colors }) => ({
diff --git a/products/mobile/src/features/views/list/viewMeta.tsx b/products/mobile/src/features/views/list/viewMeta.tsx
index b5dcfd5255cb..6da9257632ed 100644
--- a/products/mobile/src/features/views/list/viewMeta.tsx
+++ b/products/mobile/src/features/views/list/viewMeta.tsx
@@ -2,27 +2,21 @@ import type { ReactElement } from 'react'
import { calendarDaysBetween, formatMonthDay } from '@/lib/dates'
import type { ViewKind, ViewRef } from '@/model/views'
-import { CanvasIcon } from '@/ui/icons/CanvasIcon'
import { DashboardIcon } from '@/ui/icons/DashboardIcon'
-import { DocumentIcon } from '@/ui/icons/DocumentIcon'
-import { ExternalLinkIcon } from '@/ui/icons/ExternalLinkIcon'
import { GlobeIcon } from '@/ui/icons/GlobeIcon'
import { LineChartIcon } from '@/ui/icons/LineChartIcon'
import { useColors } from '@/ui/theme'
import type { PinTarget } from '../shortcutInput'
-const TYPE_LABEL: Record<ViewKind, string | null> = {
+const TYPE_LABEL: Record<ViewKind, string> = {
dashboard: 'Dashboard',
insight: 'Insight',
// The view's name is already "Web analytics", so its second line says what kind of view it is.
web_analytics: 'Built-in view',
- notebook: 'Notebook',
- canvas: 'Canvas',
- web_link: null,
}
-export function viewTypeLabel(kind: ViewKind): string | null {
+export function viewTypeLabel(kind: ViewKind): string {
return TYPE_LABEL[kind]
}
@@ -42,16 +36,10 @@ export function ViewIcon({ kind, size = 18, color: colorProp }: ViewIconProps):
return <LineChartIcon size={size} color={color} />
case 'web_analytics':
return <GlobeIcon size={size} color={color} />
- case 'notebook':
- return <DocumentIcon size={size} color={color} />
- case 'canvas':
- return <CanvasIcon size={size} color={color} />
- case 'web_link':
- return <ExternalLinkIcon size={size} color={color} />
}
}
-/** What the phone writes to pin a view. Null for kinds only the web can pin. */
+/** What the phone writes to pin a view. Null for a view that is not a dashboard or an insight with a ref. */
export function pinTargetFor(view: Pick<ViewRef, 'kind' | 'ref' | 'name'>): PinTarget | null {
switch (view.kind) {
case 'dashboard': {
@@ -63,8 +51,6 @@ export function pinTargetFor(view: Pick<ViewRef, 'kind' | 'ref' | 'name'>): PinT
}
case 'insight':
return view.ref ? { kind: 'insight', shortId: view.ref, name: view.name } : null
- case 'web_analytics':
- return { kind: 'web_analytics' }
default:
return null
}
diff --git a/products/mobile/src/features/views/pinHint.test.ts b/products/mobile/src/features/views/pinHint.test.ts
index 938141b0fdd4..a2bec5ab4a3d 100644
--- a/products/mobile/src/features/views/pinHint.test.ts
+++ b/products/mobile/src/features/views/pinHint.test.ts
@@ -2,7 +2,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage'
import { act, renderHook, waitFor } from '@testing-library/react-native'
import { track } from '@/lib/analytics'
-import type { PinDisplay, PinView, ViewKind } from '@/model/views'
+import type { PinDisplay, PinKind, PinView } from '@/model/views'
import { pinHintTarget, usePinHint } from './pinHint'
import { usePinHintStore } from './pinHintStore'
@@ -10,7 +10,7 @@ import type { PinDisplayPrefs } from './smartPinDisplay'
jest.mock('@/lib/analytics', () => ({ track: jest.fn() }))
-function pin(id: string, kind: ViewKind, native = true, display: PinDisplay = { mode: 'row' }): PinView {
+function pin(id: string, kind: PinKind, display: PinDisplay = { mode: 'row' }): PinView {
return {
kind,
ref: id,
@@ -18,19 +18,15 @@ function pin(id: string, kind: ViewKind, native = true, display: PinDisplay = {
href: null,
shortcutId: id,
shortcutIds: [id],
- type: kind,
serverOrder: 0,
rank: null,
display,
- native,
}
}
const chart: PinDisplay = { mode: 'chart', tileId: 1, insightId: 1 }
const dashboard = pin('dashboard', 'dashboard')
const insight = pin('insight', 'insight')
-const web = pin('web', 'web_analytics')
-const notebook = pin('notebook', 'notebook', false)
describe('pin hint', () => {
beforeEach(async () => {
@@ -48,13 +44,6 @@ describe('pin hint', () => {
'dashboard',
],
['skips a pin without an automatic display', [dashboard, insight], { insight: chart }, {}, 'insight'],
- [
- 'skips kinds that show as rows only',
- [web, notebook, insight],
- { web: chart, notebook: chart, insight: chart },
- {},
- 'insight',
- ],
[
'returns null once any pin has a chosen display',
[dashboard, insight],
@@ -62,7 +51,7 @@ describe('pin hint', () => {
{ insight: chart },
null,
],
- ['returns null without a confirmed visual', [dashboard, web], {}, {}, null],
+ ['returns null without a confirmed visual', [dashboard, insight], {}, {}, null],
])('%s', (_name, pins, automatic, explicit, expected) => {
expect(pinHintTarget(pins, automatic, explicit)?.shortcutId ?? null).toBe(expected)
})
diff --git a/products/mobile/src/features/views/pinHint.ts b/products/mobile/src/features/views/pinHint.ts
index 547f14bb684a..9729d8e0631a 100644
--- a/products/mobile/src/features/views/pinHint.ts
+++ b/products/mobile/src/features/views/pinHint.ts
@@ -4,13 +4,12 @@ import type { PinView } from '@/model/views'
import { type PinHintDismissReason, trackPinHintDismissed, trackPinHintShown } from './analytics'
import { usePinHintHydrated, usePinHintStore } from './pinHintStore'
-import { pinModes } from './pinHooks'
import type { PinDisplayPrefs } from './smartPinDisplay'
/**
- * The pin the long-press hint points at: the first pin that offers Number and Chart and already shows an automatic
- * visual, so "Show as" has something real to change. Null once any pin has a display chosen on this phone, because
- * that person has found the menu.
+ * The pin the long-press hint points at: the first pin that already shows an automatic visual, so "Show as" has
+ * something real to change. Null once any pin has a display chosen on this phone, because that person has found the
+ * menu.
*/
export function pinHintTarget(
pins: readonly PinView[],
@@ -20,7 +19,7 @@ export function pinHintTarget(
if (pins.some((pin) => explicit[pin.shortcutId] !== undefined)) {
return null
}
- return pins.find((pin) => pinModes(pin).length > 1 && automatic[pin.shortcutId] !== undefined) ?? null
+ return pins.find((pin) => automatic[pin.shortcutId] !== undefined) ?? null
}
export interface PinHintInput {
diff --git a/products/mobile/src/features/views/pinHooks.ts b/products/mobile/src/features/views/pinHooks.ts
index e09831ba56e1..696a44eb740f 100644
--- a/products/mobile/src/features/views/pinHooks.ts
+++ b/products/mobile/src/features/views/pinHooks.ts
@@ -69,15 +69,10 @@ function projectKey(scope: ProjectScope): string {
return `${scope.host}|${scope.projectId}`
}
-/** The display modes a pin offers. Web analytics and pins that open on the web show as rows only. */
-export function pinModes(pin: Pick<PinView, 'kind' | 'native'>): PinDisplayMode[] {
- return pin.native && (pin.kind === 'insight' || pin.kind === 'dashboard') ? ['row', 'number', 'chart'] : ['row']
-}
-
export interface PinsState {
pins: QueryState<PinView[]>
displayPrefs: PinDisplayPrefs
- /** The server holds more pins than one page: show "Showing 100 pins". */
+ /** The server holds more starred items than one page, so pins after the first page are missing. */
truncated: boolean
/** For the refresh rules: the last read of the pin list, and a re-read. */
list: RefreshList
@@ -156,7 +151,7 @@ export function usePins({ refetchOnMount = false }: { refetchOnMount?: boolean }
export function usePinnedKeys(): ReadonlySet<string> {
const { pins } = usePins()
const data = pins.data
- return useMemo(() => new Set((data ?? []).map((pin) => shortcutMatchKey(pin.type, pin.ref))), [data])
+ return useMemo(() => new Set((data ?? []).map((pin) => shortcutMatchKey(pin.kind, pin.ref))), [data])
}
export interface PinActions {
@@ -293,7 +288,7 @@ export function pinView(list: PinWriteTarget, target: PinTarget, from: PinSource
/** Deletes every row that matches the view, in every environment. Rejects with user-facing copy for a toast. */
export function unpinView(list: PinWriteTarget, view: PinView | PinTarget, from: PinSource): Promise<void> {
- const key = 'shortcutId' in view ? shortcutMatchKey(view.type, view.ref) : pinTargetKey(view)
+ const key = 'shortcutId' in view ? shortcutMatchKey(view.kind, view.ref) : pinTargetKey(view)
return queuePinWrite(list, key, async () => {
const viewType = view.kind
const { client, listKey } = list
diff --git a/products/mobile/src/features/views/screen/ViewErrorState.tsx b/products/mobile/src/features/views/screen/ViewErrorState.tsx
index d987c0734975..78c737201e34 100644
--- a/products/mobile/src/features/views/screen/ViewErrorState.tsx
+++ b/products/mobile/src/features/views/screen/ViewErrorState.tsx
@@ -61,7 +61,7 @@ export function ViewErrorState({ kind, noun, match, onRetry, onBack }: ViewError
const actions = usePinActions()
const [unpinError, setUnpinError] = useState<string | null>(null)
const key = shortcutMatchKey(match.kind, match.ref)
- const pinView = pins.data?.find((pin) => shortcutMatchKey(pin.type, pin.ref) === key)
+ const pinView = pins.data?.find((pin) => shortcutMatchKey(pin.kind, pin.ref) === key)
const gone = kind === 'deleted' || kind === 'no_access'
const copy = copyFor(kind, noun, Boolean(pinView))
const screen = match.kind
diff --git a/products/mobile/src/features/views/shortcutInput.test.ts b/products/mobile/src/features/views/shortcutInput.test.ts
index 84d4af8adaff..18713511d234 100644
--- a/products/mobile/src/features/views/shortcutInput.test.ts
+++ b/products/mobile/src/features/views/shortcutInput.test.ts
@@ -25,19 +25,12 @@ describe('shortcutInputFor', () => {
{ kind: 'insight', shortId: 'xY12', name: 'Revenue', queryKind: 'BIVisualizationNode' },
{ path: 'Revenue', type: 'insight', ref: 'xY12', href: '/bi/xY12' },
],
- [
- 'web analytics',
- { kind: 'web_analytics' },
- { path: 'Web analytics', type: 'web_analytics', ref: null, href: '/web' },
- ],
])('writes the web row for %s', (_name, target, expected) => {
const input = shortcutInputFor(target)
expect(input).toEqual(expected)
- if (target.kind !== 'web_analytics') {
- expect(shortcutName(input.path)).toBe(
- target.name || ('derivedName' in target && target.derivedName) || 'Untitled'
- )
- }
+ expect(shortcutName(input.path)).toBe(
+ target.name || ('derivedName' in target && target.derivedName) || 'Untitled'
+ )
})
})
diff --git a/products/mobile/src/features/views/shortcutInput.ts b/products/mobile/src/features/views/shortcutInput.ts
index 3aed139200cd..239097828cbf 100644
--- a/products/mobile/src/features/views/shortcutInput.ts
+++ b/products/mobile/src/features/views/shortcutInput.ts
@@ -22,7 +22,6 @@ export type PinTarget =
/** The insight's `query.kind`. A `BIVisualizationNode` lives under `/bi/`. */
queryKind?: string | null
}
- | { kind: 'web_analytics' }
export function shortcutInputFor(target: PinTarget): ShortcutInput {
switch (target.kind) {
@@ -43,8 +42,6 @@ export function shortcutInputFor(target: PinTarget): ShortcutInput {
? `/bi/${target.shortId}`
: `/insights/${target.shortId}`,
}
- case 'web_analytics':
- return { path: 'Web analytics', type: 'web_analytics', ref: null, href: '/web' }
}
}
diff --git a/products/mobile/src/features/views/smartPinDisplay.test.ts b/products/mobile/src/features/views/smartPinDisplay.test.ts
index d955cfbb7da4..8d55aea3f769 100644
--- a/products/mobile/src/features/views/smartPinDisplay.test.ts
+++ b/products/mobile/src/features/views/smartPinDisplay.test.ts
@@ -19,11 +19,9 @@ function pin(id: number): PinView {
href: null,
shortcutId: `pin-${id}`,
shortcutIds: [`pin-${id}`],
- type: 'dashboard',
serverOrder: id,
rank: null,
display: { mode: 'row' },
- native: true,
}
}
diff --git a/products/mobile/src/features/views/smartPinDisplay.ts b/products/mobile/src/features/views/smartPinDisplay.ts
index 0c023ff2ff27..2fa9ad6d8049 100644
--- a/products/mobile/src/features/views/smartPinDisplay.ts
+++ b/products/mobile/src/features/views/smartPinDisplay.ts
@@ -13,14 +13,7 @@ export interface PinDisplayCandidate {
}
export function automaticPinCandidates(pins: readonly PinView[], prefs: PinDisplayPrefs): PinView[] {
- return pins
- .filter(
- (pin) =>
- pin.native &&
- (pin.kind === 'insight' || pin.kind === 'dashboard') &&
- prefs[pin.shortcutId] === undefined
- )
- .slice(0, AUTOMATIC_PIN_LIMIT)
+ return pins.filter((pin) => prefs[pin.shortcutId] === undefined).slice(0, AUTOMATIC_PIN_LIMIT)
}
export function automaticPinMode(query: unknown): 'number' | 'chart' | null {
@@ -60,6 +53,6 @@ export function resolvePinDisplays(
): PinView[] {
return pins.map((pin) => {
const display = prefs[pin.shortcutId] ?? automatic[pin.shortcutId]
- return display && pin.native ? { ...pin, display } : pin
+ return display ? { ...pin, display } : pin
})
}
diff --git a/products/mobile/src/features/views/useSmartPinDisplays.test.tsx b/products/mobile/src/features/views/useSmartPinDisplays.test.tsx
index 4c49418295b2..d678f29c0188 100644
--- a/products/mobile/src/features/views/useSmartPinDisplays.test.tsx
+++ b/products/mobile/src/features/views/useSmartPinDisplays.test.tsx
@@ -345,7 +345,7 @@ describe('automatic displays for actual Views pins', () => {
test('canceling optional metadata during a family pause sends no request', async () => {
viewsQueue.notePause('insights', new ApiError(429, {}, new Headers({ 'Retry-After': '60' })))
const controller = new AbortController()
- const pin = { kind: 'insight', ref: 'ins-1', shortcutId: 'pin-1', native: true } as PinView
+ const pin = { kind: 'insight', ref: 'ins-1', shortcutId: 'pin-1' } as PinView
const run = discoverPinDisplays(
{ client, scope: mockScope, demo: false },
[pin],
diff --git a/products/mobile/src/features/views/viewsDemo.test.tsx b/products/mobile/src/features/views/viewsDemo.test.tsx
index 576de2fbae4d..b6dd67a48301 100644
--- a/products/mobile/src/features/views/viewsDemo.test.tsx
+++ b/products/mobile/src/features/views/viewsDemo.test.tsx
@@ -57,8 +57,6 @@ describe('views in demo mode', () => {
expect(result.current.pins.data?.map((pin) => [pin.kind, pin.ref, pin.display.mode])).toEqual([
['dashboard', 'demo-dash-kpis', 'number'],
['insight', 'demo-ins-signups', 'chart'],
- ['web_analytics', null, 'row'],
- ['notebook', 'demo-nb-launch', 'row'],
])
expect(result.current.refresh.status.text).toBe('Updating…')
diff --git a/products/mobile/src/features/views/webAnalytics/WebAnalyticsScreen.tsx b/products/mobile/src/features/views/webAnalytics/WebAnalyticsScreen.tsx
index 78bcb903a6dd..ec3a3d32b541 100644
--- a/products/mobile/src/features/views/webAnalytics/WebAnalyticsScreen.tsx
+++ b/products/mobile/src/features/views/webAnalytics/WebAnalyticsScreen.tsx
@@ -10,7 +10,6 @@ import { bottomOffset, topOffset, useScreenInsets } from '@/ui/useScreenInsets'
import { type ScrollTitleState, useScrollTitle } from '@/ui/useScrollTitle'
import { DeltaPill } from '../DeltaPill'
-import { PinButton } from '../PinButton'
import { ViewRangeControl } from '../range/ViewRangeControl'
import { RefreshFailedBanner } from '../screen/RefreshFailedBanner'
import { ViewChrome } from '../screen/ViewChrome'
@@ -80,7 +79,6 @@ function WebAnalyticsBody({
<ViewTitle
onTitleLayout={scrollTitle.onTitleLayout}
title="Web analytics"
- accessories={<PinButton target={{ kind: 'web_analytics' }} match={{ kind: 'web_analytics', ref: null }} />}
refresh={refresh}
range={
// No compare row: the overview always compares with the previous period, as the web's overview tile does.
diff --git a/products/mobile/src/model/adapters/viewPins.test.ts b/products/mobile/src/model/adapters/viewPins.test.ts
index d9d5b9fd7abf..896abf66e39c 100644
--- a/products/mobile/src/model/adapters/viewPins.test.ts
+++ b/products/mobile/src/model/adapters/viewPins.test.ts
@@ -21,14 +21,33 @@ describe('view pins', () => {
const rows = [
row('a', 'dashboard', '1', 0),
row('b', 'insight', 'abc', 1),
- row('c', 'web_analytics', null, 2),
- row('d', 'notebook', 'nb1', 3),
+ row('c', 'dashboard', '2', 2),
+ row('d', 'insight', 'def', 3),
]
const pins = pinsFromShortcuts(rows, { rank: { c: 0, a: 1 }, display: {} })
expect(pins.map((pin) => pin.shortcutId)).toEqual(['c', 'a', 'b', 'd'])
- expect(pins.map((pin) => pin.native)).toEqual([true, true, true, false])
+ })
+
+ test('keeps only dashboards and insights with a ref, the views the list can draw', () => {
+ const rows = [
+ row('folder', 'folder', 'Users/Ada', -1),
+ row('dashboards-page', 'dashboard', null, 0, { href: '/dashboard' }),
+ row('web-analytics-page', 'web_analytics', null, 1, { href: '/web' }),
+ row('flags-page', 'feature_flag', null, 2),
+ row('dashboard', 'dashboard', '12', 3),
+ row('notebook', 'notebook', 'nb1', 4),
+ row('flag', 'feature_flag', '7', 5),
+ row('insight', 'insight', 'abc', 6),
+ ]
+
+ const pins = pinsFromShortcuts(rows, { rank: {}, display: {} })
+
+ expect(pins.map((pin) => [pin.shortcutId, pin.kind, pin.ref])).toEqual([
+ ['dashboard', 'dashboard', '12'],
+ ['insight', 'insight', 'abc'],
+ ])
})
test('collapses rows for one view and keeps the ranked row, else the lowest order', () => {
@@ -37,9 +56,6 @@ describe('view pins', () => {
row('sibling', 'dashboard', '7', 0, { created_at: '2026-10-01T10:00:00Z' }),
row('ranked', 'insight', 'xyz', 5),
row('renamed', 'insight', 'xyz', 2),
- row('product', 'web_analytics', null, 3),
- row('product-again', 'web_analytics', null, 4, { href: '/web' }),
- row('folder', 'folder', null, 6),
]
const pins = pinsFromShortcuts(rows, { rank: { ranked: 0 }, display: {} })
@@ -47,7 +63,6 @@ describe('view pins', () => {
expect(pins.map((pin) => [pin.shortcutId, pin.shortcutIds])).toEqual([
['ranked', ['ranked', 'renamed']],
['sibling', ['old', 'sibling']],
- ['product', ['product', 'product-again']],
])
})
diff --git a/products/mobile/src/model/adapters/viewPins.ts b/products/mobile/src/model/adapters/viewPins.ts
index 6cef94869509..18bbb0fd3368 100644
--- a/products/mobile/src/model/adapters/viewPins.ts
+++ b/products/mobile/src/model/adapters/viewPins.ts
@@ -2,7 +2,7 @@ import type { DashboardBasicApi } from '@/api/dashboards'
import type { InsightBasicApi } from '@/api/insights'
import type { FileSystemShortcutApi } from '@/api/shortcuts'
-import type { BrowseRow, DeviceRecentEntry, PinDisplay, PinView, RecentView, ViewKind } from '../views'
+import type { BrowseRow, DeviceRecentEntry, PinDisplay, PinKind, PinView, RecentView, ViewKind } from '../views'
// Shortcut paths are escaped like the web's `escapePath` (`frontend/src/layout/panel-layout/ProjectTree/utils.tsx`):
// `\` becomes `\\` and `/` becomes `\/`, so a name with a slash stays one segment.
@@ -31,29 +31,19 @@ export function shortcutName(path: string): string {
return segments.filter((segment) => segment.length > 0).pop() ?? ''
}
-const NATIVE_KINDS: ReadonlySet<ViewKind> = new Set<ViewKind>(['dashboard', 'insight', 'web_analytics'])
-
-export function viewKindForType(type: string | null): ViewKind {
- switch (type) {
- case 'dashboard':
- case 'insight':
- case 'web_analytics':
- case 'notebook':
- case 'canvas':
- return type
- default:
- return 'web_link'
+/**
+ * The web's Starred list also holds product pages, because the web sidebar keeps its product list as stars. A product
+ * page has no `ref`, and the Dashboards page has the type `dashboard`. Only a dashboard or an insight with a `ref` is a
+ * view the list can draw, so every other star stays on the web.
+ */
+export function pinKindOf(row: Pick<FileSystemShortcutApi, 'type' | 'ref'>): PinKind | null {
+ if (!row.ref) {
+ return null
}
+ return row.type === 'dashboard' || row.type === 'insight' ? row.type : null
}
-export function isNativeKind(kind: ViewKind): boolean {
- return NATIVE_KINDS.has(kind)
-}
-
-/**
- * The identity of a pinned view. Dashboards, insights and notebooks match by `type` and `ref`. A product page such as
- * web analytics has no `ref`, and the backend writes its stars without `href`, so it matches by `type` alone.
- */
+/** The identity of a view. A view matches by `type` and `ref`. Web analytics has no `ref`, so it matches by `type`. */
export function shortcutMatchKey(type: string | null, ref: string | null): string {
return ref ? `${type ?? ''}:${ref}` : `${type ?? ''}:`
}
@@ -79,22 +69,31 @@ function keeps(a: FileSystemShortcutApi, b: FileSystemShortcutApi, rank: Record<
return Date.parse(a.created_at) <= Date.parse(b.created_at)
}
+interface PinGroup {
+ kind: PinKind
+ ref: string
+ kept: FileSystemShortcutApi
+ ids: string[]
+ serverOrder: number
+}
+
/**
- * Pins from the server's shortcut rows, in this phone's order. Rows that match one view (a star in a sibling
- * environment, or one left over after a rename) collapse into one pin: the row with a local rank, else the lowest
- * `order`, then the oldest. Folder shortcuts are not views and are left out.
+ * Pins from the server's shortcut rows, in this phone's order. Rows that `pinKindOf` rejects are left out. Rows that
+ * match one view (a star in a sibling environment, or one left over after a rename) collapse into one pin: the row
+ * with a local rank, else the lowest `order`, then the oldest.
*/
export function pinsFromShortcuts(rows: readonly FileSystemShortcutApi[], prefs: PinPrefs): PinView[] {
// Rows arrive in server order, so a group's first row holds its position.
- const groups = new Map<string, { kept: FileSystemShortcutApi; ids: string[]; serverOrder: number }>()
+ const groups = new Map<string, PinGroup>()
rows.forEach((row, serverOrder) => {
- if (row.type === 'folder') {
+ const kind = pinKindOf(row)
+ if (!kind || !row.ref) {
return
}
- const key = shortcutMatchKey(row.type, row.ref)
+ const key = shortcutMatchKey(kind, row.ref)
const group = groups.get(key)
if (!group) {
- groups.set(key, { kept: row, ids: [row.id], serverOrder })
+ groups.set(key, { kind, ref: row.ref, kept: row, ids: [row.id], serverOrder })
return
}
group.ids.push(row.id)
@@ -102,22 +101,19 @@ export function pinsFromShortcuts(rows: readonly FileSystemShortcutApi[], prefs:
group.kept = row
}
})
- const pins = [...groups.values()].map(({ kept, ids, serverOrder }): PinView => {
- const kind = viewKindForType(kept.type)
- return {
+ const pins = [...groups.values()].map(
+ ({ kind, ref, kept, ids, serverOrder }): PinView => ({
kind,
- ref: kept.ref,
+ ref,
href: kept.href,
name: shortcutName(kept.path) || 'Untitled',
shortcutId: kept.id,
shortcutIds: ids,
- type: kept.type ?? '',
serverOrder,
rank: prefs.rank[kept.id] ?? null,
- display: isNativeKind(kind) ? (prefs.display[kept.id] ?? ROW) : ROW,
- native: isNativeKind(kind),
- }
- })
+ display: prefs.display[kept.id] ?? ROW,
+ })
+ )
return orderPins(pins)
}
diff --git a/products/mobile/src/model/views.ts b/products/mobile/src/model/views.ts
index 77f9a3cfcc27..ac3917e83e67 100644
--- a/products/mobile/src/model/views.ts
+++ b/products/mobile/src/model/views.ts
@@ -2,8 +2,10 @@
import type { MetricChartKind, MetricFormat, MetricInterval, MetricPoint, MetricSeries } from './types'
-/** `web_link` covers every other shortcut type (hog functions, product pages): it opens on the web. */
-export type ViewKind = 'dashboard' | 'insight' | 'web_analytics' | 'notebook' | 'canvas' | 'web_link'
+export type ViewKind = 'dashboard' | 'insight' | 'web_analytics'
+
+/** The views a pin can hold: the ones the Views list can draw as a Number or a Chart. */
+export type PinKind = Extract<ViewKind, 'dashboard' | 'insight'>
export type PinDisplayMode = 'row' | 'number' | 'chart'
@@ -12,7 +14,7 @@ export type ViewEntry = 'pinned' | 'recent' | 'browse' | 'search' | 'deep_link'
export interface ViewRef {
kind: ViewKind
- /** Dashboard id as a string, insight or notebook `short_id`; null for web analytics and product pages. */
+ /** Dashboard id as a string or insight `short_id`; null for web analytics. */
ref: string | null
/** The web path without the project prefix, such as `/dashboard/12`. */
href: string | null
@@ -29,19 +31,17 @@ export interface PinDisplay {
}
export interface PinView extends ViewRef {
+ kind: PinKind
+ ref: string
/** The row the list keeps for this view. Local rank and display are keyed by it. */
shortcutId: string
/** Every row that matches this view, across environments. Unpin deletes all of them. */
shortcutIds: string[]
- /** The shortcut's raw `type`, for the icon of a pin that opens on the web. */
- type: string
/** Position in the server's order (`order`, then path). */
serverOrder: number
/** Device-local order; null sorts after ranked pins, in server order. */
rank: number | null
display: PinDisplay
- /** False: the app has no screen for it, so it opens on the web. */
- native: boolean
}
export interface RecentView extends ViewRef {
@@ -58,7 +58,7 @@ export interface BrowseRow extends ViewRef {
/** A view opened on this phone, kept on the device for Recent. */
export interface DeviceRecentEntry {
- kind: 'dashboard' | 'insight' | 'web_analytics'
+ kind: ViewKind
ref: string | null
name: string
viewedAt: string
diff --git a/products/mobile/src/ui/icons/CanvasIcon.tsx b/products/mobile/src/ui/icons/CanvasIcon.tsx
deleted file mode 100644
index a0ffaa81f874..000000000000
--- a/products/mobile/src/ui/icons/CanvasIcon.tsx
+++ /dev/null
@@ -1,15 +0,0 @@
-import type { ReactElement } from 'react'
-import { Path, Rect } from 'react-native-svg'
-
-import { StrokeIcon } from './StrokeIcon'
-import type { IconProps } from './types'
-
-export function CanvasIcon({ size = 18, color, strokeWidth = 1.8 }: IconProps): ReactElement {
- return (
- <StrokeIcon size={size} color={color} strokeWidth={strokeWidth}>
- <Rect x={3.5} y={4} width={17} height={12} rx={2} />
- <Path d="M12 16v4M8.5 20h7" />
- <Path d="M7.5 12.5l3-3 2.5 2 3.5-4" />
- </StrokeIcon>
- )
-}