Skip to content

Commit

Permalink
Fixing edge table support in table designer (microsoft#18555)
Browse files Browse the repository at this point in the history
* Adding edge table support in table designer

* Making sure general group is expanded for edge constraints

* adding some comments

* Updating sts version
  • Loading branch information
aasimkhan30 authored Jan 16, 2025
1 parent 99707e6 commit a2a3b96
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/configurations/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"service": {
"downloadUrl": "https://github.com/Microsoft/sqltoolsservice/releases/download/{#version#}/microsoft.sqltools.servicelayer-{#fileName#}",
"version": "5.0.20241218.1",
"version": "5.0.20250115.1",
"downloadFileNames": {
"Windows_86": "win-x86-net8.0.zip",
"Windows_64": "win-x64-net8.0.zip",
Expand Down
17 changes: 14 additions & 3 deletions src/reactviews/pages/TableDesigner/designerPropertiesPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,19 @@ export const DesignerPropertiesPane = () => {
});
};

const getExpandedGroups = () => {
// If expanded groups are set, return them
if (parentTableProperties.expandedGroups) {
return parentTableProperties.expandedGroups;
} else {
// If expanded groups are not set, expand the first group
if (getAccordionGroups().length > 0) {
return [groups[0]];
}
// If there are no groups, return empty array
return [];
}
};
return (
<div className={classes.root}>
<div className={classes.title}>
Expand Down Expand Up @@ -316,9 +329,7 @@ export const DesignerPropertiesPane = () => {
<Accordion
multiple
collapsible
defaultOpenItems={
parentTableProperties.expandedGroups ?? []
}
defaultOpenItems={getExpandedGroups()}
>
{data && getAccordionGroups()}
</Accordion>
Expand Down
22 changes: 16 additions & 6 deletions src/tableDesigner/tableDesignerTabDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ export function getCheckConstraintsTabComponents(
export function getDesignerView(
view: designer.TableDesignerView | undefined,
): designer.DesignerView {
return {
const viewDefinition = {
tabs: [
{
title: vscode.l10n.t("Columns"),
Expand All @@ -721,13 +721,23 @@ export function getDesignerView(
id: designer.DesignerMainPaneTabs.CheckConstraints,
components: getCheckConstraintsTabComponents(view),
},
{
title: vscode.l10n.t("Advanced Options"),
id: designer.DesignerMainPaneTabs.AboutTable,
components: getAdvancedOptionsComponents(view),
},
],
};

for (const tab of view.additionalTabs) {
viewDefinition.tabs.push({
title: tab.title,
id: tab.id as designer.DesignerMainPaneTabs,
components: tab.components,
});
}

viewDefinition.tabs.push({
title: vscode.l10n.t("Advanced Options"),
id: designer.DesignerMainPaneTabs.AboutTable,
components: getAdvancedOptionsComponents(view),
});
return viewDefinition;
}

function getTableDisplayProperties(
Expand Down
76 changes: 41 additions & 35 deletions src/tableDesigner/tableDesignerWebviewController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,44 +208,50 @@ export class TableDesignerWebviewController extends ReactWebviewPanelController<

private registerRpcHandlers() {
this.registerReducer("processTableEdit", async (state, payload) => {
const editResponse =
await this._tableDesignerService.processTableEdit(
payload.table,
payload.tableChangeInfo,
try {
const editResponse =
await this._tableDesignerService.processTableEdit(
payload.table,
payload.tableChangeInfo,
);
sendActionEvent(
TelemetryViews.TableDesigner,
TelemetryActions.Edit,
{
type: payload.tableChangeInfo.type.toString(),
source: payload.tableChangeInfo.source,
correlationId: this._correlationId,
},
);
sendActionEvent(
TelemetryViews.TableDesigner,
TelemetryActions.Edit,
{
type: payload.tableChangeInfo.type.toString(),
source: payload.tableChangeInfo.source,
correlationId: this._correlationId,
},
);
if (editResponse.issues?.length === 0) {
state.tabStates.resultPaneTab =
designer.DesignerResultPaneTabs.Script;
} else {
state.tabStates.resultPaneTab =
designer.DesignerResultPaneTabs.Issues;
}
if (editResponse.issues?.length === 0) {
state.tabStates.resultPaneTab =
designer.DesignerResultPaneTabs.Script;
} else {
state.tabStates.resultPaneTab =
designer.DesignerResultPaneTabs.Issues;
}

this.showRestorePromptAfterClose = true;
this.showRestorePromptAfterClose = true;

const afterEditState = {
...state,
view: editResponse.view
? getDesignerView(editResponse.view)
: state.view,
model: editResponse.viewModel,
issues: editResponse.issues,
isValid: editResponse.isValid,
apiState: {
...state.apiState,
editState: designer.LoadState.Loaded,
},
};
return afterEditState;
const afterEditState = {
...state,
view: editResponse.view
? getDesignerView(editResponse.view)
: state.view,
model: editResponse.viewModel,
issues: editResponse.issues,
isValid: editResponse.isValid,
apiState: {
...state.apiState,
editState: designer.LoadState.Loaded,
},
};

return afterEditState;
} catch (e) {
vscode.window.showErrorMessage(e.message);
return state;
}
});

this.registerReducer("publishChanges", async (state, payload) => {
Expand Down

0 comments on commit a2a3b96

Please sign in to comment.