Skip to content
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

Record control tweaks #10509

Merged
merged 8 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
22 changes: 0 additions & 22 deletions app/gui2/src/components/GraphEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -422,27 +422,6 @@ const { documentation } = useAstDocumentation(graphStore, () =>
unwrapOr(graphStore.methodAst, undefined),
)

// === Execution Mode ===

/** Handle record-once button presses. */
function onRecordOnceButtonPress() {
projectStore.lsRpcConnection.initialized.then(async () => {
const modeValue = projectStore.executionMode
if (modeValue == undefined) {
return
}
projectStore.executionContext.recompute('all', 'Live')
})
}

// Watch for changes in the execution mode.
watch(
() => projectStore.executionMode,
(modeValue) => {
projectStore.executionContext.executionEnvironment = modeValue === 'live' ? 'Live' : 'Design'
},
)

// === Component Browser ===

const componentBrowserVisible = ref(false)
Expand Down Expand Up @@ -720,7 +699,6 @@ const groupColors = computed(() => {
:zoomLevel="100.0 * graphNavigator.targetScale"
:componentsSelected="nodeSelection.selected.size"
:class="{ extraRightSpace: !showDocumentationEditor }"
@recordOnce="onRecordOnceButtonPress()"
@fitToAllClicked="zoomToSelected"
@zoomIn="graphNavigator.stepZoom(+1)"
@zoomOut="graphNavigator.stepZoom(-1)"
Expand Down
23 changes: 10 additions & 13 deletions app/gui2/src/components/RecordControl.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
<script setup lang="ts">
import SvgButton from '@/components/SvgButton.vue'
import ToggleIcon from '@/components/ToggleIcon.vue'
import { useProjectStore } from '@/stores/project'

const props = defineProps<{ recordMode: boolean }>()
const emit = defineEmits<{ recordOnce: []; 'update:recordMode': [enabled: boolean] }>()
const project = useProjectStore()
</script>

<template>
<div class="RecordControl">
<div class="control left-end">
<ToggleIcon
icon="record"
<SvgButton
title="Refresh"
class="iconButton"
title="Record"
:modelValue="props.recordMode"
@update:modelValue="emit('update:recordMode', $event)"
name="refresh"
draggable="false"
@click.stop="project.executionContext.recompute()"
/>
</div>
<div class="control right-end">
<SvgButton
title="Record Once"
title="Run Workflow"
class="iconButton"
name="record_once"
name="workflow_play"
draggable="false"
@click.stop="() => emit('recordOnce')"
@click.stop="project.executionContext.recompute('all', 'Live')"
/>
</div>
</div>
Expand Down Expand Up @@ -56,9 +55,7 @@ const emit = defineEmits<{ recordOnce: []; 'update:recordMode': [enabled: boolea
border-radius: 0 var(--radius-full) var(--radius-full) 0;

.iconButton {
position: relative;
margin: 0 auto 0 0;
--icon-width: 24px;
}
}

Expand Down
9 changes: 1 addition & 8 deletions app/gui2/src/components/TopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ const showColorPicker = defineModel<boolean>('showColorPicker', { required: true
const showCodeEditor = defineModel<boolean>('showCodeEditor', { required: true })
const showDocumentationEditor = defineModel<boolean>('showDocumentationEditor', { required: true })
const props = defineProps<{
recordMode: boolean
zoomLevel: number
componentsSelected: number
}>()
const emit = defineEmits<{
recordOnce: []
'update:recordMode': [enabled: boolean]
fitToAllClicked: []
zoomIn: []
zoomOut: []
Expand All @@ -38,12 +35,8 @@ const barStyle = computed(() => {

<template>
<div class="TopBar" :style="barStyle">
<RecordControl
:recordMode="props.recordMode"
@update:recordMode="emit('update:recordMode', $event)"
@recordOnce="emit('recordOnce')"
/>
<NavBar />
<RecordControl />
<Transition name="selection-menu">
<SelectionMenu
v-if="componentsSelected > 1"
Expand Down
11 changes: 9 additions & 2 deletions app/gui2/src/stores/project/executionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import { exponentialBackoff } from 'shared/util/net'
import type { ExternalId } from 'shared/yjsModel'
import { reactive } from 'vue'

const DEFAULT_ENVIRONMENT: ExecutionEnvironment = 'Design'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a place where we should look to keep this synced with Java?

Copy link
Contributor Author

@farmaazon farmaazon Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not aware of any "GUI-Engine common constants" place in new GUI. There was something of sort in the old GUI, but didn't feel practical.

Maybe with Bazel we design a place/library like that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not saying that this should be automatically kept as a shared constant. Just a path to a Java file in the comment would be enough.


export type NodeVisualizationConfiguration = Omit<
VisualizationConfiguration,
'executionContextId'
Expand Down Expand Up @@ -60,7 +62,7 @@ type ExecutionContextState =
status: 'created'
visualizations: Map<Uuid, NodeVisualizationConfiguration>
stack: StackItem[]
environment?: ExecutionEnvironment
environment: ExecutionEnvironment
}

type EntryPoint = Omit<ExplicitCall, 'type'>
Expand Down Expand Up @@ -326,7 +328,12 @@ export class ExecutionContext extends ObservableV2<ExecutionContextNotification>
if (result.value.contextId !== this.id) {
return Err('Unexpected Context ID returned by the language server.')
}
newState = { status: 'created', visualizations: new Map(), stack: [] }
newState = {
status: 'created',
visualizations: new Map(),
stack: [],
environment: DEFAULT_ENVIRONMENT,
}
return Ok()
}, 'Failed to create execution context')
}
Expand Down
4 changes: 4 additions & 0 deletions app/gui2/src/stores/project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ export const { provideFn: provideProjectStore, injectFn: useProjectStore } = cre
},
})

watch(executionMode, (modeValue) => {
executionContext.executionEnvironment = modeValue === 'live' ? 'Live' : 'Design'
})

function renameProject(newDisplayedName: string) {
try {
renameProjectBackend(newDisplayedName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ type File
temp.delete_if_exists

## Attach a warning to the file that it is a dry run
warning = Dry_Run_Operation.Warning "Only a dry run has occurred, with data written to a temporary file. Press the Record Once button ❙⬤❙ to write the actual file."
warning = Dry_Run_Operation.Warning "Only a dry run has occurred, with data written to a temporary file. Press the Run Workflow button to write the actual file."
Warning.attach warning temp

## ALIAS current directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ create_table_implementation connection table_name structure primary_key temporar
internal_create_table_structure connection effective_table_name structure primary_key effective_temporary on_problems
if dry_run.not then connection.query (SQL_Query.Table_Name created_table_name) else
created_table = connection.base_connection.internal_allocate_dry_run_table created_table_name
warning = Dry_Run_Operation.Warning "Only a dry run of `create_table` has occurred, creating a temporary table ("+created_table_name.pretty+"). Press the Record Once button ❙⬤❙ to create the actual one."
warning = Dry_Run_Operation.Warning "Only a dry run of `create_table` has occurred, creating a temporary table ("+created_table_name.pretty+"). Run Workflow button to create the actual one."
Warning.attach warning created_table

## PRIVATE
Expand Down Expand Up @@ -118,7 +118,7 @@ select_into_table_implementation source_table connection table_name primary_key
connection.drop_table tmp_table_name if_exists=True
internal_upload_table source_table connection tmp_table_name primary_key temporary=True on_problems=on_problems row_limit=dry_run_row_limit
temporary_table = connection.base_connection.internal_allocate_dry_run_table table.name
warning = Dry_Run_Operation.Warning "Only a dry run of `select_into_database_table` was performed - a temporary table ("+tmp_table_name+") was created, containing a sample of the data. Press the Record Once button ❙⬤❙ to write to the actual table."
warning = Dry_Run_Operation.Warning "Only a dry run of `select_into_database_table` was performed - a temporary table ("+tmp_table_name+") was created, containing a sample of the data. Run Workflow button to write to the actual table."
Warning.attach warning temporary_table

## PRIVATE
Expand Down Expand Up @@ -344,7 +344,7 @@ common_update_table (source_table : DB_Table | Table) (target_table : DB_Table)
above fails, the whole transaction will be rolled back.
connection.drop_table tmp_table.name
if dry_run.not then resulting_table else
warning = Dry_Run_Operation.Warning "Only a dry run of `update_rows` was performed - the target table has been returned unchanged. Press the Record Once button ❙⬤❙ to update the actual table."
warning = Dry_Run_Operation.Warning "Only a dry run of `update_rows` was performed - the target table has been returned unchanged. Press the Run Workflow button to update the actual table."
Warning.attach warning resulting_table

## PRIVATE
Expand Down Expand Up @@ -549,7 +549,7 @@ common_delete_rows target_table key_values_to_delete key_columns allow_duplicate
source.drop_temporary_table connection
if dry_run.not then affected_row_count else
suffix = source.dry_run_message_suffix
warning = Dry_Run_Operation.Warning "Only a dry run of `delete_rows` was performed - the target table has not been changed. Press the Record Once button ❙⬤❙ to update the actual table."+suffix
warning = Dry_Run_Operation.Warning "Only a dry run of `delete_rows` was performed - the target table has not been changed. Press the Run Workflow button to update the actual table."+suffix
Warning.attach warning affected_row_count

## PRIVATE
Expand Down
Loading