Skip to content

Commit

Permalink
Google setup script asks about setting a template.
Browse files Browse the repository at this point in the history
The Google integration setup script now prompts the user, asking if they'd like
to set a template for the integration.

Response to kevinschaich#162
  • Loading branch information
jsharf committed Aug 8, 2023
1 parent 6d6c425 commit c4e3363
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/integrations/google/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ export default async () => {
message:
'Document ID (From the sheet you just created: https://docs.google.com/spreadsheets/d/DOCUMENT_ID/edit)',
validate: (s: string) => (s.length >= 8 ? true : 'Must be at least 8 characters in length.')
},
{
type: 'confirm',
name: 'useTemplate',
message: 'Do you want to setup a template for your Google Sheet?',
},
{
type: prev => (prev ? 'text' : null),
name: 'templateDocumentId',
message: 'Template Document ID (From the URL of the document: https://docs.google.com/spreadsheets/d/DOCUMENT_ID/edit)',
validate: (s: string) => (s.length >= 8 ? true : 'Must be at least 8 characters in length.')
},
{
// The previous value is either "useTemplate" (false) or "templateDocumentId" (true). If it's false, we don't want to ask this question.
type: prev => (prev ? 'text' : null),
name: 'templateSheetTitle',
message: 'Template Sheet Title (The name of the sheet in the template document)',
validate: (s: string) => (s.length >= 1 ? true : 'Must be at least 1 character in length.')
}
])

Expand All @@ -54,6 +72,12 @@ export default async () => {
googleConfig.documentId = credentials.documentId
googleConfig.credentials.clientId = credentials.clientId
googleConfig.credentials.clientSecret = credentials.clientSecret
if (credentials.useTemplate) {
googleConfig.template = {
documentId: credentials.templateDocumentId,
sheetTitle: credentials.templateSheetTitle
}
}

config.integrations[IntegrationId.Google] = googleConfig

Expand Down

0 comments on commit c4e3363

Please sign in to comment.