Skip to content

Commit a6dd774

Browse files
committed
drop extra localization parsing roundtrip
1 parent 768aa72 commit a6dd774

File tree

5 files changed

+8
-44
lines changed

5 files changed

+8
-44
lines changed

src/notebooks/deepnote/integrations/integrationWebview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class IntegrationWebviewProvider implements IIntegrationWebviewProvider {
141141

142142
await this.currentPanel.webview.postMessage({
143143
type: SharedMessages.LocInit,
144-
locStrings: JSON.stringify(locStrings)
144+
locStrings: locStrings
145145
});
146146
}
147147

src/platform/webviews/webviewHost.ts

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export abstract class WebviewHost<IMapping> implements IDisposable {
221221
}
222222

223223
protected async sendLocStrings() {
224-
const locStrings: LocalizedMessages = {
224+
const locStrings: Partial<LocalizedMessages> = {
225225
collapseSingle: localize.WebViews.collapseSingle,
226226
expandSingle: localize.WebViews.expandSingle,
227227
openExportFileYes: localize.DataScience.openExportFileYes,
@@ -265,43 +265,7 @@ export abstract class WebviewHost<IMapping> implements IDisposable {
265265
dataframeNextPage: localize.WebViews.dataframeNextPage,
266266
dataframePageOf: localize.WebViews.dataframePageOf,
267267
dataframeCopyTable: localize.WebViews.dataframeCopyTable,
268-
dataframeExportTable: localize.WebViews.dataframeExportTable,
269-
// Integration panel strings (not used in this webview, but required by type)
270-
integrationsTitle: '',
271-
integrationsNoIntegrationsFound: '',
272-
integrationsConnected: '',
273-
integrationsNotConfigured: '',
274-
integrationsConfigure: '',
275-
integrationsReconfigure: '',
276-
integrationsReset: '',
277-
integrationsConfirmResetTitle: '',
278-
integrationsConfirmResetMessage: '',
279-
integrationsConfirmResetDetails: '',
280-
integrationsConfigureTitle: '',
281-
integrationsCancel: '',
282-
integrationsSave: '',
283-
integrationsPostgresNameLabel: '',
284-
integrationsPostgresNamePlaceholder: '',
285-
integrationsPostgresHostLabel: '',
286-
integrationsPostgresHostPlaceholder: '',
287-
integrationsPostgresPortLabel: '',
288-
integrationsPostgresPortPlaceholder: '',
289-
integrationsPostgresDatabaseLabel: '',
290-
integrationsPostgresDatabasePlaceholder: '',
291-
integrationsPostgresUsernameLabel: '',
292-
integrationsPostgresUsernamePlaceholder: '',
293-
integrationsPostgresPasswordLabel: '',
294-
integrationsPostgresPasswordPlaceholder: '',
295-
integrationsPostgresSslLabel: '',
296-
integrationsBigQueryNameLabel: '',
297-
integrationsBigQueryNamePlaceholder: '',
298-
integrationsBigQueryProjectIdLabel: '',
299-
integrationsBigQueryProjectIdPlaceholder: '',
300-
integrationsBigQueryCredentialsLabel: '',
301-
integrationsBigQueryCredentialsPlaceholder: '',
302-
integrationsBigQueryCredentialsRequired: '',
303-
integrationsRequiredField: '',
304-
integrationsOptionalField: ''
268+
dataframeExportTable: localize.WebViews.dataframeExportTable
305269
};
306270
this.postMessageInternal(SharedMessages.LocInit, JSON.stringify(locStrings)).catch(noop);
307271
}

src/webviews/webview-side/integrations/IntegrationPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const IntegrationPanel: React.FC<IIntegrationPanelProps> = ({ baseTheme,
4242
switch (msg.type) {
4343
case 'loc_init':
4444
if (msg.type === 'loc_init') {
45-
const locStrings = JSON.parse(msg.locStrings);
45+
const locStrings = msg.locStrings;
4646
storeLocStrings(locStrings);
4747
}
4848
break;

src/webviews/webview-side/integrations/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export interface StatusMessage {
5656

5757
export interface LocInitMessage {
5858
type: 'loc_init';
59-
locStrings: string;
59+
locStrings: Partial<import('../../../messageTypes').LocalizedMessages>;
6060
}
6161

6262
export type WebviewMessage = UpdateMessage | ShowFormMessage | StatusMessage | LocInitMessage;

src/webviews/webview-side/react-common/locReactSide.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import { LocalizedMessages } from '../../../messageTypes';
66
// The react code can't use the localize.ts module because it reads from
77
// disk. This isn't allowed inside a browser, so we pass the collection
88
// through the javascript.
9-
let loadedCollection: LocalizedMessages | undefined;
9+
let loadedCollection: Partial<LocalizedMessages> | undefined;
1010

1111
export function getLocString(key: keyof LocalizedMessages, defValue: string): string {
1212
if (loadedCollection && loadedCollection.hasOwnProperty(key)) {
13-
return loadedCollection[key];
13+
return loadedCollection[key] ?? defValue;
1414
}
1515

1616
return defValue;
1717
}
1818

19-
export function storeLocStrings(collection: LocalizedMessages) {
19+
export function storeLocStrings(collection: Partial<LocalizedMessages>) {
2020
loadedCollection = collection;
2121
}
2222

0 commit comments

Comments
 (0)