Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 44 additions & 19 deletions newIDE/app/src/EventsSheet/ParameterFields/AnyVariableField.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import VariableField, {
type VariableDialogOpeningProps,
} from './VariableField';
import GlobalAndSceneVariablesDialog from '../../VariablesList/GlobalAndSceneVariablesDialog';
import LocalVariablesDialog from '../../VariablesList/LocalVariablesDialog';
import {
type ParameterFieldProps,
type ParameterFieldInterface,
Expand Down Expand Up @@ -41,7 +42,6 @@ export default (React.forwardRef<ParameterFieldProps, ParameterFieldInterface>(
onChange,
value,
} = props;
const { layout } = scope;

const enumerateGlobalAndSceneVariables = React.useCallback(
() =>
Expand Down Expand Up @@ -87,12 +87,18 @@ export default (React.forwardRef<ParameterFieldProps, ParameterFieldInterface>(
[onChange, onInstructionTypeChanged, value]
);

const isGlobal = !!(
layout &&
project &&
!layout.getVariables().has(getRootVariableName(props.value)) &&
project.getVariables().has(getRootVariableName(props.value))
const variablesContainer = React.useMemo(
() => {
const variablesContainersList = projectScopedContainersAccessor
.get()
.getVariablesContainersList();
return variablesContainersList.getVariablesContainerFromVariableNameOnly(
props.value
);
},
[projectScopedContainersAccessor, props.value]
);
const variableSourceType = variablesContainer.getSourceType();

return (
<React.Fragment>
Expand Down Expand Up @@ -123,19 +129,38 @@ export default (React.forwardRef<ParameterFieldProps, ParameterFieldInterface>(
onInstructionTypeChanged={onInstructionTypeChanged}
getVariableSourceFromIdentifier={getVariableSourceFromIdentifier}
/>
{editorOpen && (
<GlobalAndSceneVariablesDialog
projectScopedContainersAccessor={projectScopedContainersAccessor}
open
onCancel={() => setEditorOpen(null)}
onApply={onVariableEditorApply}
isGlobalTabInitiallyOpen={isGlobal}
initiallySelectedVariableName={editorOpen.variableName}
shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate}
hotReloadPreviewButtonProps={null}
isListLocked={false}
/>
)}
{editorOpen &&
(variableSourceType === gd.VariablesContainer.Local ? (
project && (
<LocalVariablesDialog
project={project}
projectScopedContainersAccessor={
projectScopedContainersAccessor
}
variablesContainer={variablesContainer}
open
onCancel={() => setEditorOpen(null)}
onApply={onVariableEditorApply}
initiallySelectedVariableName={editorOpen.variableName}
shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate}
isListLocked={false}
/>
)
) : (
<GlobalAndSceneVariablesDialog
projectScopedContainersAccessor={projectScopedContainersAccessor}
open
onCancel={() => setEditorOpen(null)}
onApply={onVariableEditorApply}
isGlobalTabInitiallyOpen={
variableSourceType === gd.VariablesContainer.Global
}
initiallySelectedVariableName={editorOpen.variableName}
shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate}
hotReloadPreviewButtonProps={null}
isListLocked={false}
/>
))}
</React.Fragment>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import VariableField, {
type VariableDialogOpeningProps,
} from './VariableField';
import GlobalAndSceneVariablesDialog from '../../VariablesList/GlobalAndSceneVariablesDialog';
import LocalVariablesDialog from '../../VariablesList/LocalVariablesDialog';
import {
type ParameterFieldProps,
type ParameterFieldInterface,
Expand Down Expand Up @@ -41,7 +42,6 @@ export default (React.forwardRef<ParameterFieldProps, ParameterFieldInterface>(
onChange,
value,
} = props;
const { layout } = scope;

const enumerateGlobalAndSceneVariables = React.useCallback(
() =>
Expand Down Expand Up @@ -85,12 +85,18 @@ export default (React.forwardRef<ParameterFieldProps, ParameterFieldInterface>(
[onChange, onInstructionTypeChanged, value]
);

const isGlobal = !!(
layout &&
project &&
!layout.getVariables().has(getRootVariableName(props.value)) &&
project.getVariables().has(getRootVariableName(props.value))
const variablesContainer = React.useMemo(
() => {
const variablesContainersList = projectScopedContainersAccessor
.get()
.getVariablesContainersList();
return variablesContainersList.getVariablesContainerFromVariableOrPropertyName(
props.value
);
},
[projectScopedContainersAccessor, props.value]
);
const variableSourceType = variablesContainer.getSourceType();

return (
<React.Fragment>
Expand Down Expand Up @@ -121,19 +127,39 @@ export default (React.forwardRef<ParameterFieldProps, ParameterFieldInterface>(
onInstructionTypeChanged={onInstructionTypeChanged}
getVariableSourceFromIdentifier={getVariableSourceFromIdentifier}
/>
{editorOpen && (
<GlobalAndSceneVariablesDialog
projectScopedContainersAccessor={projectScopedContainersAccessor}
open
onCancel={() => setEditorOpen(null)}
onApply={onVariableEditorApply}
isGlobalTabInitiallyOpen={isGlobal}
initiallySelectedVariableName={editorOpen.variableName}
shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate}
hotReloadPreviewButtonProps={null}
isListLocked={false}
/>
)}
{editorOpen &&
(variableSourceType === gd.VariablesContainer.Local ? (
project && (
<LocalVariablesDialog
project={project}
projectScopedContainersAccessor={
projectScopedContainersAccessor
}
variablesContainer={variablesContainer}
open
onCancel={() => setEditorOpen(null)}
onApply={onVariableEditorApply}
initiallySelectedVariableName={editorOpen.variableName}
shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate}
isListLocked={false}
/>
)
) : (
<GlobalAndSceneVariablesDialog
projectScopedContainersAccessor={projectScopedContainersAccessor}
open
onCancel={() => setEditorOpen(null)}
onApply={onVariableEditorApply}
isGlobalTabInitiallyOpen={
variableSourceType === gd.VariablesContainer.Global ||
variableSourceType === gd.VariablesContainer.ExtensionGlobal
}
initiallySelectedVariableName={editorOpen.variableName}
shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate}
hotReloadPreviewButtonProps={null}
isListLocked={false}
/>
))}
</React.Fragment>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import VariableField, {
type VariableDialogOpeningProps,
} from './VariableField';
import GlobalAndSceneVariablesDialog from '../../VariablesList/GlobalAndSceneVariablesDialog';
import LocalVariablesDialog from '../../VariablesList/LocalVariablesDialog';
import {
type ParameterFieldProps,
type ParameterFieldInterface,
Expand Down Expand Up @@ -41,7 +42,6 @@ export default (React.forwardRef<ParameterFieldProps, ParameterFieldInterface>(
onChange,
value,
} = props;
const { layout } = scope;

const enumerateGlobalAndSceneVariables = React.useCallback(
() =>
Expand Down Expand Up @@ -81,12 +81,18 @@ export default (React.forwardRef<ParameterFieldProps, ParameterFieldInterface>(
[onChange, onInstructionTypeChanged, value]
);

const isGlobal = !!(
layout &&
project &&
!layout.getVariables().has(getRootVariableName(props.value)) &&
project.getVariables().has(getRootVariableName(props.value))
const variablesContainer = React.useMemo(
() => {
const variablesContainersList = projectScopedContainersAccessor
.get()
.getVariablesContainersList();
return variablesContainersList.getVariablesContainerFromVariableOrPropertyOrParameterName(
props.value
);
},
[projectScopedContainersAccessor, props.value]
);
const variableSourceType = variablesContainer.getSourceType();

return (
<React.Fragment>
Expand Down Expand Up @@ -117,19 +123,39 @@ export default (React.forwardRef<ParameterFieldProps, ParameterFieldInterface>(
onInstructionTypeChanged={onInstructionTypeChanged}
getVariableSourceFromIdentifier={getVariableSourceFromIdentifier}
/>
{editorOpen && (
<GlobalAndSceneVariablesDialog
projectScopedContainersAccessor={projectScopedContainersAccessor}
open
onCancel={() => setEditorOpen(null)}
onApply={onVariableEditorApply}
isGlobalTabInitiallyOpen={isGlobal}
initiallySelectedVariableName={editorOpen.variableName}
shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate}
hotReloadPreviewButtonProps={null}
isListLocked={false}
/>
)}
{editorOpen &&
(variableSourceType === gd.VariablesContainer.Local ? (
project && (
<LocalVariablesDialog
project={project}
projectScopedContainersAccessor={
projectScopedContainersAccessor
}
variablesContainer={variablesContainer}
open
onCancel={() => setEditorOpen(null)}
onApply={onVariableEditorApply}
initiallySelectedVariableName={editorOpen.variableName}
shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate}
isListLocked={false}
/>
)
) : (
<GlobalAndSceneVariablesDialog
projectScopedContainersAccessor={projectScopedContainersAccessor}
open
onCancel={() => setEditorOpen(null)}
onApply={onVariableEditorApply}
isGlobalTabInitiallyOpen={
variableSourceType === gd.VariablesContainer.Global ||
variableSourceType === gd.VariablesContainer.ExtensionGlobal
}
initiallySelectedVariableName={editorOpen.variableName}
shouldCreateInitiallySelectedVariable={editorOpen.shouldCreate}
hotReloadPreviewButtonProps={null}
isListLocked={false}
/>
))}
</React.Fragment>
);
}
Expand Down
Loading