From f048f722af6cf3a674001c4b72a5f1497acb072c Mon Sep 17 00:00:00 2001 From: cngonzalez Date: Mon, 21 Mar 2022 17:57:35 -0700 Subject: [PATCH] All turtles add link (#10) Combined with a parallel update in sanity-translations-tab, this update includes a link that goes straight to the given task in Smartling, using the project id and task id. If there is a task, then a link will show along with the current job to "View Job" so users can easily get to the associated Smartling job for additional updates or info. --- package-lock.json | 4 ++-- package.json | 2 +- src/adapter/getTranslationTask.ts | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6976a82..ebf54cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "sanity-plugin-studio-smartling", - "version": "1.4.1", + "version": "1.5.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "sanity-plugin-studio-smartling", - "version": "1.4.1", + "version": "1.5.0", "license": "MIT", "dependencies": { "sanity-naive-html-serializer": "^1.3.0", diff --git a/package.json b/package.json index 38d0400..ce2dce4 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "1.4.1", + "version": "1.5.0", "license": "MIT", "main": "dist/index.js", "typings": "dist/index.d.ts", diff --git a/src/adapter/getTranslationTask.ts b/src/adapter/getTranslationTask.ts index 621715e..960ee92 100644 --- a/src/adapter/getTranslationTask.ts +++ b/src/adapter/getTranslationTask.ts @@ -20,10 +20,11 @@ export const getTranslationTask = async ( } } - const url = `https://api.smartling.com/jobs-api/v3/projects/${secrets.project}/jobs/${taskId}/progress` + const projectId = secrets.project + const progressUrl = `https://api.smartling.com/jobs-api/v3/projects/${projectId}/jobs/${taskId}/progress` const smartlingTask = await fetch(smartlingProxy, { method: 'POST', - headers: getHeaders(url, accessToken), + headers: getHeaders(progressUrl, accessToken), }) .then(res => res.json()) .then(res => res.response.data) @@ -41,5 +42,6 @@ export const getTranslationTask = async ( locales, //since our download is tied to document id for smartling, keep track of it as a task taskId: documentId, + linkToVendorTask: `https://dashboard.smartling.com/app/projects/${projectId}/account-jobs/${projectId}:${taskId}`, } }