Skip to content

Commit 3faa7b7

Browse files
committed
Merge branch 'main' into lewissanchez/feat/add-lanaguge-service-switch-2
2 parents 3070fd2 + 127fa7f commit 3faa7b7

File tree

6 files changed

+90
-31
lines changed

6 files changed

+90
-31
lines changed

.github/workflows/file-size-check.yml .github/workflows/pr-checks.yml

+57-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
name: File Size Check
2-
# Trigger the workflow on PRs to the main branch. It builds the extension in prod mode and checks the size of the
3-
# vsix file and webview bundle file and compares it with the main branch. It fails if the size has increased by more than 10%.
4-
# For vsix, we also check if the size is greater than 25MB.
1+
name: PR Checks
2+
# Trigger the workflow on PRs to the main branch.
3+
# It performs the following checks:
4+
# 1. Calculate the size difference between the webview bundles of the main branch and the PR branch.
5+
# 2. Calculate the size difference between the VSIX files of the main branch and the PR branch.
6+
# 3. Does a check if the PR has properly localized strings.
57

68
on:
79
pull_request:
810
branches:
911
- main
1012

1113
jobs:
12-
size-check:
14+
pr-checks:
1315
runs-on: ubuntu-latest
1416
permissions:
1517
contents: read
@@ -119,21 +121,14 @@ jobs:
119121
body-includes: |
120122
### VSIX Size Comparison
121123
122-
- name: Create comment
124+
- name: Create or update comment
123125
if: steps.fc.outputs.comment-id == ''
124126
uses: peter-evans/create-or-update-comment@v4
125127
with:
126128
token: ${{ secrets.GITHUB_TOKEN }}
127129
issue-number: ${{ github.event.pull_request.number }}
128130
body-path: ./results.md
129-
130-
- name: Update comment
131-
if: steps.fc.outputs.comment-id != ''
132-
uses: peter-evans/create-or-update-comment@v4
133-
with:
134-
token: ${{ secrets.GITHUB_TOKEN }}
135131
comment-id: ${{ steps.fc.outputs.comment-id }}
136-
body-path: ./results.md
137132
edit-mode: replace
138133

139134
- name: Fail if vsix size is increased by 5% or size is above 25mb
@@ -144,7 +139,56 @@ jobs:
144139
if: ${{ env.webview_bundle_percentage_change > 5 }}
145140
run: exit 1
146141

142+
- name: Generate xliff files in PR branch
143+
run: |
144+
cd pr
145+
yarn localization
147146
147+
# Check if there are git changes in english xlf files
148+
- name: Check for changes in english xlf files
149+
run: |
150+
cd pr
151+
if git diff --quiet --exit-code ./localization/xliff/vscode-mssql.xlf; then
152+
echo "Changes not found in english xlf files"
153+
echo "loc_update_required=false" >> $GITHUB_ENV
154+
else
155+
echo "Changes found in english xlf files"
156+
echo "loc_update_required=true" >> $GITHUB_ENV
157+
fi
148158
159+
- name: Find comment
160+
uses: peter-evans/find-comment@v3
161+
id: loc-comment
162+
with:
163+
issue-number: ${{ github.event.pull_request.number }}
164+
comment-author: 'github-actions[bot]'
165+
body-includes: |
166+
# Updates to localized strings required
149167
168+
- name: Create or update comment
169+
if: ${{ env.loc_update_required == 'true' }}
170+
uses: peter-evans/create-or-update-comment@v4
171+
with:
172+
comment-id: ${{ steps.loc-comment.outputs.comment-id }}
173+
token: ${{ secrets.GITHUB_TOKEN }}
174+
issue-number: ${{ github.event.pull_request.number }}
175+
body: |
176+
# Updates to localized strings required
177+
Please update the localized strings in the PR with following steps:
178+
1. Run `yarn localization` in the PR branch.
179+
1. Based on the changes,
180+
* If there are changes in localized strings in source code, make sure that `src/localization/xliff/vscode-mssql.xlf` and `src/l10n/bundle.l10n.json` files are updated.
181+
* If there are changes in localized strings in `package.nls.json`, make sure that `src/localization/xliff/vscode-mssql.xlf` is updated.
182+
edit-mode: replace
150183

184+
- name: Delete comment
185+
if: ${{ env.loc_update_required == 'false' }} && steps.loc-comment.outputs.comment-id != ''
186+
run: |
187+
curl -X DELETE \
188+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
189+
-H "Accept: application/vnd.github.v3+json" \
190+
https://api.github.com/repos/${{ github.repository }}/issues/comments/${{ steps.loc-comment.outputs.comment-id }}
191+
192+
- name: Fail if there are changes required in english xlf files
193+
if: ${{ env.loc_update_required == 'true' }}
194+
run: exit 1

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ coverage
1818
coverage-remapped
1919
test-reports
2020
.vscode-test
21-
localization/i18n/
2221
src/constants/localizedConstants.ts
2322
package.nls.*.json
2423
/test-results/

localization/xliff/vscode-mssql.xlf

+3
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,9 @@
10461046
<trans-unit id="mssql.queryHistoryLimit">
10471047
<source xml:lang="en">Number of query history entries to show in the Query History view</source>
10481048
</trans-unit>
1049+
<trans-unit id="mssql.openExecutionPlanFile">
1050+
<source xml:lang="en">Open Execution Plan File</source>
1051+
</trans-unit>
10491052
<trans-unit id="mssql.openQueryHistory">
10501053
<source xml:lang="en">Open Query</source>
10511054
</trans-unit>

src/connectionconfig/connectionDialogWebviewController.ts

+27-14
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class ConnectionDialogWebviewController extends ReactWebviewPanelControll
8181

8282
private async loadRecentConnections() {
8383
const recentConnections = this._mainController.connectionManager.connectionStore.loadAllConnections(true).map(c => c.connectionCreds);
84-
const dialogConnections = [];
84+
const dialogConnections: IConnectionDialogProfile[] = [];
8585
for (let i = 0; i < recentConnections.length; i++) {
8686
dialogConnections.push(await this.initializeConnectionForDialog(recentConnections[i]));
8787
}
@@ -105,28 +105,41 @@ export class ConnectionDialogWebviewController extends ReactWebviewPanelControll
105105
this.state.connectionProfile = emptyConnection;
106106
}
107107

108-
private async initializeConnectionForDialog(connection: IConnectionInfo) {
108+
private async initializeConnectionForDialog(connection: IConnectionInfo): Promise<IConnectionDialogProfile> {
109109
// Load the password if it's saved
110110
const isConnectionStringConnection = connection.connectionString !== undefined && connection.connectionString !== '';
111-
const password = await this._mainController.connectionManager.connectionStore.lookupPassword(connection, isConnectionStringConnection);
112111
if (!isConnectionStringConnection) {
112+
const password = await this._mainController.connectionManager.connectionStore.lookupPassword(connection, isConnectionStringConnection);
113113
connection.password = password;
114114
} else {
115-
connection.connectionString = '';
116-
// extract password from connection string it starts after 'Password=' and ends before ';'
117-
const passwordIndex = password.indexOf('Password=') === -1 ? password.indexOf('password=') : password.indexOf('Password=');
118-
if (passwordIndex !== -1) {
119-
const passwordStart = passwordIndex + 'Password='.length;
120-
const passwordEnd = password.indexOf(';', passwordStart);
121-
if (passwordEnd !== -1) {
122-
connection.password = password.substring(passwordStart, passwordEnd);
115+
// If the connection is a connection string connection with SQL Auth:
116+
// * the full connection string is stored as the "password" in the credential store
117+
// * we need to extract the password from the connection string
118+
// If the connection is a connection string connection with a different auth type, then there's nothing in the credential store.
119+
120+
const connectionString = await this._mainController.connectionManager.connectionStore.lookupPassword(connection, isConnectionStringConnection);
121+
122+
if (connectionString) {
123+
const passwordIndex = connectionString.toLowerCase().indexOf('password=');
124+
125+
if (passwordIndex !== -1) {
126+
// extract password from connection string; found between 'Password=' and the next ';'
127+
const passwordStart = passwordIndex + 'password='.length;
128+
const passwordEnd = connectionString.indexOf(';', passwordStart);
129+
if (passwordEnd !== -1) {
130+
connection.password = connectionString.substring(passwordStart, passwordEnd);
131+
}
132+
133+
// clear the connection string from the IConnectionDialogProfile so that the ugly connection string key
134+
// that's used to look up the actual connection string (with password) isn't displayed
135+
connection.connectionString = '';
123136
}
124137
}
125-
126138
}
139+
127140
const dialogConnection = connection as IConnectionDialogProfile;
128-
// Set the profile name
129-
dialogConnection.profileName = dialogConnection.profileName ?? getConnectionDisplayName(connection);
141+
// Set the display name
142+
dialogConnection.displayName = dialogConnection.profileName ? dialogConnection.profileName : getConnectionDisplayName(connection);
130143
return dialogConnection;
131144
}
132145

src/reactviews/pages/ConnectionDialog/mruConnectionsContainer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const MruConnectionsContainer = () => {
5454
connectionDialogContext.loadConnection(connection);
5555
}}>
5656
<TreeItemLayout iconBefore={<ServerRegular />}>
57-
{connection.profileName}
57+
{connection.displayName}
5858
</TreeItemLayout>
5959
</TreeItem>;
6060
})

src/sharedInterfaces/connectionDialog.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ export interface IConnectionDialogProfile extends vscodeMssql.IConnectionInfo {
6666
savePassword?: boolean;
6767
emptyPasswordInput?: boolean;
6868
azureAuthType?: vscodeMssql.AzureAuthType;
69+
/** display name for the MRU pane; should be set to the profileName if available, otherwise generated from connection details */
70+
displayName?: string;
6971
}
7072

71-
72-
7373
export interface ConnectionDialogContextProps extends FormContextProps<ConnectionDialogWebviewState, IConnectionDialogProfile> {
7474
theme: Theme;
7575
loadConnection: (connection: IConnectionDialogProfile) => void;

0 commit comments

Comments
 (0)