diff --git a/README.md b/README.md
index 932b6790..b2065251 100644
--- a/README.md
+++ b/README.md
@@ -98,13 +98,6 @@ export default createConfig({
## Known issues
-
-(V3) Where has the references tab gone?
-
-- This will be enabled in a future version!
-
-
-
There isn't a way to edit asset fields directly from the desk (without opening the plugin)
diff --git a/src/components/DialogAssetEdit/index.tsx b/src/components/DialogAssetEdit/index.tsx
index 40c4c0d7..e3171ec1 100644
--- a/src/components/DialogAssetEdit/index.tsx
+++ b/src/components/DialogAssetEdit/index.tsx
@@ -1,12 +1,12 @@
import {yupResolver} from '@hookform/resolvers/yup'
-import {useClient} from 'sanity'
import type {MutationEvent} from '@sanity/client'
-import {Box, Button, Card, Flex, Stack, TabPanel, Text} from '@sanity/ui'
+import {Box, Button, Card, Flex, Stack, Tab, TabList, TabPanel, Text} from '@sanity/ui'
import {Asset, DialogAssetEditProps, ReactSelectOption} from '@types'
import groq from 'groq'
import React, {ReactNode, useEffect, useRef, useState} from 'react'
import {useForm} from 'react-hook-form'
import {useDispatch} from 'react-redux'
+import {useClient} from 'sanity'
import * as yup from 'yup'
import useTypedSelector from '../../hooks/useTypedSelector'
import {assetsActions, selectAssetById} from '../../modules/assets'
@@ -18,7 +18,7 @@ import sanitizeFormData from '../../utils/sanitizeFormData'
import {isFileAsset, isImageAsset} from '../../utils/typeGuards'
import AssetMetadata from '../AssetMetadata'
import Dialog from '../Dialog'
-// import DocumentList from '../DocumentList'
+import DocumentList from '../DocumentList'
import FileAssetPreview from '../FileAssetPreview'
import FormFieldInputFilename from '../FormFieldInputFilename'
import FormFieldInputTags from '../FormFieldInputTags'
@@ -62,10 +62,7 @@ const DialogAssetEdit = (props: Props) => {
// State
// - Generate a snapshot of the current asset
const [assetSnapshot, setAssetSnapshot] = useState(assetItem?.asset)
- const [
- tabSection
- // setTabSection
- ] = useState<'details' | 'references'>('details')
+ const [tabSection, setTabSection] = useState<'details' | 'references'>('details')
const currentAsset = assetItem ? assetItem?.asset : assetSnapshot
const allTagOptions = getTagSelectOptions(tags)
@@ -273,7 +270,6 @@ const DialogAssetEdit = (props: Props) => {
{/* Tabs */}
- {/*
{
size={2}
/>
- */}
{/* Form fields */}
@@ -369,7 +364,6 @@ const DialogAssetEdit = (props: Props) => {
{/* Panel: References */}
- {/*
{
{assetItem?.asset && }
- */}
diff --git a/src/components/DocumentList/index.tsx b/src/components/DocumentList/index.tsx
index 0267e95b..7194f051 100644
--- a/src/components/DocumentList/index.tsx
+++ b/src/components/DocumentList/index.tsx
@@ -1,107 +1,82 @@
-/*
import type {SanityDocument} from '@sanity/client'
-import {Box, Card, Text} from '@sanity/ui'
-import {IntentLink} from 'part:sanity/router'
-import Preview from 'part:sanity/preview'
-import schema from 'part:sanity/schema'
-import {WithReferringDocuments} from 'part:sanity/with-referring-documents'
+import {Box, Button, Card, Stack, Text} from '@sanity/ui'
import React from 'react'
-import styled from 'styled-components'
+import {useIntentLink, useSchema} from 'sanity'
+import {SanityPreview, useDocumentStore, WithReferringDocuments} from 'sanity/_unstable'
type Props = {
assetId: string
}
-// Brute force styles on all of Sanity's preview components.
-// TODO: Consider using a custom preview component that is able to resolve custom titles
-// (and potentially subtitles) defined at the document schema level. Or anything to ensure
-// that future upstream changes to Sanity's preview components don't break anything here.
-const Container = styled(Box)`
- * {
- color: ${props => props.theme.sanity.color.base.fg};
- }
-
- a {
- text-decoration: none;
- }
-
- h2 {
- font-size: ${props => props.theme.sanity.fonts.text.sizes[1]};
- }
-`
-
const DocumentList = (props: Props) => {
const {assetId} = props
- const renderChild = (renderProps: {isLoading: boolean; referringDocuments: SanityDocument}) => {
- const {isLoading, referringDocuments} = renderProps
+ const documentStore = useDocumentStore()
- const draftIds = referringDocuments.reduce(
- (acc: string[], doc: SanityDocument) =>
- doc._id.startsWith('drafts.') ? acc.concat(doc._id.slice(7)) : acc,
- []
- )
+ return (
+
+ {({isLoading, referringDocuments}) => (
+
+ )}
+
+ )
+}
- const filteredDocuments: SanityDocument[] = referringDocuments.filter(
- (doc: SanityDocument) => !draftIds.includes(doc._id)
- )
+const ReferringDocuments = (props: {isLoading: boolean; referringDocuments: SanityDocument[]}) => {
+ const {isLoading, referringDocuments} = props
- if (isLoading) {
- return Loading...
- }
+ const schema = useSchema()
- if (filteredDocuments.length === 0) {
- return No documents are referencing this asset
- }
+ const draftIds = referringDocuments.reduce(
+ (acc: string[], doc: SanityDocument) =>
+ doc._id.startsWith('drafts.') ? acc.concat(doc._id.slice(7)) : acc,
+ []
+ )
- return filteredDocuments?.map(doc => {
- const schemaType = schema.get(doc._type)
+ const filteredDocuments: SanityDocument[] = referringDocuments.filter(
+ (doc: SanityDocument) => !draftIds.includes(doc._id)
+ )
- return (
-
-
- {schemaType ? (
-
-
-
- ) : (
-
-
- A document of the unknown type {doc._type}
-
-
- )}
-
-
- )
- })
+ if (isLoading) {
+ return Loading...
+ }
+
+ if (filteredDocuments.length === 0) {
+ return No documents are referencing this asset
}
return (
-
- {renderChild}
-
+
+
+ {filteredDocuments?.map(doc => {
+ const schemaType = schema.get(doc._type)
+
+ const {onClick} = useIntentLink({
+ intent: 'edit',
+ params: {id: doc._id}
+ })
+
+ return schemaType ? (
+
+ ) : (
+
+
+ A document of the unknown type {doc._type}
+
+
+ )
+ })}
+
+
)
}
-*/
-
-import React from 'react'
-import {Text} from '@sanity/ui'
-
-type Props = {
- assetId: string
-}
-
-const DocumentList = (props: Props) => {
- const {assetId} = props
- return Document list for Asset with ID {assetId} should go here
-}
export default DocumentList