From 10bac639be2bcc83a9d250ef312bd6867d8db9dd Mon Sep 17 00:00:00 2001 From: anaghav2023 <124548794+anaghav2023@users.noreply.github.com> Date: Mon, 25 Nov 2024 12:21:52 +0530 Subject: [PATCH 1/5] quick fix --- plugins/phrase-conector/src/phrase.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/phrase-conector/src/phrase.ts b/plugins/phrase-conector/src/phrase.ts index 2cc3e7ac173..dd08ec27f7e 100644 --- a/plugins/phrase-conector/src/phrase.ts +++ b/plugins/phrase-conector/src/phrase.ts @@ -34,11 +34,12 @@ export class Phrase { } async request(path: string, config?: RequestInit, search = {}) { + let privateKey = await appState.globalState.getPluginPrivateKey(pkg.name); await this.loaded; return fetch(`${this.getBaseUrl(path, search)}`, { ...config, headers: { - Authorization: `Bearer ${this.privateKey}`, + Authorization: `Bearer ${privateKey}`, 'Content-Type': 'application/json', }, }).then(res => res.json()); From 7b2780738b7b8681b2f081dab23e51ca3f7eb389 Mon Sep 17 00:00:00 2001 From: Anagha <124548794+anaghav2023@users.noreply.github.com> Date: Mon, 25 Nov 2024 17:09:34 +0530 Subject: [PATCH 2/5] Update plugins/phrase-conector/src/phrase.ts Co-authored-by: Sanyam Kamat <1625114+sanyamkamat@users.noreply.github.com> --- plugins/phrase-conector/src/phrase.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/phrase-conector/src/phrase.ts b/plugins/phrase-conector/src/phrase.ts index dd08ec27f7e..202addf9b09 100644 --- a/plugins/phrase-conector/src/phrase.ts +++ b/plugins/phrase-conector/src/phrase.ts @@ -34,7 +34,7 @@ export class Phrase { } async request(path: string, config?: RequestInit, search = {}) { - let privateKey = await appState.globalState.getPluginPrivateKey(pkg.name); + const privateKey = await appState.globalState.getPluginPrivateKey(pkg.name); await this.loaded; return fetch(`${this.getBaseUrl(path, search)}`, { ...config, From 8a63ea0753e6d0d66e09d9f158e8f98251badf96 Mon Sep 17 00:00:00 2001 From: anaghav2023 <124548794+anaghav2023@users.noreply.github.com> Date: Wed, 27 Nov 2024 16:52:57 +0530 Subject: [PATCH 3/5] subscribing to org switched event --- plugins/phrase-conector/src/phrase.ts | 9 +++++++-- plugins/smartling/src/smartling.ts | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/plugins/phrase-conector/src/phrase.ts b/plugins/phrase-conector/src/phrase.ts index dd08ec27f7e..d99b6e36eee 100644 --- a/plugins/phrase-conector/src/phrase.ts +++ b/plugins/phrase-conector/src/phrase.ts @@ -1,3 +1,4 @@ +import { action } from 'mobx'; import pkg from '../package.json'; import appState from '@builder.io/app-context'; @@ -24,6 +25,11 @@ export class Phrase { constructor(private apiHost?: string) { this.loaded = new Promise(resolve => (this.resolveLoaded = resolve)); this.init(); + appState.globalState.orgChanged?.subscribe( + action(async () => { + await this.init(); + }) + ); } async init() { @@ -34,12 +40,11 @@ export class Phrase { } async request(path: string, config?: RequestInit, search = {}) { - let privateKey = await appState.globalState.getPluginPrivateKey(pkg.name); await this.loaded; return fetch(`${this.getBaseUrl(path, search)}`, { ...config, headers: { - Authorization: `Bearer ${privateKey}`, + Authorization: `Bearer ${this.privateKey}`, 'Content-Type': 'application/json', }, }).then(res => res.json()); diff --git a/plugins/smartling/src/smartling.ts b/plugins/smartling/src/smartling.ts index 6a20b34fde3..8f4efb0af2b 100644 --- a/plugins/smartling/src/smartling.ts +++ b/plugins/smartling/src/smartling.ts @@ -1,6 +1,7 @@ import pkg from '../package.json'; import appState from '@builder.io/app-context'; import { getTranslationModel } from './model-template'; +import { action } from 'mobx'; export type Project = { targetLocales: Array<{ enabled: boolean; localeId: string; description: string }>; @@ -29,6 +30,11 @@ export class SmartlingApi { constructor() { this.loaded = new Promise(resolve => (this.resolveLoaded = resolve)); this.init(); + appState.globalState.orgChanged?.subscribe( + action(async () => { + await this.init(); + }) + ); } async init() { From f80980bf405e7d8613b06c5c14ceaf3596d172a8 Mon Sep 17 00:00:00 2001 From: anaghav2023 <124548794+anaghav2023@users.noreply.github.com> Date: Wed, 27 Nov 2024 16:55:14 +0530 Subject: [PATCH 4/5] renaming --- plugins/phrase-conector/src/phrase.ts | 2 +- plugins/smartling/src/smartling.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/phrase-conector/src/phrase.ts b/plugins/phrase-conector/src/phrase.ts index d99b6e36eee..d93d7fda015 100644 --- a/plugins/phrase-conector/src/phrase.ts +++ b/plugins/phrase-conector/src/phrase.ts @@ -25,7 +25,7 @@ export class Phrase { constructor(private apiHost?: string) { this.loaded = new Promise(resolve => (this.resolveLoaded = resolve)); this.init(); - appState.globalState.orgChanged?.subscribe( + appState.globalState.orgSwitched?.subscribe( action(async () => { await this.init(); }) diff --git a/plugins/smartling/src/smartling.ts b/plugins/smartling/src/smartling.ts index 8f4efb0af2b..319389d5ff9 100644 --- a/plugins/smartling/src/smartling.ts +++ b/plugins/smartling/src/smartling.ts @@ -30,7 +30,7 @@ export class SmartlingApi { constructor() { this.loaded = new Promise(resolve => (this.resolveLoaded = resolve)); this.init(); - appState.globalState.orgChanged?.subscribe( + appState.globalState.orgSwitched?.subscribe( action(async () => { await this.init(); }) From f823f3c9ee97c50124a96fa89b95f2c4d35d8eb6 Mon Sep 17 00:00:00 2001 From: anaghav2023 <124548794+anaghav2023@users.noreply.github.com> Date: Thu, 28 Nov 2024 15:12:27 +0530 Subject: [PATCH 5/5] version update after release --- plugins/phrase-conector/package-lock.json | 4 ++-- plugins/phrase-conector/package.json | 2 +- plugins/smartling/package-lock.json | 4 ++-- plugins/smartling/package.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/phrase-conector/package-lock.json b/plugins/phrase-conector/package-lock.json index 1f275ff1e8c..524f193865d 100644 --- a/plugins/phrase-conector/package-lock.json +++ b/plugins/phrase-conector/package-lock.json @@ -1,12 +1,12 @@ { "name": "@builder.io/plugin-phrase-connector", - "version": "0.0.11", + "version": "0.0.14", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@builder.io/plugin-phrase-connector", - "version": "0.0.11", + "version": "0.0.14", "license": "MIT", "dependencies": { "@builder.io/commerce-plugin-tools": "^0.3.0", diff --git a/plugins/phrase-conector/package.json b/plugins/phrase-conector/package.json index 9592c9ea103..74a5bb0999e 100644 --- a/plugins/phrase-conector/package.json +++ b/plugins/phrase-conector/package.json @@ -1,6 +1,6 @@ { "name": "@builder.io/plugin-phrase-connector", - "version": "0.0.11", + "version": "0.0.14", "description": "", "keywords": [], "main": "dist/plugin.system.js", diff --git a/plugins/smartling/package-lock.json b/plugins/smartling/package-lock.json index 75efcbe5a80..8441ae5efe6 100644 --- a/plugins/smartling/package-lock.json +++ b/plugins/smartling/package-lock.json @@ -1,12 +1,12 @@ { "name": "@builder.io/plugin-smartling", - "version": "0.0.20", + "version": "0.0.21", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@builder.io/plugin-smartling", - "version": "0.0.20", + "version": "0.0.21", "license": "MIT", "dependencies": { "@builder.io/commerce-plugin-tools": "^0.3.0", diff --git a/plugins/smartling/package.json b/plugins/smartling/package.json index 790bd203710..03471e84ba6 100644 --- a/plugins/smartling/package.json +++ b/plugins/smartling/package.json @@ -1,6 +1,6 @@ { "name": "@builder.io/plugin-smartling", - "version": "0.0.20", + "version": "0.0.21", "description": "", "keywords": [], "main": "dist/plugin.system.js",