1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Added possibility to define custom action links and properties in differential.

Summary:
There was a need to add old facebook specific action links and properties
back to differential.

Test Plan:
Tested that all the facebook specific links work for multiple
different revisions.

Reviewed By: epriestley
Reviewers: epriestley
CC: jungejason, tuomaspelkonen, epriestley
Differential Revision: 127
This commit is contained in:
tuomaspelkonen 2011-04-12 15:57:29 -07:00
parent ea455376e6
commit 79b32afeec
5 changed files with 76 additions and 0 deletions

View file

@ -141,6 +141,7 @@ phutil_register_library_map(array(
'DifferentialRevisionCommentListView' => 'applications/differential/view/revisioncommentlist',
'DifferentialRevisionCommentView' => 'applications/differential/view/revisioncomment',
'DifferentialRevisionControlSystem' => 'applications/differential/constants/revisioncontrolsystem',
'DifferentialRevisionDetailRenderer' => 'applications/differential/controller/customrenderer',
'DifferentialRevisionDetailView' => 'applications/differential/view/revisiondetail',
'DifferentialRevisionEditController' => 'applications/differential/controller/revisionedit',
'DifferentialRevisionEditor' => 'applications/differential/editor/revision',

View file

@ -0,0 +1,43 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
abstract class DifferentialRevisionDetailRenderer {
/**
* This function must return an array of action links that will be
* added to the end of action links on the differential revision
* page. Each element in the array must be an array which must
* contain 'name' and 'href' fields. 'name' will be the name of the
* link and 'href' will be the address where the link points
* to. 'class' is optional and can be used for specifying a CSS
* class.
*/
abstract public function generateActionLinks(DifferentialRevision $revision,
DifferentialDiff $diff);
/**
* This function must return an array of properties. These
* properties will be shown below other properties on differential
* revision page. Array keys are used for property names and array
* values are used for the actual property values. These property
* values will be displayed on the page as they are given, so they
* should be properly escaped.
*/
abstract public function generateProperties(DifferentialRevision $revision,
DifferentialDiff $diff);
}

View file

@ -0,0 +1,10 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_source('DifferentialRevisionDetailRenderer.php');

View file

@ -129,14 +129,34 @@ class DifferentialRevisionViewController extends DifferentialController {
$revision_detail = new DifferentialRevisionDetailView();
$revision_detail->setRevision($revision);
$custom_renderer_class = PhabricatorEnv::getEnvConfig(
'differential.revision-custom-detail-renderer');
if ($custom_renderer_class) {
PhutilSymbolLoader::loadClass($custom_renderer_class);
$custom_renderer =
newv($custom_renderer_class, array());
}
$properties = $this->getRevisionProperties(
$revision,
$target,
$handles,
$diff_properties);
if ($custom_renderer) {
$properties = array_merge(
$properties,
$custom_renderer->generateProperties($revision, $target));
}
$revision_detail->setProperties($properties);
$actions = $this->getRevisionActions($revision);
if ($custom_renderer) {
$actions = array_merge(
$actions,
$custom_renderer->generateActionLinks($revision, $target));
}
$revision_detail->setActions($actions);
$comment_view = new DifferentialRevisionCommentListView();

View file

@ -25,9 +25,11 @@ phutil_require_module('phabricator', 'applications/draft/storage/draft');
phutil_require_module('phabricator', 'applications/phid/constants');
phutil_require_module('phabricator', 'applications/phid/handle/data');
phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'view/form/error');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'symbols');
phutil_require_module('phutil', 'utils');