Skip to content

Commit

Permalink
set timeline status to draft if created by saving notes
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc committed Oct 1, 2020
1 parent 21fcf02 commit dc635b7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { noteSavedObjectType } from './saved_object_mappings';
import { pickSavedTimeline } from '../timeline/pick_saved_timeline';
import { convertSavedObjectToSavedTimeline } from '../timeline/convert_saved_object_to_savedtimeline';
import { timelineSavedObjectType } from '../timeline/saved_object_mappings';
import { TimelineStatus } from '../../../common/types/timeline';

export interface Note {
deleteNote: (request: FrameworkRequest, noteIds: string[]) => Promise<void>;
Expand Down Expand Up @@ -149,10 +148,10 @@ export const persistNote = async (
note.timelineId == null
? await (async () => {
const timelineResult = convertSavedObjectToSavedTimeline(
await savedObjectsClient.create(timelineSavedObjectType, {
...pickSavedTimeline(null, {}, request.user),
status: TimelineStatus.draft,
})
await savedObjectsClient.create(
timelineSavedObjectType,
pickSavedTimeline(null, {}, request.user)
)
);
note.timelineId = timelineResult.savedObjectId;
return timelineResult.version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const pickSavedTimeline = (
savedTimeline.updatedBy = userInfo?.username ?? UNAUTHENTICATED_USER;
}

if (savedTimeline.status === TimelineStatus.draft) {
if (savedTimeline.status === TimelineStatus.draft || savedTimeline.status == null) {
savedTimeline.status = !isEmpty(savedTimeline.title)
? TimelineStatus.active
: TimelineStatus.draft;
Expand Down

0 comments on commit dc635b7

Please sign in to comment.