Skip to content

Commit

Permalink
fix: Add itemType as part of defaultDraftData when importing insight
Browse files Browse the repository at this point in the history
  • Loading branch information
lvillalobos authored and LulaV14 committed Oct 27, 2022
1 parent 6803563 commit 676459b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/backend/src/controllers/import.v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export const importToDraft = async (req: Request, res: Response): Promise<void>
title: req.body.title,
url: req.body.url,
contents: req.body.contents,
format: req.body.format
format: req.body.format,
itemType: req.body.itemType
});

res.send({
Expand Down
5 changes: 4 additions & 1 deletion packages/backend/src/lib/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import { InsightFileAction } from '@iex/models/insight-file-action';
import { ItemType } from '@iex/models/item-type';
import { getLogger } from '@iex/shared/logger';
import isArray from 'lodash/isArray';
import mergeWith from 'lodash/mergeWith';
Expand All @@ -37,6 +38,7 @@ export interface ImportRequest {
url: string;
contents: string;
format?: ImportFormat;
itemType?: ItemType;
htmlElement?: HTMLElement;
}

Expand Down Expand Up @@ -168,7 +170,8 @@ export function convertToDraft(request: ImportRequest): DraftDataInput {
importedFrom: request.url
},
commitMessage: 'Imported from ' + request.url,
initializedTemplate: true
initializedTemplate: true,
itemType: request.itemType || ItemType.INSIGHT
};

// Merge converted draft contents with the default metadata
Expand Down

0 comments on commit 676459b

Please sign in to comment.