Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionCommitController.php
| Show First 20 Lines • Show All 363 Lines • ▼ Show 20 Lines | if ($is_unreadable) { | ||||
| null, | null, | ||||
| $repository->getPathURI('diff/?view=r')); | $repository->getPathURI('diff/?view=r')); | ||||
| $change_list->setInlineCommentControllerURI( | $change_list->setInlineCommentControllerURI( | ||||
| '/diffusion/inline/edit/'.phutil_escape_uri($commit->getPHID()).'/'); | '/diffusion/inline/edit/'.phutil_escape_uri($commit->getPHID()).'/'); | ||||
| } | } | ||||
| $add_comment = $this->renderAddCommentPanel($commit, $audit_requests); | $add_comment = $this->renderAddCommentPanel( | ||||
| $commit, | |||||
| $timeline); | |||||
| $filetree_on = $viewer->compareUserSetting( | $filetree_on = $viewer->compareUserSetting( | ||||
| PhabricatorShowFiletreeSetting::SETTINGKEY, | PhabricatorShowFiletreeSetting::SETTINGKEY, | ||||
| PhabricatorShowFiletreeSetting::VALUE_ENABLE_FILETREE); | PhabricatorShowFiletreeSetting::VALUE_ENABLE_FILETREE); | ||||
| $pref_collapse = PhabricatorFiletreeVisibleSetting::SETTINGKEY; | $pref_collapse = PhabricatorFiletreeVisibleSetting::SETTINGKEY; | ||||
| $collapsed = $viewer->getUserSetting($pref_collapse); | $collapsed = $viewer->getUserSetting($pref_collapse); | ||||
| ▲ Show 20 Lines • Show All 331 Lines • ▼ Show 20 Lines | $timeline = $this->buildTransactionTimeline( | ||||
| $commit, | $commit, | ||||
| new PhabricatorAuditTransactionQuery()); | new PhabricatorAuditTransactionQuery()); | ||||
| $commit->willRenderTimeline($timeline, $this->getRequest()); | $commit->willRenderTimeline($timeline, $this->getRequest()); | ||||
| return $timeline; | return $timeline; | ||||
| } | } | ||||
| private function renderAddCommentPanel( | private function renderAddCommentPanel( | ||||
| PhabricatorRepositoryCommit $commit, | PhabricatorRepositoryCommit $commit, | ||||
| array $audit_requests) { | $timeline) { | ||||
| assert_instances_of($audit_requests, 'PhabricatorRepositoryAuditRequest'); | |||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| $viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
| if (!$viewer->isLoggedIn()) { | Javelin::initBehavior('differential-keyboard-navigation'); | ||||
| return id(new PhabricatorApplicationTransactionCommentView()) | |||||
| ->setUser($viewer) | |||||
| ->setRequestURI($request->getRequestURI()); | |||||
| } | |||||
| $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); | |||||
| $pane_id = celerity_generate_unique_node_id(); | |||||
| Javelin::initBehavior( | |||||
| 'differential-keyboard-navigation', | |||||
| array( | |||||
| 'haunt' => $pane_id, | |||||
| )); | |||||
| $draft = id(new PhabricatorDraft())->loadOneWhere( | |||||
| 'authorPHID = %s AND draftKey = %s', | |||||
| $viewer->getPHID(), | |||||
| 'diffusion-audit-'.$commit->getID()); | |||||
| if ($draft) { | |||||
| $draft = $draft->getDraft(); | |||||
| } else { | |||||
| $draft = null; | |||||
| } | |||||
| $actions = $this->getAuditActions($commit, $audit_requests); | |||||
| $mailable_source = new PhabricatorMetaMTAMailableDatasource(); | |||||
| $auditor_source = new DiffusionAuditorDatasource(); | |||||
| $form = id(new AphrontFormView()) | |||||
| ->setUser($viewer) | |||||
| ->setAction('/audit/addcomment/') | |||||
| ->addHiddenInput('commit', $commit->getPHID()) | |||||
| ->appendChild( | |||||
| id(new AphrontFormSelectControl()) | |||||
| ->setLabel(pht('Action')) | |||||
| ->setName('action') | |||||
| ->setID('audit-action') | |||||
| ->setOptions($actions)) | |||||
| ->appendControl( | |||||
| id(new AphrontFormTokenizerControl()) | |||||
| ->setLabel(pht('Add Auditors')) | |||||
| ->setName('auditors') | |||||
| ->setControlID('add-auditors') | |||||
| ->setControlStyle('display: none') | |||||
| ->setID('add-auditors-tokenizer') | |||||
| ->setDisableBehavior(true) | |||||
| ->setDatasource($auditor_source)) | |||||
| ->appendControl( | |||||
| id(new AphrontFormTokenizerControl()) | |||||
| ->setLabel(pht('Add CCs')) | |||||
| ->setName('ccs') | |||||
| ->setControlID('add-ccs') | |||||
| ->setControlStyle('display: none') | |||||
| ->setID('add-ccs-tokenizer') | |||||
| ->setDisableBehavior(true) | |||||
| ->setDatasource($mailable_source)) | |||||
| ->appendChild( | |||||
| id(new PhabricatorRemarkupControl()) | |||||
| ->setLabel(pht('Comments')) | |||||
| ->setName('content') | |||||
| ->setValue($draft) | |||||
| ->setID('audit-content') | |||||
| ->setUser($viewer)) | |||||
| ->appendChild( | |||||
| id(new AphrontFormSubmitControl()) | |||||
| ->setValue(pht('Submit'))); | |||||
| $header = new PHUIHeaderView(); | |||||
| $header->setHeader( | |||||
| $is_serious ? pht('Audit Commit') : pht('Creative Accounting')); | |||||
| Javelin::initBehavior( | |||||
| 'differential-add-reviewers-and-ccs', | |||||
| array( | |||||
| 'dynamic' => array( | |||||
| 'add-auditors-tokenizer' => array( | |||||
| 'actions' => array('add_auditors' => 1), | |||||
| 'src' => $auditor_source->getDatasourceURI(), | |||||
| 'row' => 'add-auditors', | |||||
| 'placeholder' => $auditor_source->getPlaceholderText(), | |||||
| ), | |||||
| 'add-ccs-tokenizer' => array( | |||||
| 'actions' => array('add_ccs' => 1), | |||||
| 'src' => $mailable_source->getDatasourceURI(), | |||||
| 'row' => 'add-ccs', | |||||
| 'placeholder' => $mailable_source->getPlaceholderText(), | |||||
| ), | |||||
| ), | |||||
| 'select' => 'audit-action', | |||||
| )); | |||||
| Javelin::initBehavior('differential-feedback-preview', array( | |||||
| 'uri' => '/audit/preview/'.$commit->getID().'/', | |||||
| 'preview' => 'audit-preview', | |||||
| 'content' => 'audit-content', | |||||
| 'action' => 'audit-action', | |||||
| 'previewTokenizers' => array( | |||||
| 'auditors' => 'add-auditors-tokenizer', | |||||
| 'ccs' => 'add-ccs-tokenizer', | |||||
| ), | |||||
| 'inline' => 'inline-comment-preview', | |||||
| 'inlineuri' => '/diffusion/inline/preview/'.$commit->getPHID().'/', | |||||
| )); | |||||
| $loading = phutil_tag_div( | |||||
| 'aphront-panel-preview-loading-text', | |||||
| pht('Loading preview...')); | |||||
| $preview_panel = phutil_tag_div( | |||||
| 'aphront-panel-preview aphront-panel-flush', | |||||
| array( | |||||
| phutil_tag('div', array('id' => 'audit-preview'), $loading), | |||||
| phutil_tag('div', array('id' => 'inline-comment-preview')), | |||||
| )); | |||||
| // TODO: This is pretty awkward, unify the CSS between Diffusion and | // TODO: This is pretty awkward, unify the CSS between Diffusion and | ||||
| // Differential better. | // Differential better. | ||||
| require_celerity_resource('differential-core-view-css'); | require_celerity_resource('differential-core-view-css'); | ||||
| $anchor = id(new PhabricatorAnchorView()) | $comment_view = id(new DiffusionCommitEditEngine()) | ||||
| ->setAnchorName('comment') | ->setViewer($viewer) | ||||
| ->setNavigationMarker(true) | ->buildEditEngineCommentView($commit); | ||||
| ->render(); | |||||
| $comment_box = id(new PHUIObjectBoxView()) | $comment_view->setTransactionTimeline($timeline); | ||||
| ->setHeader($header) | |||||
| ->appendChild($form); | |||||
| return phutil_tag( | return $comment_view; | ||||
| 'div', | |||||
| array( | |||||
| 'id' => $pane_id, | |||||
| ), | |||||
| phutil_tag_div( | |||||
| 'differential-add-comment-panel', | |||||
| array($anchor, $comment_box, $preview_panel))); | |||||
| } | } | ||||
| /** | /** | ||||
| * Return a map of available audit actions for rendering into a <select />. | * Return a map of available audit actions for rendering into a <select />. | ||||
| * This shows the user valid actions, and does not show nonsense/invalid | * This shows the user valid actions, and does not show nonsense/invalid | ||||
| * actions (like closing an already-closed commit, or resigning from a commit | * actions (like closing an already-closed commit, or resigning from a commit | ||||
| * you have no association with). | * you have no association with). | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 464 Lines • Show Last 20 Lines | |||||