Skip to content

Commit

Permalink
model config Only show confirmation dialog if config has changes (#4459)
Browse files Browse the repository at this point in the history
  • Loading branch information
asylves1 authored Aug 15, 2024
1 parent 5e12fe0 commit 3a5480b
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@

<script setup lang="ts">
import '@/ace-config';
import { cloneDeep, isEmpty, orderBy } from 'lodash';
import { cloneDeep, isEmpty, isEqual, orderBy } from 'lodash';
import Accordion from 'primevue/accordion';
import AccordionTab from 'primevue/accordiontab';
import Button from 'primevue/button';
Expand Down Expand Up @@ -450,6 +450,7 @@ useClientEvent(ClientEventType.TaskGollmConfigureFromDataset, configModelEventHa

const selectedOutputId = ref<string>('');
const selectedConfigId = computed(() => props.node.outputs.find((o) => o.id === selectedOutputId.value)?.value?.[0]);
let originalConfig: ModelConfiguration | null = null;

const documentId = computed(() => props.node.inputs[1]?.value?.[0]?.documentId);
const datasetIds = computed(() => props.node.inputs[2]?.value);
Expand Down Expand Up @@ -532,6 +533,7 @@ const initialize = async () => {
applyConfigValues(suggestedConfigurationContext.value.tableData[0]);
} else {
knobs.value.transientModelConfig = cloneDeep(state.transientModelConfig);
originalConfig = cloneDeep(state.transientModelConfig);
}
// Create a new session and context based on model
Expand All @@ -550,6 +552,12 @@ const initialize = async () => {
};
const onSelectConfiguration = (config: ModelConfiguration) => {
// Checks if there are unsaved changes to current model configuration
if (isEqual(originalConfig, knobs.value.transientModelConfig)) {
applyConfigValues(config);
return;
}
confirm.require({
header: 'Are you sure you want to select this configuration?',
message: `This will apply the configuration "${config.name}" to the model. All current values will be replaced.`,
Expand All @@ -563,6 +571,7 @@ const onSelectConfiguration = (config: ModelConfiguration) => {
const applyConfigValues = (config: ModelConfiguration) => {
knobs.value.transientModelConfig = cloneDeep(config);
originalConfig = cloneDeep(config);
// Update output port:
if (!config.id) {
Expand Down Expand Up @@ -605,7 +614,6 @@ const resetConfiguration = () => {
header: 'Are you sure you want to reset the configuration?',
message: 'This will reset all values original values of the configuration.',
accept: () => {
const originalConfig = suggestedConfigurationContext.value.tableData.find((c) => c.id === selectedConfigId.value);
if (originalConfig) applyConfigValues(originalConfig);
},
acceptLabel: 'Confirm',
Expand Down

0 comments on commit 3a5480b

Please sign in to comment.