-
Notifications
You must be signed in to change notification settings - Fork 33
feat: ext 6788 asset sidebar location constants [EXT-6786] #2338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| import { Channel } from './channel' | ||
| import { MemoizedSignal } from './signal' | ||
| import { ConnectMessage, Metadata } from './types' | ||
| import { AssetAPI } from './types/asset.types' | ||
| import { AssetSys } from './types/utils' | ||
|
|
||
| export default function createAsset( | ||
| channel: Channel, | ||
| assetData: ConnectMessage['asset'], | ||
| ): AssetAPI { | ||
| if (!assetData) { | ||
| throw new Error('Asset data is required') | ||
| } | ||
|
|
||
| let sys: AssetSys = assetData.sys | ||
| const sysChanged = new MemoizedSignal<[AssetSys]>(sys) | ||
| let metadata = assetData.metadata | ||
| const metadataChanged = new MemoizedSignal<[Metadata | undefined]>(metadata) | ||
|
|
||
| channel.addHandler('sysChanged', (newSys: AssetSys) => { | ||
| sys = newSys | ||
| sysChanged.dispatch(sys) | ||
| }) | ||
|
|
||
| channel.addHandler('metadataChanged', (newMetadata: Metadata) => { | ||
| metadata = newMetadata | ||
| metadataChanged.dispatch(metadata) | ||
| }) | ||
|
|
||
| return { | ||
| getSys() { | ||
| return sys | ||
| }, | ||
| publish(options?: { skipUiValidation?: boolean }) { | ||
| return channel.call<void>('callAssetMethod', 'publish', [options]) | ||
| }, | ||
| unpublish() { | ||
| return channel.call<void>('callAssetMethod', 'unpublish') | ||
| }, | ||
| save() { | ||
| return channel.call<void>('callAssetMethod', 'save') | ||
| }, | ||
| onSysChanged(handler: (sys: AssetSys) => void) { | ||
| return sysChanged.attach(handler) | ||
| }, | ||
| ...(metadata ? { metadata } : {}), | ||
| getMetadata() { | ||
| return metadata | ||
| }, | ||
| onMetadataChanged(handler: VoidFunction) { | ||
| return metadataChanged.attach(handler) | ||
| }, | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { Metadata } from './entities' | ||
| import { AssetSys } from './utils' | ||
|
|
||
| export interface AssetAPI { | ||
| /** Returns sys for an asset. */ | ||
| getSys: () => AssetSys | ||
| /** Publish the asset */ | ||
| publish: (options?: { skipUiValidation?: boolean }) => Promise<void> | ||
| /** Unpublish the asset */ | ||
| unpublish: () => Promise<void> | ||
| /** Saves the current changes of the asset */ | ||
| save: () => Promise<void> | ||
| /** Calls the callback with sys every time that sys changes. */ | ||
| onSysChanged: (callback: (sys: AssetSys) => void) => () => void | ||
| /** | ||
| * Optional metadata on an asset | ||
| * @deprecated | ||
| */ | ||
| metadata?: Metadata | ||
| getMetadata: () => Metadata | undefined | ||
| onMetadataChanged: (callback: (metadata?: Metadata) => void) => VoidFunction | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -70,6 +70,10 @@ export interface EntrySys extends ContentEntitySys { | |||||||||||||
| automationTags: Link<'Tag'>[] | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| export interface AssetSys extends ContentEntitySys { | ||||||||||||||
| type: 'Asset' | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+73
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AssetSys should not inherit Current inheritance from Apply this diff: -export interface AssetSys extends ContentEntitySys {
- type: 'Asset'
-}
+export type AssetSys = Omit<ContentEntitySys, 'contentType'> & {
+ type: 'Asset'
+}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the identical entry interface uses the same structure so im going to keep this the same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tylerwashington888 Thanks for the clarification! You're absolutely right that maintaining consistency between ✏ Learnings added
|
||||||||||||||
|
|
||||||||||||||
| export type FieldType = | ||||||||||||||
| | 'Symbol' | ||||||||||||||
| | 'Text' | ||||||||||||||
|
|
||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type mismatch:
onMetadataChangedcallback should receive metadata.The signature is
VoidFunctionbut listeners are invoked withmetadata. Align withAssetAPItype.Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the identical entry api method uses the same args so im going to keep this the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 1234
@tylerwashington888 You're absolutely right! I can see that the entry API implementation in
lib/entry.tsline 77 uses the exact same pattern:Both implementations are consistent with each other, even though they differ from their respective type definitions (which correctly specify
(metadata?: Metadata) => void). I understand the rationale for maintaining consistency across the codebase. Thanks for the clarification!✏ Learnings added