@@ -16,25 +16,28 @@ import client, {
16
16
INTERACTIVE_SESSIONS_OPEN_URL ,
17
17
USER_INFO_URL ,
18
18
USER_SIGNOUT_URL ,
19
+ USERS_SHARED_WITH_YOU_URL ,
20
+ USERS_YOU_SHARED_WITH_URL ,
19
21
WORKFLOW_FILES_URL ,
20
22
WORKFLOW_LOGS_URL ,
21
23
WORKFLOW_RETENTION_RULES_URL ,
22
24
WORKFLOW_SET_STATUS_URL ,
25
+ WORKFLOW_SHARE_STATUS_URL ,
23
26
WORKFLOW_SPECIFICATION_URL ,
24
27
} from "~/client" ;
25
- import {
26
- parseWorkflows ,
27
- parseWorkflowRetentionRules ,
28
- parseLogs ,
29
- parseFiles ,
30
- formatSearch ,
31
- } from "~/util" ;
32
28
import {
33
29
getConfig ,
34
30
getWorkflow ,
35
31
getWorkflowLogs ,
36
32
getWorkflowSpecification ,
37
33
} from "~/selectors" ;
34
+ import {
35
+ formatSearch ,
36
+ parseFiles ,
37
+ parseLogs ,
38
+ parseWorkflowRetentionRules ,
39
+ parseWorkflows ,
40
+ } from "~/util" ;
38
41
39
42
export const ERROR = "Error" ;
40
43
export const NOTIFICATION = "Notification" ;
@@ -96,26 +99,11 @@ export const WORKFLOW_SHARE_STATUS_FETCH = "Fetch workflow share status";
96
99
export const WORKFLOW_SHARE_STATUS_RECEIVED = "Workflow share status received" ;
97
100
export const WORKFLOW_SHARE_STATUS_FETCH_ERROR =
98
101
"Fetch workflow share status error" ;
99
- export const WORKFLOW_SHARE_INIT = "Initialise workflow sharing" ;
100
- export const WORKFLOW_SHARED_SUCCESSFULLY = "Workflow shared successfully" ;
101
- export const WORKFLOW_SHARED_ERROR = "Workflow shared error" ;
102
- export const WORKFLOW_SHARE_FINISH = "Finish workflow sharing" ;
103
- export const WORKFLOW_UNSHARE_INIT = "Initialise workflow unsharing" ;
104
- export const WORKFLOW_UNSHARED = "Workflow unshared" ;
105
- export const WORKFLOW_UNSHARE_ERROR = "Workflow unshare error" ;
106
-
107
- export const USERS_SHARED_WITH_YOU_FETCH =
108
- "Fetch users who shared workflows with you" ;
102
+
109
103
export const USERS_SHARED_WITH_YOU_RECEIVED =
110
104
"Users who shared workflows with you received" ;
111
- export const USERS_SHARED_WITH_YOU_FETCH_ERROR =
112
- "Fetch users who shared workflows with you error" ;
113
- export const USERS_YOU_SHARED_WITH_FETCH =
114
- "Fetch users you shared workflows with" ;
115
105
export const USERS_YOU_SHARED_WITH_RECEIVED =
116
106
"Users you shared workflows with received" ;
117
- export const USERS_YOU_SHARED_WITH_FETCH_ERROR =
118
- "Fetch users you shared workflows with error" ;
119
107
120
108
export function errorActionCreator ( error , name ) {
121
109
const { status, data } = error ?. response ;
@@ -288,12 +276,12 @@ export function fetchWorkflows({
288
276
pagination,
289
277
search,
290
278
status,
291
- ownedBy ,
279
+ sharedBy ,
292
280
sharedWith,
293
281
sort,
294
282
showLoader = true ,
295
283
workflowIdOrName,
296
- includeShared = false ,
284
+ shared = false ,
297
285
} ) {
298
286
return async ( dispatch ) => {
299
287
if ( showLoader ) {
@@ -305,20 +293,20 @@ export function fetchWorkflows({
305
293
pagination,
306
294
search : formatSearch ( search ) ,
307
295
status,
308
- ownedBy ,
296
+ sharedBy ,
309
297
sharedWith,
310
298
sort,
311
299
workflowIdOrName,
312
- includeShared ,
300
+ shared ,
313
301
} )
314
- . then ( ( resp ) => {
302
+ . then ( ( resp ) =>
315
303
dispatch ( {
316
304
type : WORKFLOWS_RECEIVED ,
317
305
workflows : parseWorkflows ( resp . data . items ) ,
318
306
total : resp . data . total ,
319
307
userHasWorkflows : resp . data . user_has_workflows ,
320
- } ) ;
321
- } )
308
+ } ) ,
309
+ )
322
310
. catch ( ( err ) => {
323
311
dispatch ( errorActionCreator ( err , USER_INFO_URL ) ) ;
324
312
dispatch ( { type : WORKFLOWS_FETCH_ERROR } ) ;
@@ -338,7 +326,7 @@ export function fetchWorkflow(id, { refetch = false, showLoader = true } = {}) {
338
326
fetchWorkflows ( {
339
327
workflowIdOrName : id ,
340
328
showLoader,
341
- includeShared : true ,
329
+ shared : true ,
342
330
} ) ,
343
331
) ;
344
332
}
@@ -567,38 +555,34 @@ export function closeShareWorkflowModal() {
567
555
568
556
export function fetchUsersSharedWithYou ( ) {
569
557
return async ( dispatch ) => {
570
- dispatch ( { type : USERS_SHARED_WITH_YOU_FETCH } ) ;
571
-
572
558
return await client
573
559
. getUsersSharedWithYou ( )
574
560
. then ( ( resp ) => {
575
561
dispatch ( {
576
562
type : USERS_SHARED_WITH_YOU_RECEIVED ,
577
- users_shared_with_you : resp . data . users_shared_with_you ,
563
+ usersSharedYouWith : resp . data . users_shared_with_you ,
578
564
} ) ;
579
565
return resp ;
580
566
} )
581
567
. catch ( ( err ) => {
582
- dispatch ( errorActionCreator ( err , USERS_SHARED_WITH_YOU_FETCH_ERROR ) ) ;
568
+ dispatch ( errorActionCreator ( err , USERS_SHARED_WITH_YOU_URL ) ) ;
583
569
} ) ;
584
570
} ;
585
571
}
586
572
587
573
export function fetchUsersYouSharedWith ( ) {
588
574
return async ( dispatch ) => {
589
- dispatch ( { type : USERS_YOU_SHARED_WITH_FETCH } ) ;
590
-
591
575
return await client
592
576
. getUsersYouSharedWith ( )
593
577
. then ( ( resp ) => {
594
578
dispatch ( {
595
579
type : USERS_YOU_SHARED_WITH_RECEIVED ,
596
- users_you_shared_with : resp . data . users_you_shared_with ,
580
+ usersYouSharedWith : resp . data . users_you_shared_with ,
597
581
} ) ;
598
582
return resp ;
599
583
} )
600
584
. catch ( ( err ) => {
601
- dispatch ( errorActionCreator ( err , USERS_YOU_SHARED_WITH_FETCH_ERROR ) ) ;
585
+ dispatch ( errorActionCreator ( err , USERS_YOU_SHARED_WITH_URL ) ) ;
602
586
} ) ;
603
587
} ;
604
588
}
@@ -609,83 +593,24 @@ export function fetchWorkflowShareStatus(id) {
609
593
return await client
610
594
. getWorkflowShareStatus ( id )
611
595
. then ( ( resp ) => {
596
+ // convert to camel-case
597
+ const sharedWith = [ ] ;
598
+ for ( const share of resp . data . shared_with ) {
599
+ sharedWith . push ( {
600
+ userEmail : share . user_email ,
601
+ validUntil : share . valid_until ,
602
+ } ) ;
603
+ }
612
604
dispatch ( {
613
605
type : WORKFLOW_SHARE_STATUS_RECEIVED ,
614
606
id,
615
- workflow_share_status : resp . data . shared_with ,
607
+ sharedWith ,
616
608
} ) ;
617
609
return resp ;
618
610
} )
619
611
. catch ( ( err ) => {
620
- dispatch ( errorActionCreator ( err , WORKFLOW_SHARE_STATUS_FETCH_ERROR ) ) ;
621
- } ) ;
622
- } ;
623
- }
624
-
625
- export function shareWorkflow (
626
- id ,
627
- user_id ,
628
- user_emails_to_share_with ,
629
- valid_until ,
630
- ) {
631
- return async ( dispatch ) => {
632
- dispatch ( { type : WORKFLOW_SHARE_INIT } ) ;
633
-
634
- const users_shared_with = [ ] ;
635
- const users_not_shared_with = [ ] ;
636
-
637
- for ( const user_email_to_share_with of user_emails_to_share_with ) {
638
- await client
639
- . shareWorkflow ( id , {
640
- user_id,
641
- user_email_to_share_with,
642
- valid_until,
643
- } )
644
- . then ( ( ) => {
645
- users_shared_with . push ( user_email_to_share_with ) ;
646
- } )
647
- . catch ( ( err ) => {
648
- const error_message = err . response . data . message ;
649
- users_not_shared_with . push ( {
650
- user_email_to_share_with,
651
- error_message,
652
- } ) ;
653
- } ) ;
654
-
655
- if ( users_shared_with . length > 0 ) {
656
- dispatch ( {
657
- type : WORKFLOW_SHARED_SUCCESSFULLY ,
658
- users_shared_with,
659
- } ) ;
660
- }
661
-
662
- if ( users_not_shared_with . length > 0 ) {
663
- dispatch ( {
664
- type : WORKFLOW_SHARED_ERROR ,
665
- users_not_shared_with,
666
- } ) ;
667
- }
668
- }
669
-
670
- dispatch ( { type : WORKFLOW_SHARE_FINISH } ) ;
671
- } ;
672
- }
673
-
674
- export function unshareWorkflow ( id , user_id , user_email_to_unshare_with ) {
675
- return async ( dispatch ) => {
676
- dispatch ( { type : WORKFLOW_UNSHARE_INIT } ) ;
677
-
678
- return await client
679
- . unshareWorkflow ( id , {
680
- user_id,
681
- user_email_to_unshare_with,
682
- } )
683
- . then ( ( ) => {
684
- dispatch ( { type : WORKFLOW_UNSHARED , user_email_to_unshare_with } ) ;
685
- } )
686
- . catch ( ( err ) => {
687
- const error_message = err . response . data . message ;
688
- dispatch ( { type : WORKFLOW_UNSHARE_ERROR , error_message } ) ;
612
+ dispatch ( { type : WORKFLOW_SHARE_STATUS_FETCH_ERROR } ) ;
613
+ dispatch ( errorActionCreator ( err , WORKFLOW_SHARE_STATUS_URL ( id ) ) ) ;
689
614
} ) ;
690
615
} ;
691
616
}
0 commit comments