Skip to content

Commit

Permalink
Convert Settings form to be organized with tabs (#38)
Browse files Browse the repository at this point in the history
* wip

* New settings form works

* Remove old settings form

* remove extra setting for now

* Header and misc changes

* Let the user verify that a non-empty database is ok instead of requiring them to empty it out first

---------

Co-authored-by: Ben Martens <benmar@microsoft.com>
  • Loading branch information
benmartens and Ben Martens authored Apr 22, 2024
1 parent cb2fb0d commit a257b11
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 240 deletions.
14 changes: 12 additions & 2 deletions SyncKusto/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ IDatabaseSchema TryGetSchema(Func<Either<IOperationError, DatabaseSchema>> schem
case InvalidDatabaseSchema invalidSource:
MessageBox.Show($@"The Source schema is invalid: {errorMessageResolver().ResolveFor(invalidSource.Error).Get()}", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;

case ValidDatabaseSchema _ when targetSchema is InvalidDatabaseSchema invalidTarget:
MessageBox.Show($@"The Target schema is invalid: {errorMessageResolver().ResolveFor(invalidTarget.Error).Get()}", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;

case ValidDatabaseSchema source when targetSchema is ValidDatabaseSchema target:
spcTarget.ReportProgress($@"Schema loaded.");
_sourceSchema = source.Schema;
Expand Down Expand Up @@ -180,10 +182,12 @@ TreeNode ToTreeNode(SchemaDifference difference)
when drop.Difference is OnlyInTarget:
functionDropNode.Nodes.Add(ToTreeNode(drop));
break;

case FunctionSchemaDifference add
when add.Difference is OnlyInSource:
functionAddNode.Nodes.Add(ToTreeNode(add));
break;

case FunctionSchemaDifference change
when change.Difference is Modified:
functionEditNode.Nodes.Add(ToTreeNode(change));
Expand All @@ -204,10 +208,12 @@ TreeNode ToTreeNode(SchemaDifference difference)
when drop.Difference is OnlyInTarget:
tableDropNode.Nodes.Add(ToTreeNode(drop));
break;

case TableSchemaDifference add
when add.Difference is OnlyInSource:
tableAddNode.Nodes.Add(ToTreeNode(add));
break;

case TableSchemaDifference change
when change.Difference is Modified:
tableEditNode.Nodes.Add(ToTreeNode(change));
Expand Down Expand Up @@ -282,12 +288,15 @@ private void tvComparison_NodeMouseClick(object sender, TreeNodeMouseClickEventA
rtbSourceText.SelectionBackColor = System.Drawing.Color.Yellow;
rtbSourceText.SelectedText = line.Text.PadRight(longestLine);
break;

case DiffPlex.DiffBuilder.Model.ChangeType.Deleted:
rtbSourceText.SelectionBackColor = System.Drawing.Color.Red;
rtbSourceText.SelectedText = line.Text.PadRight(longestLine);
break;

case DiffPlex.DiffBuilder.Model.ChangeType.Imaginary:
break;

default:
rtbSourceText.SelectionBackColor = System.Drawing.Color.White;
rtbSourceText.SelectedText = line.Text.PadRight(longestLine);
Expand Down Expand Up @@ -360,7 +369,6 @@ private void btnUpdate_Click(object sender, EventArgs e)
/// <param name="kustoQueryEngine">Pass a connection to Kusto if the target is Kusto</param>
private void PersistChanges(IEnumerable<TreeNode> selectedNodes, QueryEngine kustoQueryEngine = null)
{

void WriteToTarget(IKustoSchema schema)
{
if (spcTarget.SourceSelection == SourceSelection.FilePath())
Expand Down Expand Up @@ -394,10 +402,12 @@ difference.Difference is Modified ||
difference.Difference is OnlyInSource:
WriteToTarget(update);
break;

case IKustoSchema delete when
difference.Difference is OnlyInTarget:
DeleteFromTarget(delete);
break;

default:
throw new InvalidOperationException("Unhandled type supplied.");
}
Expand Down Expand Up @@ -495,4 +505,4 @@ private bool IsTempClusterDefined()
return !string.IsNullOrWhiteSpace(SettingsWrapper.KustoClusterForTempDatabases);
}
}
}
}
2 changes: 1 addition & 1 deletion SyncKusto/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a257b11

Please sign in to comment.