-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.22.12.24.patch
executable file
·1773 lines (1706 loc) · 57.6 KB
/
update.22.12.24.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/canvas/app/dashboard/project/all/components/create-project/form.tsx b/canvas/app/dashboard/project/all/components/create-project/form.tsx
index ba23333..a97ab66 100644
--- a/canvas/app/dashboard/project/all/components/create-project/form.tsx
+++ b/canvas/app/dashboard/project/all/components/create-project/form.tsx
@@ -26,10 +26,10 @@ export function CreateProjectForm(props: TCreateProjectFormProps) {
});
const [parsers, types] = useMemo(() => {
- if (!data || !data.response || !data.ok) return [[], []];
+ if (!data) return [[], []];
- const _parsers = data.response[0];
- const _types = data.response[1];
+ const _parsers = data[0];
+ const _types = data[1];
const mapFn = (d: string) => ({ label: d, value: d });
diff --git a/canvas/app/dashboard/project/all/view/index.tsx b/canvas/app/dashboard/project/all/view/index.tsx
index 7c11e5f..cf60eb2 100644
--- a/canvas/app/dashboard/project/all/view/index.tsx
+++ b/canvas/app/dashboard/project/all/view/index.tsx
@@ -10,7 +10,7 @@ export function AllProjectsView() {
const { data, error } = useGetProjects();
const { push } = useRouter();
- if (!data || !data.ok || !Array.isArray(data.response) || error) {
+ if (!data || error) {
return (
<ContainerWithTextCenter>
We're experiencing a temporary issue. Please try again shortly.
@@ -18,7 +18,7 @@ export function AllProjectsView() {
);
}
- if (data.response.length === 0) {
+ if (data.length === 0) {
return (
<ContainerWithTextCenter>
You don't have any project yet! <br />
@@ -30,7 +30,7 @@ export function AllProjectsView() {
return (
<AllProjectsContainer>
- {data.response.map(({ id, name, description, img_uri }) => (
+ {data.map(({ id, name, description, img_uri }) => (
<Card
key={id}
img={{
diff --git a/canvas/app/dashboard/project/id/[id]/model.tsx b/canvas/app/dashboard/project/id/[id]/model.tsx
index 77a5af2..1422cec 100644
--- a/canvas/app/dashboard/project/id/[id]/model.tsx
+++ b/canvas/app/dashboard/project/id/[id]/model.tsx
@@ -11,21 +11,17 @@ export type TProjectModelProps = {
export function ProjectModel(props: TProjectModelProps) {
const { projectId } = props;
- const {
- data: project,
- error: projectError,
- isLoading: isProjectLoading,
- } = useGetProject({
+ const { data, error, isLoading } = useGetProject({
id: projectId,
});
- if (isProjectLoading) {
+ if (isLoading) {
return <ProjectSkeleton />;
}
- if (projectError || !project || !project.response) {
+ if (error || !data) {
return <ProjectError />;
}
- return <ProjectView project={project.response} />;
+ return <ProjectView project={data} />;
}
diff --git a/canvas/app/dashboard/project/id/[id]/view/heading/actions.tsx b/canvas/app/dashboard/project/id/[id]/view/heading/actions.tsx
index 0b84365..1e791d2 100644
--- a/canvas/app/dashboard/project/id/[id]/view/heading/actions.tsx
+++ b/canvas/app/dashboard/project/id/[id]/view/heading/actions.tsx
@@ -7,7 +7,7 @@ export function ProjectActions() {
return (
<ActionContainer>
<TakeCredentials />
- <Button>
+ <Button className="md:w-40">
<PlayIcon /> Run project
</Button>
</ActionContainer>
diff --git a/canvas/app/dashboard/project/id/[id]/view/heading/take-credentials.tsx b/canvas/app/dashboard/project/id/[id]/view/heading/take-credentials.tsx
index cb737b6..2bbce97 100644
--- a/canvas/app/dashboard/project/id/[id]/view/heading/take-credentials.tsx
+++ b/canvas/app/dashboard/project/id/[id]/view/heading/take-credentials.tsx
@@ -22,6 +22,7 @@ export function TakeCredentials() {
<ButtonWithTooltip
message="Add or update AWS Credentials"
variant="outline"
+ className="md:w-40"
>
<Settings className="mr-2 h-4 w-4" />
Credentials
diff --git a/canvas/app/dashboard/project/id/[id]/view/hooks/useParsePathRecordToArray.ts b/canvas/app/dashboard/project/id/[id]/view/hooks/useParsePathRecordToArray.ts
new file mode 100644
index 0000000..34ddceb
--- /dev/null
+++ b/canvas/app/dashboard/project/id/[id]/view/hooks/useParsePathRecordToArray.ts
@@ -0,0 +1,54 @@
+import { TJob } from "@/services/job";
+import { useProjectStore } from "@/stores/project";
+import React from "react";
+
+export type TUseParsePathRecordToArrayOptions<
+ T extends Record<string, string>
+> = {
+ obj: Record<string, T>;
+ /**
+ * @default "type"
+ */
+ typeKey?: string;
+ /**
+ * @default "value"
+ */
+ valueKey?: string;
+};
+
+export type TPathRecord = {
+ id: string;
+ name: string;
+ type: string;
+ value: string;
+};
+export type TUseParsePathRecordToArrayReturn = TPathRecord[];
+
+export function useParsePathRecordToArray<T extends Record<string, string>>(
+ options: TUseParsePathRecordToArrayOptions<T>
+): TUseParsePathRecordToArrayReturn {
+ const { obj, typeKey = "type", valueKey = "value" } = options;
+ const { projectWorkspaceURI } = useProjectStore((state) => ({
+ projectWorkspaceURI: state.project.workspace_uri,
+ }));
+
+ return React.useMemo((): TUseParsePathRecordToArrayReturn => {
+ if (!obj) return [];
+
+ const out = [] as TUseParsePathRecordToArrayReturn;
+
+ for (const [k, v] of Object.entries(obj)) {
+ const type = v[typeKey];
+ const value = v[valueKey] || projectWorkspaceURI;
+
+ out.push({
+ id: k,
+ name: k,
+ type,
+ value,
+ });
+ }
+
+ return out;
+ }, [obj, projectWorkspaceURI, typeKey, valueKey]);
+}
diff --git a/canvas/app/dashboard/project/id/[id]/view/jobs/index.tsx b/canvas/app/dashboard/project/id/[id]/view/jobs/index.tsx
index f7772be..045580a 100644
--- a/canvas/app/dashboard/project/id/[id]/view/jobs/index.tsx
+++ b/canvas/app/dashboard/project/id/[id]/view/jobs/index.tsx
@@ -17,7 +17,7 @@ export function ProjectJobs() {
return <JobsSkeleton />;
}
- if (error || !data || !data.ok || !data.response) {
+ if (error || !data) {
return (
<div className="p-4 flex-col flex justify-center items-center text-red-500 md:pr-0 md:col-span-9 md:border-l md:border-l-slate-100">
<p>
@@ -41,7 +41,7 @@ export function ProjectJobs() {
return (
<div className="p-4 md:pr-0 md:col-span-9 md:border-l md:border-l-slate-100">
- <ProjectJobsView step={currentStep} jobs={data.response} />
+ <ProjectJobsView step={currentStep} jobs={data} />
</div>
);
}
diff --git a/canvas/app/dashboard/project/id/[id]/view/jobs/job-input-edit.tsx b/canvas/app/dashboard/project/id/[id]/view/jobs/job-input-edit.tsx
index dab5443..3d448d6 100644
--- a/canvas/app/dashboard/project/id/[id]/view/jobs/job-input-edit.tsx
+++ b/canvas/app/dashboard/project/id/[id]/view/jobs/job-input-edit.tsx
@@ -1,10 +1,9 @@
-import { TUseParseJobInput } from "./useParseJobInput";
import React from "react";
-import { Input } from "@/components/ui/input";
import { ActionButton } from "@/components/custom/action-button";
import { Check, XIcon } from "lucide-react";
import { JobInputUploadFile } from "./job-input-upload-file";
import { ProjectJobInputEditWarningModal } from "./job-input-edit-warning-modal";
+import { PathFieldWithAction } from "@/components/custom/path-filed-with-actions";
export type TProjectJobInputProps = {
inputPath: string;
@@ -47,34 +46,52 @@ export function ProjectJobInputEdit(props: TProjectJobInputProps) {
return (
<>
- <div className="px-1.5 py-2 bg-accent text-accent-foreground rounded-md">
- {inputName}
- </div>
- <Input
- className="border-none shadow-transparent flex-1"
- autoFocus
- value={inputPath}
- onChange={(e) => onInputPathChange(e.currentTarget.value)}
+ <PathFieldWithAction
+ pathRecord={{
+ id: inputPath,
+ name: inputName,
+ type: "path",
+ value: inputPath,
+ }}
+ inputProps={{
+ onChange: (e) => onInputPathChange(e.currentTarget.value),
+ autoFocus: true,
+ }}
+ actions={[
+ {
+ id: "upload-file",
+ children: (
+ <JobInputUploadFile
+ inputFile={inputFile}
+ updateInputFile={setInputFile}
+ />
+ ),
+ },
+ {
+ id: "close-editing-mode",
+ children: (
+ <ActionButton
+ icon={<XIcon />}
+ message="Close editing mode"
+ className="text-yellow-600 hover:bg-yellow-50 hover:text-yellow-600"
+ onClick={handleOnCloseEditingModeClick}
+ />
+ ),
+ },
+ {
+ id: "save-changes",
+ children: (
+ <ActionButton
+ onClick={onRequestView}
+ icon={<Check />}
+ message="Save changes"
+ key="save-changes"
+ />
+ ),
+ },
+ ]}
/>
- <JobInputUploadFile
- inputFile={inputFile}
- updateInputFile={setInputFile}
- />
- <div className="w-[1px] h-5 border-r border-r-gray-200" />
- <ActionButton
- icon={<XIcon />}
- message="Close editing mode"
- className="text-yellow-600 hover:bg-yellow-50 hover:text-yellow-600"
- onClick={handleOnCloseEditingModeClick}
- />
- <div className="w-[1px] h-5 border-r border-r-gray-200" />
- <ActionButton
- onClick={onRequestView}
- icon={<Check />}
- message="Save changes"
- key="save-changes"
- />
<ProjectJobInputEditWarningModal
primaryActionCallback={handleOnWarningModalPrimaryActionClick}
isOpen={isWarningModalOpen}
diff --git a/canvas/app/dashboard/project/id/[id]/view/jobs/job-input-view.tsx b/canvas/app/dashboard/project/id/[id]/view/jobs/job-input-view.tsx
index 3253536..d069fa5 100644
--- a/canvas/app/dashboard/project/id/[id]/view/jobs/job-input-view.tsx
+++ b/canvas/app/dashboard/project/id/[id]/view/jobs/job-input-view.tsx
@@ -1,7 +1,8 @@
import React from "react";
-import { ViewJobInput } from "./view-input";
import { ActionButton } from "@/components/custom/action-button";
import { Pencil } from "lucide-react";
+import { PathFieldWithAction } from "@/components/custom/path-filed-with-actions";
+import { ViewFile } from "@/components/custom/view-file";
export type TProjectJobInputProps = {
inputPath: string;
@@ -13,24 +14,39 @@ export function ProjectJobInputView(props: TProjectJobInputProps) {
const { inputPath, inputName, onRequestEditing } = props;
return (
- <>
- <div className="px-1.5 py-2 bg-accent text-accent-foreground rounded-md">
- {inputName}
- </div>
- <span
- onDoubleClick={onRequestEditing}
- className="flex-1 overflow-hidden whitespace-nowrap text-ellipsis text-gray-400"
- >
- {inputPath}
- </span>
- <ViewJobInput />
- <div className="w-[1px] h-5 border-r border-r-gray-200" />
- <ActionButton
- icon={<Pencil />}
- message="Edit input file"
- onClick={onRequestEditing}
- key="edit-input"
- />
- </>
+ <PathFieldWithAction
+ pathRecord={{
+ id: inputPath,
+ name: inputName,
+ type: "path",
+ value: inputPath,
+ }}
+ isReadonly
+ spanProp={{
+ onDoubleClick: onRequestEditing,
+ }}
+ actions={[
+ {
+ id: "view-job-input",
+ children: (
+ <ViewFile
+ key="view-job-input"
+ defaultTriggerProps={{ message: "View input file." }}
+ />
+ ),
+ },
+ {
+ id: "edit-job-input",
+ children: (
+ <ActionButton
+ icon={<Pencil />}
+ message="Edit input file"
+ onClick={onRequestEditing}
+ key="edit-input"
+ />
+ ),
+ },
+ ]}
+ />
);
}
diff --git a/canvas/app/dashboard/project/id/[id]/view/jobs/job-input.tsx b/canvas/app/dashboard/project/id/[id]/view/jobs/job-input.tsx
index 32b648f..72ea760 100644
--- a/canvas/app/dashboard/project/id/[id]/view/jobs/job-input.tsx
+++ b/canvas/app/dashboard/project/id/[id]/view/jobs/job-input.tsx
@@ -1,10 +1,10 @@
-import { TUseParseJobInput } from "./useParseJobInput";
import React from "react";
import { ProjectJobInputView } from "./job-input-view";
import { ProjectJobInputEdit } from "./job-input-edit";
+import { TPathRecord } from "../hooks/useParsePathRecordToArray";
export type TProjectJobInputProps = {
- input: TUseParseJobInput;
+ input: TPathRecord;
};
export function ProjectJobInput(props: TProjectJobInputProps) {
@@ -21,10 +21,7 @@ export function ProjectJobInput(props: TProjectJobInputProps) {
}, []);
return (
- <li
- key={input.id}
- className="flex items-center text-sm border border-gray-200 rounded-md space-x-1"
- >
+ <>
{isEditing ? (
<ProjectJobInputEdit
inputName={input.name}
@@ -39,6 +36,6 @@ export function ProjectJobInput(props: TProjectJobInputProps) {
inputPath={inputPath}
/>
)}
- </li>
+ </>
);
}
diff --git a/canvas/app/dashboard/project/id/[id]/view/jobs/job-inputs.tsx b/canvas/app/dashboard/project/id/[id]/view/jobs/job-inputs.tsx
index cd86ba0..34e33b2 100644
--- a/canvas/app/dashboard/project/id/[id]/view/jobs/job-inputs.tsx
+++ b/canvas/app/dashboard/project/id/[id]/view/jobs/job-inputs.tsx
@@ -1,5 +1,5 @@
import { TJob } from "@/services/job";
-import { useParseJobInput } from "./useParseJobInput";
+import { useParsePathRecordToArray } from "../hooks/useParsePathRecordToArray";
import React from "react";
import { ProjectJobInput } from "./job-input";
@@ -9,7 +9,7 @@ export type TProjectJobInputsProps = {
export function ProjectJobInputs(props: TProjectJobInputsProps) {
const { job } = props;
- const { inputs } = useParseJobInput({ job });
+ const inputs = useParsePathRecordToArray({ obj: job.inputs });
return (
<div className="flex-1">
@@ -17,11 +17,11 @@ export function ProjectJobInputs(props: TProjectJobInputsProps) {
{inputs.length === 0 && (
<p className="text-sm text-gray-400 my-2">This job has no input</p>
)}
- <ul className="space-y-2 my-2">
+ <div className="space-y-2 my-2">
{inputs.map((input) => (
<ProjectJobInput input={input} key={input.id} />
))}
- </ul>
+ </div>
</div>
);
}
diff --git a/canvas/app/dashboard/project/id/[id]/view/jobs/useParseJobInput.ts b/canvas/app/dashboard/project/id/[id]/view/jobs/useParseJobInput.ts
deleted file mode 100644
index 169ecdd..0000000
--- a/canvas/app/dashboard/project/id/[id]/view/jobs/useParseJobInput.ts
+++ /dev/null
@@ -1,68 +0,0 @@
-import { TJob } from "@/services/job";
-import { useProjectStore } from "@/stores/project";
-import React from "react";
-
-export type TUseParseJobInputOptions = {
- job: TJob;
-};
-
-export type TUseParseJobInput = {
- id: string;
- /**
- * Name of the input
- */
- name: string;
- /**
- * Type of input.
- */
- type: "path";
- /**
- * Full path.
- */
- value: string;
- /**
- * Workspace path.
- */
- workspaceURI: string;
- /**
- * Sub path.
- */
- subPath: string;
-};
-
-export type TUseParseJobInputReturn = {
- inputs: TUseParseJobInput[];
-};
-
-export function useParseJobInput(
- options: TUseParseJobInputOptions
-): TUseParseJobInputReturn {
- const { job } = options;
- const { projectWorkspaceURI } = useProjectStore((state) => ({
- projectWorkspaceURI: state.project.workspace_uri,
- }));
-
- const inputs = React.useMemo((): TUseParseJobInput[] => {
- const _inputs = [] as TUseParseJobInput[];
-
- for (const [key, value] of Object.entries(job.inputs)) {
- const workspaceURI = projectWorkspaceURI.replace(/\/$/, ""); // Remove trailing slash.
- const subPath = value.value.replace(/\/$/, "").replace(workspaceURI, "");
-
- _inputs.push({
- id: key,
- name: key,
- type: value.type as "path",
- workspaceURI,
- subPath,
- value: `${workspaceURI}${subPath}`,
- });
- }
-
- return _inputs;
- }, [job, projectWorkspaceURI]);
-
- return {
- inputs,
- };
-}
diff --git a/canvas/app/dashboard/project/id/[id]/view/jobs/view-input.tsx b/canvas/app/dashboard/project/id/[id]/view/jobs/view-input.tsx
deleted file mode 100644
index e230cd5..0000000
--- a/canvas/app/dashboard/project/id/[id]/view/jobs/view-input.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import { ButtonWithTooltip } from "@/components/custom/button-with-tooltip";
-import { Eye } from "lucide-react";
-
-export function ViewJobInput() {
- // TODO: Implement View job input.
- return (
- <ButtonWithTooltip
- variant="ghost"
- size="icon"
- message="View input file"
- onClick={() => console.log("Not Implemented!")}
- >
- <Eye className="h-2 w-2" />
- </ButtonWithTooltip>
- );
-}
diff --git a/canvas/app/dashboard/project/id/[id]/view/jobs/view.tsx b/canvas/app/dashboard/project/id/[id]/view/jobs/view.tsx
index e933900..4bb13b1 100644
--- a/canvas/app/dashboard/project/id/[id]/view/jobs/view.tsx
+++ b/canvas/app/dashboard/project/id/[id]/view/jobs/view.tsx
@@ -14,7 +14,7 @@ export function ProjectJobsView(props: TProjectJobsViewProps) {
<div>
<h4 className="font-bold text-xl mb-2">{step.name}</h4>
{step.description && <p className="mb-2">{step.description}</p>}
- <div className="grid grid-cols-1 gap-4 md:grid-cols-2 pt-4">
+ <div className="grid grid-cols-1 gap-4 pt-4 lg:grid-cols-2">
{jobs.map((job) => (
<ProjectJob job={job} key={job.id} />
))}
diff --git a/canvas/app/dashboard/project/id/[id]/badge.tsx b/canvas/app/dashboard/project/id/[id]/view/runs/badge.tsx
similarity index 55%
rename from canvas/app/dashboard/project/id/[id]/badge.tsx
rename to canvas/app/dashboard/project/id/[id]/view/runs/badge.tsx
index e8d38f1..92892af 100644
--- a/canvas/app/dashboard/project/id/[id]/badge.tsx
+++ b/canvas/app/dashboard/project/id/[id]/view/runs/badge.tsx
@@ -1,20 +1,20 @@
import { Badge } from "@/components/ui/badge";
-export type TJobBadgeProps = {
+export type TProjectRunBadge = {
status: string;
};
-export function JobBadge(props: TJobBadgeProps) {
+export function ProjectRunBadge(props: TProjectRunBadge) {
const { status } = props;
if (status === "pending") {
- return <Badge variant="outline">Pending</Badge>;
+ return <Badge variant="default">Pending</Badge>;
}
if (status === "running") {
- return <Badge variant="secondary">Running</Badge>;
+ return <Badge variant="info">Running</Badge>;
}
if (status === "success") {
- return <Badge variant="default">Success</Badge>;
+ return <Badge variant="success">Success</Badge>;
}
if (status === "failed") {
return <Badge variant="destructive">Failed</Badge>;
diff --git a/canvas/app/dashboard/project/id/[id]/view/runs/index.tsx b/canvas/app/dashboard/project/id/[id]/view/runs/index.tsx
index 774987e..f02490a 100644
--- a/canvas/app/dashboard/project/id/[id]/view/runs/index.tsx
+++ b/canvas/app/dashboard/project/id/[id]/view/runs/index.tsx
@@ -15,7 +15,7 @@ export function ProjectRuns(props: TProjectRunProps) {
return <p>Loading...</p>;
}
- if (error || !data || !data.response) {
+ if (error || !data) {
return (
<p className="text-red-500 text-sm">Failed to load job‘s run </p>
);
@@ -24,16 +24,20 @@ export function ProjectRuns(props: TProjectRunProps) {
return (
<div className="h-96 overflow-auto">
<h5 className="font-bold mb-1">Runs</h5>
- {data.response.length === 0 && (
+ {data.length === 0 && (
<div className="text-sm text-gray-400">
Click the play button (<PlayIcon className="h-4 w-4 inline-flex" />)
to run this job. Once started, a Run will be displayed here.
</div>
)}
- {data.response.map((run) => (
- <ProjectRun key={run.id} run={run} />
- ))}
+ <ul className="space-y-3 mt-2">
+ {data.map((run) => (
+ <li key={run.id}>
+ <ProjectRun run={run} />
+ </li>
+ ))}
+ </ul>
</div>
);
}
diff --git a/canvas/app/dashboard/project/id/[id]/view/runs/run-paths-popover.tsx b/canvas/app/dashboard/project/id/[id]/view/runs/run-paths-popover.tsx
new file mode 100644
index 0000000..106177b
--- /dev/null
+++ b/canvas/app/dashboard/project/id/[id]/view/runs/run-paths-popover.tsx
@@ -0,0 +1,68 @@
+import {
+ Popover,
+ PopoverTrigger,
+ PopoverContent,
+} from "@/components/ui/popover";
+import { TPathRecord } from "../hooks/useParsePathRecordToArray";
+import React from "react";
+import { PathFieldWithAction } from "@/components/custom/path-filed-with-actions";
+import { ViewFile } from "@/components/custom/view-file";
+import {
+ ButtonWithTooltip,
+ TButtonWithTooltipProps,
+} from "@/components/custom/button-with-tooltip";
+
+export type TRunPathsPopoverProps = {
+ paths: TPathRecord[];
+ title: string;
+ triggerProps: TButtonWithTooltipProps;
+ noPathsMessage: string;
+ viewActionTooltipMessage: string;
+};
+
+export function RunPathsPopover(props: TRunPathsPopoverProps) {
+ const {
+ paths,
+ title,
+ noPathsMessage,
+ triggerProps,
+ viewActionTooltipMessage,
+ } = props;
+
+ return (
+ <>
+ <Popover>
+ <PopoverTrigger asChild>
+ <ButtonWithTooltip variant="ghost" size="icon" {...triggerProps} />
+ </PopoverTrigger>
+ <PopoverContent className="text-sm w-96">
+ <div className="font-bold mb-2">{title}</div>
+ {paths.length === 0 && (
+ <p className="text-gray-400">{noPathsMessage}</p>
+ )}
+ <div className="space-y-2 my-2">
+ {paths.map((path) => (
+ <PathFieldWithAction
+ pathRecord={path}
+ isReadonly
+ key={path.id}
+ actions={[
+ {
+ id: "view-input",
+ children: (
+ <ViewFile
+ defaultTriggerProps={{
+ message: viewActionTooltipMessage,
+ }}
+ />
+ ),
+ },
+ ]}
+ />
+ ))}
+ </div>
+ </PopoverContent>
+ </Popover>
+ </>
+ );
+}
diff --git a/canvas/app/dashboard/project/id/[id]/view/runs/run.tsx b/canvas/app/dashboard/project/id/[id]/view/runs/run.tsx
index d189048..f831b53 100644
--- a/canvas/app/dashboard/project/id/[id]/view/runs/run.tsx
+++ b/canvas/app/dashboard/project/id/[id]/view/runs/run.tsx
@@ -1,4 +1,9 @@
import { TRun } from "@/services/run";
+import { ProjectRunBadge } from "./badge";
+import { RunPathsPopover } from "./run-paths-popover";
+import { useParsePathRecordToArray } from "../hooks/useParsePathRecordToArray";
+import { FileInput, FileOutput, ScrollText } from "lucide-react";
+import { ActionButton } from "@/components/custom/action-button";
export type TProjectRun = {
run: TRun;
@@ -7,9 +12,39 @@ export type TProjectRun = {
export function ProjectRun(props: TProjectRun) {
const { run } = props;
+ const inputs = useParsePathRecordToArray({ obj: run.inputs });
+ const outputs = useParsePathRecordToArray({
+ obj: run.outputs,
+ valueKey: "uri",
+ });
+
return (
- <div>
- {run.name} - {run.run_status} - {run.id}
+ <div className="border-b border-b-gray-200 text-sm pb-2">
+ <div className="font-bold">{run.name}</div>
+ <div className="pt-2 flex justify-between items-center">
+ <ProjectRunBadge status={run.run_status} />
+
+ <div>
+ <RunPathsPopover
+ paths={inputs}
+ title="Run Inputs"
+ noPathsMessage="No input file for this run."
+ viewActionTooltipMessage="View input file"
+ triggerProps={{ message: "View inputs", children: <FileInput /> }}
+ />
+ <RunPathsPopover
+ paths={outputs}
+ title="Run Outputs"
+ noPathsMessage="No output file for this run."
+ viewActionTooltipMessage="View output file"
+ triggerProps={{
+ message: "View outputs",
+ children: <FileOutput />,
+ }}
+ />
+ <ActionButton icon={<ScrollText />} message="View logs" />
+ </div>
+ </div>
</div>
);
}
diff --git a/canvas/app/dashboard/project/id/[id]/view/steps/index.tsx b/canvas/app/dashboard/project/id/[id]/view/steps/index.tsx
index 8d75e98..6a68326 100644
--- a/canvas/app/dashboard/project/id/[id]/view/steps/index.tsx
+++ b/canvas/app/dashboard/project/id/[id]/view/steps/index.tsx
@@ -9,13 +9,13 @@ export function ProjectSteps() {
projectId: state.project.id,
}));
- const { data, isLoading } = useGetSteps({ id: projectId });
+ const { data, error, isLoading } = useGetSteps({ id: projectId });
if (isLoading) {
return <SidebarSkeleton />;
}
- if (!data || !data.ok || !data.response) {
+ if (!data || error) {
return (
<div className="text-red-500 md:pt-4 md:col-span-3">
Failed to load steps. Please Refresh the page or try again later.
@@ -23,5 +23,5 @@ export function ProjectSteps() {
);
}
- return <StepSidebar steps={data.response} />;
+ return <StepSidebar steps={data} />;
}
diff --git a/canvas/components/custom/action-button.tsx b/canvas/components/custom/action-button.tsx
index 4fadefb..610e39e 100644
--- a/canvas/components/custom/action-button.tsx
+++ b/canvas/components/custom/action-button.tsx
@@ -22,7 +22,7 @@ export function ActionButton(props: TActionsButtonProps) {
} else {
setChild(icon);
}
- }, [isLoading]);
+ }, [icon, isLoading]);
return (
<ButtonWithTooltip
diff --git a/canvas/components/custom/button-with-tooltip.tsx b/canvas/components/custom/button-with-tooltip.tsx
index 28b0ffd..c808c2f 100644
--- a/canvas/components/custom/button-with-tooltip.tsx
+++ b/canvas/components/custom/button-with-tooltip.tsx
@@ -14,7 +14,7 @@ export const ButtonWithTooltip = React.forwardRef<
const { message, ...rest } = props;
return (
<WithTooltip message={message}>
- <Button ref={ref} {...rest} />
+ <Button ref={ref} type="button" {...rest} />
</WithTooltip>
);
});
diff --git a/canvas/components/custom/path-filed-with-actions.tsx b/canvas/components/custom/path-filed-with-actions.tsx
new file mode 100644
index 0000000..bf7b610
--- /dev/null
+++ b/canvas/components/custom/path-filed-with-actions.tsx
@@ -0,0 +1,78 @@
+import { TPathRecord } from "@/app/dashboard/project/id/[id]/view/hooks/useParsePathRecordToArray";
+import { Input } from "../ui/input";
+import React from "react";
+import clsx from "clsx";
+import { WithTooltip } from "./with-tooltip";
+
+export type TPathFiledWithActionsProps = {
+ pathRecord: TPathRecord;
+ /**
+ * If true then use span to show the path value,
+ * else use input component.
+ */
+ isReadonly?: boolean;
+ /**
+ * Props passed to input element
+ */
+ inputProps?: React.HTMLProps<HTMLInputElement>;
+ /**
+ * Props passed to span element.
+ */
+ spanProp?: React.HTMLProps<HTMLSpanElement>;
+
+ actions?: { id: string; children: React.ReactNode }[];
+};
+
+export function PathFieldWithAction(props: TPathFiledWithActionsProps) {
+ const {
+ pathRecord,
+ inputProps = {},
+ spanProp = {},
+ isReadonly,
+ actions = [],
+ } = props;
+ const { name, value } = pathRecord;
+
+ const { className: inputClassName, ...inputRest } = inputProps;
+ const { className: spanClassName, ...spanRest } = spanProp;
+
+ return (
+ <div className="flex items-center text-sm border border-gray-200 rounded-md space-x-1">
+ <div className="px-1.5 py-2 bg-accent text-accent-foreground rounded-md">
+ {name}
+ </div>
+
+ {isReadonly ? (
+ <WithTooltip message={value}>
+ <span
+ className={clsx(
+ "flex-1 overflow-hidden whitespace-nowrap text-ellipsis text-gray-400",
+ spanClassName
+ )}
+ {...spanRest}
+ >
+ {value}
+ </span>
+ </WithTooltip>
+ ) : (
+ <Input
+ className={clsx(
+ "border-none shadow-transparent flex-1",
+ inputClassName
+ )}
+ value={value}
+ {...inputRest}
+ />
+ )}
+
+ {actions.map((action, idx) => (
+ <React.Fragment key={action.id}>
+ {action.children}
+ {idx !== actions.length - 1 && (
+ <div className="w-[1px] h-5 border-r border-r-gray-200" />
+ )}
+ </React.Fragment>
+ ))}
+ </div>
+ );
+}
diff --git a/canvas/components/custom/view-file/index.tsx b/canvas/components/custom/view-file/index.tsx
new file mode 100644
index 0000000..974539a
--- /dev/null
+++ b/canvas/components/custom/view-file/index.tsx
@@ -0,0 +1,16 @@
+import React from "react";
+import { ActionButton, TActionsButtonProps } from "../action-button";
+import { Eye } from "lucide-react";
+
+export type TViewFileProps = {
+ trigger?: React.ReactNode;
+ defaultTriggerProps?: TActionsButtonProps;
+};
+
+export function ViewFile(props: TViewFileProps) {
+ const { trigger, defaultTriggerProps = { message: "View file" } } = props;
+
+ return (
+ <>{trigger || <ActionButton icon={<Eye />} {...defaultTriggerProps} />}</>
+ );
+}
diff --git a/canvas/components/ui/badge.tsx b/canvas/components/ui/badge.tsx
index 677eedb..4533326 100644
--- a/canvas/components/ui/badge.tsx
+++ b/canvas/components/ui/badge.tsx
@@ -1,27 +1,25 @@
-import * as React from "react"
-import { cva, type VariantProps } from "class-variance-authority"
+import * as React from "react";
+import { cva, type VariantProps } from "class-variance-authority";
-import { cn } from "@/shadcn/utils"
+import { cn } from "@/shadcn/utils";
const badgeVariants = cva(
"inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
{
variants: {
variant: {
- default:
- "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
- secondary:
- "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
+ default: "border-transparent bg-accent text-accent-foreground",
+ success: "border-transparent bg-green-600 text-white",
+ info: "border-transparent bg-blue-600 text-white",
destructive:
- "border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
- outline: "text-foreground",
+ "border-transparent bg-destructive text-destructive-foreground",
},
},
defaultVariants: {
variant: "default",
},
}
-)
+);
export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,
@@ -30,7 +28,7 @@ export interface BadgeProps
function Badge({ className, variant, ...props }: BadgeProps) {
return (
<div className={cn(badgeVariants({ variant }), className)} {...props} />
- )
+ );
}
-export { Badge, badgeVariants }
+export { Badge, badgeVariants };
diff --git a/canvas/components/ui/popover.tsx b/canvas/components/ui/popover.tsx
new file mode 100644
index 0000000..1ef0dfc
--- /dev/null
+++ b/canvas/components/ui/popover.tsx
@@ -0,0 +1,33 @@
+"use client"
+
+import * as React from "react"
+import * as PopoverPrimitive from "@radix-ui/react-popover"
+
+import { cn } from "@/shadcn/utils"
+
+const Popover = PopoverPrimitive.Root
+
+const PopoverTrigger = PopoverPrimitive.Trigger
+
+const PopoverAnchor = PopoverPrimitive.Anchor
+
+const PopoverContent = React.forwardRef<
+ React.ElementRef<typeof PopoverPrimitive.Content>,
+ React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
+>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
+ <PopoverPrimitive.Portal>
+ <PopoverPrimitive.Content
+ ref={ref}
+ align={align}
+ sideOffset={sideOffset}
+ className={cn(
+ "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
+ className
+ )}
+ {...props}
+ />
+ </PopoverPrimitive.Portal>
+))
+PopoverContent.displayName = PopoverPrimitive.Content.displayName
+
+export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
diff --git a/canvas/package-lock.json b/canvas/package-lock.json
index c179db2..3def30c 100644
--- a/canvas/package-lock.json
+++ b/canvas/package-lock.json
@@ -17,6 +17,7 @@
"@radix-ui/react-hover-card": "^1.1.4",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.1.0",
+ "@radix-ui/react-popover": "^1.1.4",
"@radix-ui/react-progress": "^1.1.0",
"@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-slot": "^1.1.0",
@@ -1917,6 +1918,301 @@
}
}
},
+ "node_modules/@radix-ui/react-popover": {