Skip to content

Commit e70229e

Browse files
fix(lib): make the translatable property optional (#375)
* make the translatable property optional * adjust the sandbox to consider the translatable property as optional
1 parent a70d612 commit e70229e

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

packages/field-plugin/src/createFieldPlugin/createFieldPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const createFieldPlugin: CreateFieldPlugin = ({
5151
const origin =
5252
host === 'plugin-sandbox.storyblok.com'
5353
? 'https://plugin-sandbox.storyblok.com'
54-
: 'https://plugins.storyblok.com'
54+
: 'https://app.storyblok.com'
5555

5656
const postToContainer = (message: unknown) => {
5757
try {

packages/field-plugin/src/createFieldPlugin/createPluginActions/createPluginMessageListener/createPluginMessageListener.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const createPluginMessageListener: CreatePluginMessageListener = (
3535
handlePluginMessage(event.data, uid, callbacks)
3636
}
3737
}
38+
3839
window.addEventListener('message', handleEvent, false)
3940

4041
return () => {

packages/field-plugin/src/createFieldPlugin/createPluginActions/createPluginMessageListener/handlePluginMessage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const handlePluginMessage = (
1717
return
1818
}
1919

20-
// TODO check origin https://plugins.storyblok.com/ in production mode, * in dev mode
20+
// TODO check origin https://app.storyblok.com/ in production mode, * in dev mode
2121

2222
if (data.uid !== uid) {
2323
// Not intended for this field plugin

packages/field-plugin/src/messaging/pluginMessage/containerToPluginMessage/FieldPluginSchema.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { hasKey } from '../../../utils'
66
export type FieldPluginSchema = {
77
field_type: string
88
options: FieldPluginOption[]
9-
translatable: boolean
9+
translatable?: boolean
1010
}
1111

1212
export type FieldPluginOption = { name: string; value: string }
@@ -23,5 +23,5 @@ export const isFieldPluginSchema = (it: unknown): it is FieldPluginSchema =>
2323
hasKey(it, 'options') &&
2424
Array.isArray(it.options) &&
2525
it.options.every(isFieldPluginOption) &&
26-
hasKey(it, 'translatable') &&
27-
typeof it.translatable === 'boolean'
26+
(!hasKey(it, 'translatable') ||
27+
(hasKey(it, 'translatable') && typeof it.translatable === 'boolean'))

packages/sandbox/src/components/TranslatableCheckbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Checkbox, FormControl, FormLabel } from '@mui/material'
22
import { FunctionComponent } from 'react'
33

44
export const TranslatableCheckbox: FunctionComponent<{
5-
isTranslatable: boolean
5+
isTranslatable: boolean | undefined
66
setTranslatable: (value: boolean) => void
77
}> = (props) => {
88
return (
@@ -13,7 +13,7 @@ export const TranslatableCheckbox: FunctionComponent<{
1313
alignSelf: 'flex-start',
1414
}}
1515
aria-describedby="translatable-checkbox"
16-
value={props.isTranslatable}
16+
value={props.isTranslatable ?? false}
1717
onChange={(e) => props.setTranslatable(e.target.checked)}
1818
/>
1919
</FormControl>

0 commit comments

Comments
 (0)