Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add callback url #38

Merged
merged 8 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}