@@ -52,6 +52,13 @@ public function processRequest() {
52
52
->setAnchorName ('top ' )
53
53
->setNavigationMarker (true );
54
54
55
+ $ audit_requests = id (new PhabricatorAuditQuery ())
56
+ ->withCommitPHIDs (array ($ commit ->getPHID ()))
57
+ ->execute ();
58
+ $ this ->auditAuthorityPHIDs =
59
+ PhabricatorAuditCommentEditor::loadAuditPHIDsForUser ($ user );
60
+
61
+
55
62
$ is_foreign = $ commit_data ->getCommitDetail ('foreign-svn-stub ' );
56
63
$ changesets = null ;
57
64
if ($ is_foreign ) {
@@ -86,7 +93,8 @@ public function processRequest() {
86
93
$ commit_properties = $ this ->loadCommitProperties (
87
94
$ commit ,
88
95
$ commit_data ,
89
- $ parents );
96
+ $ parents ,
97
+ $ audit_requests );
90
98
$ property_list = id (new PhabricatorPropertyListView ())
91
99
->setHasKeyboardShortcuts (true )
92
100
->setUser ($ user )
@@ -116,14 +124,6 @@ public function processRequest() {
116
124
$ content [] = $ property_list ;
117
125
}
118
126
119
- $ query = new PhabricatorAuditQuery ();
120
- $ query ->withCommitPHIDs (array ($ commit ->getPHID ()));
121
- $ audit_requests = $ query ->execute ();
122
-
123
- $ this ->auditAuthorityPHIDs =
124
- PhabricatorAuditCommentEditor::loadAuditPHIDsForUser ($ user );
125
-
126
- $ content [] = $ this ->buildAuditTable ($ commit , $ audit_requests );
127
127
$ content [] = $ this ->buildComments ($ commit );
128
128
129
129
$ hard_limit = 1000 ;
@@ -368,7 +368,8 @@ public function processRequest() {
368
368
private function loadCommitProperties (
369
369
PhabricatorRepositoryCommit $ commit ,
370
370
PhabricatorRepositoryCommitData $ data ,
371
- array $ parents ) {
371
+ array $ parents ,
372
+ array $ audit_requests ) {
372
373
373
374
assert_instances_of ($ parents , 'PhabricatorRepositoryCommit ' );
374
375
$ user = $ this ->getRequest ()->getUser ();
@@ -418,10 +419,30 @@ private function loadCommitProperties(
418
419
if ($ commit ->getAuditStatus ()) {
419
420
$ status = PhabricatorAuditCommitStatusConstants::getStatusName (
420
421
$ commit ->getAuditStatus ());
421
- $ props ['Status ' ] = phutil_tag (
422
- 'strong ' ,
423
- array (),
424
- $ status );
422
+ $ tag = id (new PhabricatorTagView ())
423
+ ->setType (PhabricatorTagView::TYPE_STATE )
424
+ ->setName ($ status );
425
+
426
+ switch ($ commit ->getAuditStatus ()) {
427
+ case PhabricatorAuditCommitStatusConstants::NEEDS_AUDIT :
428
+ $ tag ->setBackgroundColor (PhabricatorTagView::COLOR_ORANGE );
429
+ break ;
430
+ case PhabricatorAuditCommitStatusConstants::CONCERN_RAISED :
431
+ $ tag ->setBackgroundColor (PhabricatorTagView::COLOR_RED );
432
+ break ;
433
+ case PhabricatorAuditCommitStatusConstants::PARTIALLY_AUDITED :
434
+ $ tag ->setBackgroundColor (PhabricatorTagView::COLOR_BLUE );
435
+ break ;
436
+ case PhabricatorAuditCommitStatusConstants::FULLY_AUDITED :
437
+ $ tag ->setBackgroundColor (PhabricatorTagView::COLOR_GREEN );
438
+ break ;
439
+ }
440
+
441
+ $ props ['Status ' ] = $ tag ;
442
+ }
443
+
444
+ if ($ audit_requests ) {
445
+ $ props ['Auditors ' ] = $ this ->renderAuditStatusView ($ audit_requests );
425
446
}
426
447
427
448
$ props ['Committed ' ] = phabricator_datetime ($ commit ->getEpoch (), $ user );
@@ -510,33 +531,6 @@ private function loadCommitProperties(
510
531
return $ props ;
511
532
}
512
533
513
- private function buildAuditTable (
514
- PhabricatorRepositoryCommit $ commit ,
515
- array $ audits ) {
516
- assert_instances_of ($ audits , 'PhabricatorRepositoryAuditRequest ' );
517
- $ user = $ this ->getRequest ()->getUser ();
518
-
519
- $ view = new PhabricatorAuditListView ();
520
- $ view ->setAudits ($ audits );
521
- $ view ->setCommits (array ($ commit ));
522
- $ view ->setUser ($ user );
523
- $ view ->setShowCommits (false );
524
-
525
- $ phids = $ view ->getRequiredHandlePHIDs ();
526
- $ handles = $ this ->loadViewerHandles ($ phids );
527
- $ view ->setHandles ($ handles );
528
- $ view ->setAuthorityPHIDs ($ this ->auditAuthorityPHIDs );
529
- $ this ->highlightedAudits = $ view ->getHighlightedAudits ();
530
-
531
- $ panel = new AphrontPanelView ();
532
- $ panel ->setHeader (pht ('Audits ' ));
533
- $ panel ->setCaption (pht ('Audits you are responsible for are highlighted. ' ));
534
- $ panel ->appendChild ($ view );
535
- $ panel ->setNoBackground ();
536
-
537
- return $ panel ;
538
- }
539
-
540
534
private function buildComments (PhabricatorRepositoryCommit $ commit ) {
541
535
$ user = $ this ->getRequest ()->getUser ();
542
536
$ comments = id (new PhabricatorAuditComment ())->loadAllWhere (
@@ -886,21 +880,6 @@ private function renderHeadsupActionList(
886
880
$ actions ->addAction ($ action );
887
881
}
888
882
889
- if ($ user ->getIsAdmin ()) {
890
- $ action = id (new PhabricatorActionView ())
891
- ->setName (pht ('MetaMTA Transcripts ' ))
892
- ->setIcon ('file ' )
893
- ->setHref ('/mail/?phid= ' .$ commit ->getPHID ());
894
- $ actions ->addAction ($ action );
895
- }
896
-
897
- $ action = id (new PhabricatorActionView ())
898
- ->setName (pht ('Herald Transcripts ' ))
899
- ->setIcon ('file ' )
900
- ->setHref ('/herald/transcript/?phid= ' .$ commit ->getPHID ())
901
- ->setWorkflow (true );
902
- $ actions ->addAction ($ action );
903
-
904
883
$ action = id (new PhabricatorActionView ())
905
884
->setName (pht ('Download Raw Diff ' ))
906
885
->setHref ($ request ->getRequestURI ()->alter ('diff ' , true ))
@@ -947,4 +926,63 @@ private function buildRawDiffResponse(DiffusionRequest $drequest) {
947
926
return id (new AphrontRedirectResponse ())->setURI ($ file ->getBestURI ());
948
927
}
949
928
929
+ private function renderAuditStatusView (array $ audit_requests ) {
930
+ assert_instances_of ($ audit_requests , 'PhabricatorRepositoryAuditRequest ' );
931
+
932
+ $ phids = mpull ($ audit_requests , 'getAuditorPHID ' );
933
+ $ this ->loadHandles ($ phids );
934
+
935
+ $ authority_map = array_fill_keys ($ this ->auditAuthorityPHIDs , true );
936
+
937
+ $ view = new PHUIStatusListView ();
938
+ foreach ($ audit_requests as $ request ) {
939
+ $ item = new PHUIStatusItemView ();
940
+
941
+ switch ($ request ->getAuditStatus ()) {
942
+ case PhabricatorAuditStatusConstants::AUDIT_NOT_REQUIRED :
943
+ $ item ->setIcon ('open-blue ' , pht ('Commented ' ));
944
+ break ;
945
+ case PhabricatorAuditStatusConstants::AUDIT_REQUIRED :
946
+ $ item ->setIcon ('warning-blue ' , pht ('Audit Required ' ));
947
+ break ;
948
+ case PhabricatorAuditStatusConstants::CONCERNED :
949
+ $ item ->setIcon ('reject-red ' , pht ('Concern Raised ' ));
950
+ break ;
951
+ case PhabricatorAuditStatusConstants::ACCEPTED :
952
+ $ item ->setIcon ('accept-green ' , pht ('Accepted ' ));
953
+ break ;
954
+ case PhabricatorAuditStatusConstants::AUDIT_REQUESTED :
955
+ $ item ->setIcon ('warning-dark ' , pht ('Audit Requested ' ));
956
+ break ;
957
+ case PhabricatorAuditStatusConstants::RESIGNED :
958
+ $ item ->setIcon ('open-dark ' , pht ('Accepted ' ));
959
+ break ;
960
+ case PhabricatorAuditStatusConstants::CLOSED :
961
+ $ item ->setIcon ('accept-blue ' , pht ('Accepted ' ));
962
+ break ;
963
+ case PhabricatorAuditStatusConstants::CC :
964
+ $ item ->setIcon ('info-dark ' , pht ('Subscribed ' ));
965
+ break ;
966
+ }
967
+
968
+ $ note = array ();
969
+ foreach ($ request ->getAuditReasons () as $ reason ) {
970
+ $ note [] = phutil_tag ('div ' , array (), $ reason );
971
+ }
972
+ $ item ->setNote ($ note );
973
+
974
+ $ auditor_phid = $ request ->getAuditorPHID ();
975
+ $ target = $ this ->getHandle ($ auditor_phid )->renderLink ();
976
+ $ item ->setTarget ($ target );
977
+
978
+ if (isset ($ authority_map [$ auditor_phid ])) {
979
+ $ item ->setHighlighted (true );
980
+ }
981
+
982
+ $ view ->addItem ($ item );
983
+ }
984
+
985
+ return $ view ;
986
+ }
987
+
950
988
}
0 commit comments