Skip to content

Commit 5e7a8e0

Browse files
committed
Forbid to edit variants from the store.
1 parent fbd99b8 commit 5e7a8e0

File tree

1 file changed

+20
-1
lines changed
  • newIDE/app/src/ObjectEditor/Editors/CustomObjectPropertiesEditor

1 file changed

+20
-1
lines changed

newIDE/app/src/ObjectEditor/Editors/CustomObjectPropertiesEditor/index.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,26 @@ const styles = {
6666
const getVariantName = (
6767
eventBasedObject: gdEventsBasedObject | null,
6868
customObjectConfiguration: gdCustomObjectConfiguration
69-
) =>
69+
): string =>
7070
eventBasedObject &&
7171
eventBasedObject
7272
.getVariants()
7373
.hasVariantNamed(customObjectConfiguration.getVariantName())
7474
? customObjectConfiguration.getVariantName()
7575
: '';
7676

77+
const getVariant = (
78+
eventBasedObject: gdEventsBasedObject,
79+
customObjectConfiguration: gdCustomObjectConfiguration
80+
): gdEventsBasedObjectVariant => {
81+
const variantName = getVariantName(eventBasedObject, customObjectConfiguration);
82+
const variants = eventBasedObject.getVariants();
83+
return variantName
84+
? variants.getVariant(variantName)
85+
: eventBasedObject.getDefaultVariant();
86+
}
87+
88+
7789
type Props = EditorProps;
7890

7991
const CustomObjectPropertiesEditor = (props: Props) => {
@@ -229,6 +241,7 @@ const CustomObjectPropertiesEditor = (props: Props) => {
229241
project
230242
);
231243
newVariant.setName(uniqueNewName);
244+
newVariant.setAssetStoreId('');
232245
customObjectConfiguration.setVariantName(uniqueNewName);
233246
setNewVariantDialogOpen(false);
234247
forceUpdate();
@@ -330,6 +343,12 @@ const CustomObjectPropertiesEditor = (props: Props) => {
330343
<FlatButton
331344
label={<Trans>Edit</Trans>}
332345
onClick={editVariant}
346+
disabled={
347+
!eventBasedObject || getVariant(
348+
eventBasedObject,
349+
customObjectConfiguration
350+
).getAssetStoreId() !== ''
351+
}
333352
/>
334353
<FlatButton
335354
label={<Trans>Duplicate</Trans>}

0 commit comments

Comments
 (0)