Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F99770388
DiffusionRepositoryClusterManagementPanel.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jan 26, 13:27
Size
3 KB
Mime Type
text/x-php
Expires
Tue, Jan 28, 13:27 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23819610
Attached To
rPH Phabricator
DiffusionRepositoryClusterManagementPanel.php
View Options
<?php
final
class
DiffusionRepositoryClusterManagementPanel
extends
DiffusionRepositoryManagementPanel
{
const
PANELKEY
=
'cluster'
;
public
function
getManagementPanelLabel
()
{
return
pht
(
'Cluster Configuration'
);
}
public
function
getManagementPanelOrder
()
{
return
12345
;
}
public
function
buildManagementPanelContent
()
{
$repository
=
$this
->
getRepository
();
$viewer
=
$this
->
getViewer
();
$service_phid
=
$repository
->
getAlmanacServicePHID
();
if
(
$service_phid
)
{
$service
=
id
(
new
AlmanacServiceQuery
())
->
setViewer
(
$viewer
)
->
withServiceTypes
(
array
(
AlmanacClusterRepositoryServiceType
::
SERVICETYPE
,
))
->
withPHIDs
(
array
(
$service_phid
))
->
needBindings
(
true
)
->
executeOne
();
if
(!
$service
)
{
// TODO: Viewer may not have permission to see the service, or it may
// be invalid? Raise some more useful error here?
throw
new
Exception
(
pht
(
'Unable to load cluster service.'
));
}
}
else
{
$service
=
null
;
}
Javelin
::
initBehavior
(
'phabricator-tooltips'
);
$rows
=
array
();
if
(
$service
)
{
$bindings
=
$service
->
getBindings
();
$bindings
=
mgroup
(
$bindings
,
'getDevicePHID'
);
foreach
(
$bindings
as
$binding_group
)
{
$all_disabled
=
true
;
foreach
(
$binding_group
as
$binding
)
{
if
(!
$binding
->
getIsDisabled
())
{
$all_disabled
=
false
;
break
;
}
}
$any_binding
=
head
(
$binding_group
);
if
(
$all_disabled
)
{
$binding_icon
=
'fa-times grey'
;
$binding_tip
=
pht
(
'Disabled'
);
}
else
{
$binding_icon
=
'fa-folder-open green'
;
$binding_tip
=
pht
(
'Active'
);
}
$binding_icon
=
id
(
new
PHUIIconView
())
->
setIcon
(
$binding_icon
)
->
addSigil
(
'has-tooltip'
)
->
setMetadata
(
array
(
'tip'
=>
$binding_tip
,
));
$device
=
$any_binding
->
getDevice
();
$rows
[]
=
array
(
$binding_icon
,
phutil_tag
(
'a'
,
array
(
'href'
=>
$device
->
getURI
(),
),
$device
->
getName
()),
);
}
}
$table
=
id
(
new
AphrontTableView
(
$rows
))
->
setNoDataString
(
pht
(
'This is not a cluster repository.'
))
->
setHeaders
(
array
(
null
,
pht
(
'Device'
),
))
->
setColumnClasses
(
array
(
null
,
'wide'
,
));
$doc_href
=
PhabricatorEnv
::
getDoclink
(
'Cluster: Repositories'
);
$header
=
id
(
new
PHUIHeaderView
())
->
setHeader
(
pht
(
'Cluster Status'
))
->
addActionLink
(
id
(
new
PHUIButtonView
())
->
setIcon
(
'fa-book'
)
->
setHref
(
$doc_href
)
->
setTag
(
'a'
)
->
setText
(
pht
(
'Documentation'
)));
if
(
$service
)
{
$header
->
setSubheader
(
pht
(
'This repository is hosted on %s.'
,
phutil_tag
(
'a'
,
array
(
'href'
=>
$service
->
getURI
(),
),
$service
->
getName
())));
}
return
id
(
new
PHUIObjectBoxView
())
->
setHeader
(
$header
)
->
setTable
(
$table
);
}
}
Event Timeline
Log In to Comment