Skip to content

Commit

Permalink
feat: add callback url (#38)
Browse files Browse the repository at this point in the history
* feat: add callback param option for plugin

* fix: export serialized doc type
---------

Co-authored-by: arthurpereira <[email protected]>
  • Loading branch information
cngonzalez and arthur-pinner authored Nov 6, 2023
1 parent 1f66661 commit f0fbdd9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sanity-translations-tab",
"version": "4.1.0",
"version": "4.2.0",
"description": "This is the base module for implementing common translation vendor tasks from a Studio, such as sending content to be translated in some specific languages, importing content back etc. Not useful on its own, but vendor-specific plugins will use this for its chrome.",
"keywords": [
"sanity",
Expand Down
3 changes: 1 addition & 2 deletions src/components/NewTask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ const LocaleCheckbox = ({locale, toggle, checked}: LocaleCheckboxProps) => {
style={{pointerEvents: `none`}}
disabled={locale.enabled === false}
checked={checked}
//eslint-disable-next-line @typescript-eslint/no-empty-function
onChange={() => {}} // noop
/>
<WrapText>
<Text size={1} weight="semibold">
Expand Down Expand Up @@ -91,6 +89,7 @@ export const NewTask = ({locales, refreshTask}: Props) => {
selectedLocales as string[],
context.secrets,
selectedWorkflowUid,
context.callbackUrl,
),
)
.then(() => {
Expand Down
1 change: 1 addition & 0 deletions src/components/TranslationContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type ContextProps = {
secrets: Secrets
workflowOptions?: WorkflowIdentifiers[]
localeIdAdapter?: (id: string) => string | Promise<string>
callbackUrl?: string
}

export const TranslationContext = React.createContext<ContextProps | null>(null)
1 change: 1 addition & 0 deletions src/components/TranslationsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const TranslationTab = (props: TranslationTabProps) => {
baseLanguage: props.options.baseLanguage,
workflowOptions: props.options.workflowOptions,
localeIdAdapter: props.options.localeIdAdapter,
callbackUrl: props.options.callbackUrl,
}}
>
<TranslationView />
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
BaseDocumentMerger,
defaultStopTypes,
customSerializers,
SerializedDocument,
} from 'sanity-naive-html-serializer'

export type {
Expand All @@ -32,6 +33,7 @@ export type {
ImportTranslation,
TranslationFunctionContext,
TranslationsTabConfigOptions,
SerializedDocument,
}
export {
TranslationsTab,
Expand Down
4 changes: 3 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ export interface Adapter {
getTranslationTask: (documentId: string, secrets: Secrets | null) => Promise<TranslationTask>
createTask: (
taskName: string,
document: Record<string, any>,
serializedDocument: SerializedDocument,
localeIds: string[],
secrets: Secrets | null,
workflowUid?: string,
callbackUrl?: string,
) => Promise<TranslationTask>
getTranslation: (taskid: string, localeId: string, secrets: Secrets | null) => Promise<any | null>
}
Expand Down Expand Up @@ -95,4 +96,5 @@ export type TranslationsTabConfigOptions = {
workflowOptions?: WorkflowIdentifiers[]
localeIdAdapter?: (id: string) => string
languageField?: string
callbackUrl?: string
}

0 comments on commit f0fbdd9

Please sign in to comment.