Skip to content

Commit

Permalink
lukasoppermann#181: Added Content Type setting to URLExport flow.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgmartin committed Feb 23, 2022
1 parent c47a914 commit 095b27c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
.DS_Store
tests/amazon-style-dictionary/build
tests/unit/coverage
_resources/_notSynced.md
_resources/_notSynced.md
.idea
13 changes: 13 additions & 0 deletions src/ui/components/UrlExportSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const UrlExportSettings = () => {
url: settings.serverUrl,
accessToken: settings.accessToken,
acceptHeader: settings.acceptHeader,
contentType: settings.contentType,
authType: settings.authType
} as urlExportSettings,
{
Expand Down Expand Up @@ -124,6 +125,18 @@ export const UrlExportSettings = () => {
/>
</Row>

<h3>Content-Type header</h3>
<Row fill>
<Input
type='text'
required
pattern='\S+'
placeholder='text/plain;charset=UTF-8'
value={settings.contentType}
onChange={value => updateSettings(draft => { draft.contentType = value })}
/>
</Row>

<h3>Auth type</h3>
<Row fill>
<Select
Expand Down
2 changes: 2 additions & 0 deletions src/ui/modules/urlExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const urlExport = (parent, exportSettings: urlExportSettings, requestBody: urlEx
request.open('POST', exportSettings.url)
// set request header if provided
request.setRequestHeader('Accept', exportSettings.acceptHeader || 'application/vnd.github.everest-preview+json')
// set Content-Type header if provided
request.setRequestHeader('Content-Type', exportSettings.contentType || 'text/plain;charset=UTF-8')
// add access token of provided
if (exportSettings.accessToken !== '' && exportSettings.authType !== '') {
request.setRequestHeader('Authorization', `${exportSettings.authType} ${exportSettings.accessToken}`)
Expand Down
1 change: 1 addition & 0 deletions types/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type Settings = {
eventType: string,
accessToken?: string,
acceptHeader?: string,
contentType?: string,
exclusionPrefix: string,
alias: string,
authType: string,
Expand Down
3 changes: 2 additions & 1 deletion types/urlExportData.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ export type urlExportSettings = {
url: string,
accessToken: string,
acceptHeader: string,
authType: string
authType: string,
contentType: string
}

export type urlExportRequestBody = {
Expand Down

0 comments on commit 095b27c

Please sign in to comment.