|
10 | 10 | let patch: any = {};
|
11 | 11 | let stack: any = {};
|
12 | 12 | let status: any = {};
|
13 |
| - let chats: any = []; |
| 13 | + let events: any = []; |
14 | 14 | let key: any = '';
|
15 | 15 | let uuid: any = '';
|
16 | 16 |
|
|
256 | 256 | }
|
257 | 257 |
|
258 | 258 | function fetchAndUpdateChat() {
|
259 |
| - fetch(env.PUBLIC_APP_HOST + 'api/chat_messages/' + data.projectId + '/chats/' + data.changeId, { |
| 259 | + fetch(env.PUBLIC_APP_HOST + 'api/patch_events/' + data.projectId + '/patch/' + data.changeId, { |
260 | 260 | method: 'GET',
|
261 | 261 | headers: {
|
262 | 262 | 'X-AUTH-TOKEN': key || ''
|
|
266 | 266 | .then((data) => {
|
267 | 267 | console.log(data);
|
268 | 268 | setTimeout(() => {
|
269 |
| - chats = data; |
| 269 | + events = data; |
270 | 270 | setTimeout(() => {
|
271 | 271 | scrollToBottom();
|
272 | 272 | }, 150); // I don't know how to DOM in Svelte, but it takes a second
|
|
342 | 342 | .then((data) => {
|
343 | 343 | console.log('sign off', data);
|
344 | 344 | getPatchStatus();
|
| 345 | + fetchAndUpdateChat(); |
345 | 346 | });
|
346 | 347 | }
|
347 | 348 | }
|
|
469 | 470 | {/if}
|
470 | 471 | {/if}
|
471 | 472 | <div>
|
472 |
| - {#if !status[data.changeId].last_signoff} |
473 |
| - <button class="button" on:click={() => signOff(true)}>Sign Off</button> |
474 |
| - {/if} |
475 |
| - {#if status[data.changeId].last_signoff || !status[data.changeId].last_reviewed} |
476 |
| - <button class="button" on:click={() => signOff(false)}>Reject</button> |
| 473 | + {#if status[data.changeId]} |
| 474 | + {#if !status[data.changeId].last_signoff} |
| 475 | + <button class="button" on:click={() => signOff(true)}>Sign Off</button> |
| 476 | + {/if} |
| 477 | + {#if status[data.changeId].last_signoff || !status[data.changeId].last_reviewed} |
| 478 | + <button class="button" on:click={() => signOff(false)}>Reject</button> |
| 479 | + {/if} |
477 | 480 | {/if}
|
478 | 481 | </div>
|
479 | 482 | </div>
|
|
535 | 538 | <div class="column chatArea">
|
536 | 539 | <h3>Chat</h3>
|
537 | 540 | <div class="chatWindow">
|
538 |
| - {#each chats as chat} |
539 |
| - <div class="chatEntry {chat.issue ? 'issue' : ''} {chat.resolved ? 'resolved' : ''}"> |
540 |
| - <div class="chatHeader"> |
541 |
| - <div class="avatar"> |
542 |
| - <Gravatar email={chat.user.email} size={20} /> |
| 541 | + {#each events as event} |
| 542 | + {#if event.event_type === 'chat'} |
| 543 | + <div |
| 544 | + class="chatEntry {event.object.issue ? 'issue' : ''} {event.object.resolved |
| 545 | + ? 'resolved' |
| 546 | + : ''}" |
| 547 | + > |
| 548 | + <div class="chatHeader"> |
| 549 | + <div class="avatar"> |
| 550 | + <Gravatar email={event.object.user.email} size={20} /> |
| 551 | + </div> |
| 552 | + <div>{event.object.created_at}</div> |
543 | 553 | </div>
|
544 |
| - <div>{chat.created_at}</div> |
| 554 | + {#if event.object.diff_patch_array} |
| 555 | + <div> |
| 556 | + <div class="diffPath">{event.object.diff_path}</div> |
| 557 | + <!-- {chat.diff_sha} --> |
| 558 | + <DiffPatchArray diffArray={event.object.diff_patch_array} /> |
| 559 | + </div> |
| 560 | + {/if} |
| 561 | + <div class="chatComment">{event.object.comment}</div> |
| 562 | + {#if event.object.issue} |
| 563 | + {#if event.object.resolved} |
| 564 | + <div class="right">resolved</div> |
| 565 | + {:else} |
| 566 | + <button class="action" on:click={() => resolveIssue(event.object.uuid)} |
| 567 | + >resolve</button |
| 568 | + > |
| 569 | + {/if} |
| 570 | + {/if} |
545 | 571 | </div>
|
546 |
| - {#if chat.diff_patch_array} |
547 |
| - <div> |
548 |
| - <div class="diffPath">{chat.diff_path}</div> |
549 |
| - <!-- {chat.diff_sha} --> |
550 |
| - <DiffPatchArray diffArray={chat.diff_patch_array} /> |
| 572 | + {/if} |
| 573 | + {#if event.event_type === 'issue_status'} |
| 574 | + {#if event.data.resolution} |
| 575 | + <div class="issueEvent event"> |
| 576 | + <div class="eventDetail"> |
| 577 | + {event.user.email} resolved issue {event.object.uuid.substr(0, 8)} |
| 578 | + </div> |
| 579 | + <div class="eventDate"> |
| 580 | + {event.created_at} |
| 581 | + </div> |
551 | 582 | </div>
|
552 | 583 | {/if}
|
553 |
| - <div class="chatComment">{chat.comment}</div> |
554 |
| - {#if chat.issue} |
555 |
| - {#if chat.resolved} |
556 |
| - <div class="right">resolved</div> |
557 |
| - {:else} |
558 |
| - <button class="action" on:click={() => resolveIssue(chat.uuid)}>resolve</button> |
559 |
| - {/if} |
| 584 | + {/if} |
| 585 | + |
| 586 | + {#if event.event_type === 'patch_status'} |
| 587 | + {#if event.data.status} |
| 588 | + <div class="signoffEvent event"> |
| 589 | + <div class="eventDetail"> |
| 590 | + {event.user.email} |
| 591 | + signed off |
| 592 | + </div> |
| 593 | + <div class="eventDate"> |
| 594 | + {event.created_at} |
| 595 | + </div> |
| 596 | + </div> |
| 597 | + {:else} |
| 598 | + <div class="rejectEvent event"> |
| 599 | + <div class="eventDetail"> |
| 600 | + {event.user.email} |
| 601 | + requested changes |
| 602 | + </div> |
| 603 | + <div class="eventDate"> |
| 604 | + {event.created_at} |
| 605 | + </div> |
| 606 | + </div> |
560 | 607 | {/if}
|
561 |
| - </div> |
| 608 | + {/if} |
| 609 | + |
| 610 | + {#if event.event_type === 'patch_version'} |
| 611 | + <div class="versionEvent event"> |
| 612 | + <div class="eventDetail"> |
| 613 | + new patch version: v{event.object.version} |
| 614 | + </div> |
| 615 | + <div class="eventDate"> |
| 616 | + {event.created_at} |
| 617 | + </div> |
| 618 | + </div> |
| 619 | + {/if} |
562 | 620 | {/each}
|
563 | 621 | </div>
|
564 | 622 | <div class="chatBox">
|
|
580 | 638 | {/if}
|
581 | 639 |
|
582 | 640 | <style>
|
| 641 | + .event { |
| 642 | + display: flex; |
| 643 | + flex-direction: row; |
| 644 | + justify-content: space-between; |
| 645 | + margin-bottom: 0.5em; |
| 646 | + } |
| 647 | + .eventDate { |
| 648 | + color: #888; |
| 649 | + font-size: small; |
| 650 | + } |
| 651 | +
|
| 652 | + .issueEvent { |
| 653 | + background-color: #dbecff; |
| 654 | + padding: 5px; |
| 655 | + border-radius: 5px; |
| 656 | + } |
| 657 | + .signoffEvent { |
| 658 | + background-color: #e6ffed; |
| 659 | + padding: 5px; |
| 660 | + border-radius: 5px; |
| 661 | + } |
| 662 | + .rejectEvent { |
| 663 | + background-color: #ffeef0; |
| 664 | + padding: 5px; |
| 665 | + border-radius: 5px; |
| 666 | + } |
| 667 | + .versionEvent { |
| 668 | + padding: 5px; |
| 669 | + border-bottom: 1px solid rgb(96, 43, 43); |
| 670 | + } |
| 671 | + .versionEvent .eventDetail { |
| 672 | + color: #844; |
| 673 | + } |
| 674 | +
|
583 | 675 | .actionChat {
|
584 | 676 | cursor: pointer;
|
585 | 677 | color: #ffffff;
|
|
0 commit comments