Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14409083
D16747.id40333.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D16747.id40333.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2137,6 +2137,8 @@
'PhabricatorCalendarImportOrphanLogType' => 'applications/calendar/importlog/PhabricatorCalendarImportOrphanLogType.php',
'PhabricatorCalendarImportPHIDType' => 'applications/calendar/phid/PhabricatorCalendarImportPHIDType.php',
'PhabricatorCalendarImportQuery' => 'applications/calendar/query/PhabricatorCalendarImportQuery.php',
+ 'PhabricatorCalendarImportReloadController' => 'applications/calendar/controller/PhabricatorCalendarImportReloadController.php',
+ 'PhabricatorCalendarImportReloadTransaction' => 'applications/calendar/xaction/PhabricatorCalendarImportReloadTransaction.php',
'PhabricatorCalendarImportSearchEngine' => 'applications/calendar/query/PhabricatorCalendarImportSearchEngine.php',
'PhabricatorCalendarImportTransaction' => 'applications/calendar/storage/PhabricatorCalendarImportTransaction.php',
'PhabricatorCalendarImportTransactionQuery' => 'applications/calendar/query/PhabricatorCalendarImportTransactionQuery.php',
@@ -6982,6 +6984,8 @@
'PhabricatorCalendarImportOrphanLogType' => 'PhabricatorCalendarImportLogType',
'PhabricatorCalendarImportPHIDType' => 'PhabricatorPHIDType',
'PhabricatorCalendarImportQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PhabricatorCalendarImportReloadController' => 'PhabricatorCalendarController',
+ 'PhabricatorCalendarImportReloadTransaction' => 'PhabricatorCalendarImportTransactionType',
'PhabricatorCalendarImportSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorCalendarImportTransaction' => 'PhabricatorModularTransaction',
'PhabricatorCalendarImportTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
diff --git a/src/applications/calendar/application/PhabricatorCalendarApplication.php b/src/applications/calendar/application/PhabricatorCalendarApplication.php
--- a/src/applications/calendar/application/PhabricatorCalendarApplication.php
+++ b/src/applications/calendar/application/PhabricatorCalendarApplication.php
@@ -85,6 +85,8 @@
=> 'PhabricatorCalendarImportDisableController',
'delete/(?P<id>[1-9]\d*)/'
=> 'PhabricatorCalendarImportDeleteController',
+ 'reload/(?P<id>[1-9]\d*)/'
+ => 'PhabricatorCalendarImportReloadController',
'drop/'
=> 'PhabricatorCalendarImportDropController',
'log/' => array(
diff --git a/src/applications/calendar/controller/PhabricatorCalendarImportReloadController.php b/src/applications/calendar/controller/PhabricatorCalendarImportReloadController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/controller/PhabricatorCalendarImportReloadController.php
@@ -0,0 +1,52 @@
+<?php
+
+final class PhabricatorCalendarImportReloadController
+ extends PhabricatorCalendarController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+
+ $import = id(new PhabricatorCalendarImportQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($request->getURIData('id')))
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->executeOne();
+ if (!$import) {
+ return new Aphront404Response();
+ }
+
+ $import_uri = $import->getURI();
+
+ if ($request->isFormPost()) {
+ $xactions = array();
+ $xactions[] = id(new PhabricatorCalendarImportTransaction())
+ ->setTransactionType(
+ PhabricatorCalendarImportReloadTransaction::TRANSACTIONTYPE)
+ ->setNewValue(true);
+
+ $editor = id(new PhabricatorCalendarImportEditor())
+ ->setActor($viewer)
+ ->setContinueOnNoEffect(true)
+ ->setContinueOnMissingFields(true)
+ ->setContentSourceFromRequest($request);
+
+ $editor->applyTransactions($import, $xactions);
+
+ return id(new AphrontRedirectResponse())->setURI($import_uri);
+ }
+
+ return $this->newDialog()
+ ->setTitle(pht('Reload Events'))
+ ->appendParagraph(
+ pht(
+ 'Reload this source? Events imported from this source will '.
+ 'be updated.'))
+ ->addCancelButton($import_uri)
+ ->addSubmitButton(pht('Reload Events'));
+ }
+
+}
diff --git a/src/applications/calendar/controller/PhabricatorCalendarImportViewController.php b/src/applications/calendar/controller/PhabricatorCalendarImportViewController.php
--- a/src/applications/calendar/controller/PhabricatorCalendarImportViewController.php
+++ b/src/applications/calendar/controller/PhabricatorCalendarImportViewController.php
@@ -105,6 +105,17 @@
->setWorkflow(!$can_edit)
->setHref($edit_uri));
+ $reload_uri = "import/reload/{$id}/";
+ $reload_uri = $this->getApplicationURI($reload_uri);
+
+ $curtain->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Reload Import'))
+ ->setIcon('fa-refresh')
+ ->setDisabled(!$can_edit)
+ ->setWorkflow(true)
+ ->setHref($reload_uri));
+
$disable_uri = "import/disable/{$id}/";
$disable_uri = $this->getApplicationURI($disable_uri);
if ($import->getIsDisabled()) {
@@ -123,7 +134,6 @@
->setWorkflow(true)
->setHref($disable_uri));
-
if ($can_edit) {
$can_delete = $engine->canDeleteAnyEvents($viewer, $import);
} else {
diff --git a/src/applications/calendar/editor/PhabricatorCalendarImportEditEngine.php b/src/applications/calendar/editor/PhabricatorCalendarImportEditEngine.php
--- a/src/applications/calendar/editor/PhabricatorCalendarImportEditEngine.php
+++ b/src/applications/calendar/editor/PhabricatorCalendarImportEditEngine.php
@@ -101,6 +101,26 @@
->setConduitDescription(pht('Disable or restore the import.'))
->setConduitTypeDescription(pht('True to cancel the import.'))
->setValue($object->getIsDisabled()),
+ id(new PhabricatorBoolEditField())
+ ->setKey('delete')
+ ->setLabel(pht('Delete Imported Events'))
+ ->setDescription(pht('Delete all events from this source.'))
+ ->setTransactionType(
+ PhabricatorCalendarImportDisableTransaction::TRANSACTIONTYPE)
+ ->setIsConduitOnly(true)
+ ->setConduitDescription(pht('Disable or restore the import.'))
+ ->setConduitTypeDescription(pht('True to delete imported events.'))
+ ->setValue(false),
+ id(new PhabricatorBoolEditField())
+ ->setKey('reload')
+ ->setLabel(pht('Reload Import'))
+ ->setDescription(pht('Reload events imported from this source.'))
+ ->setTransactionType(
+ PhabricatorCalendarImportDisableTransaction::TRANSACTIONTYPE)
+ ->setIsConduitOnly(true)
+ ->setConduitDescription(pht('Disable or restore the import.'))
+ ->setConduitTypeDescription(pht('True to reload the import.'))
+ ->setValue(false),
);
$import_engine = $object->getEngine();
diff --git a/src/applications/calendar/editor/PhabricatorCalendarImportEditor.php b/src/applications/calendar/editor/PhabricatorCalendarImportEditor.php
--- a/src/applications/calendar/editor/PhabricatorCalendarImportEditor.php
+++ b/src/applications/calendar/editor/PhabricatorCalendarImportEditor.php
@@ -28,11 +28,23 @@
PhabricatorLiskDAO $object,
array $xactions) {
- if ($this->getIsNewObject()) {
+ $type_reload = PhabricatorCalendarImportReloadTransaction::TRANSACTIONTYPE;
+
+ // We import events when you create a source, or if you later reload it
+ // explicitly.
+ $should_reload = $this->getIsNewObject();
+ foreach ($xactions as $xaction) {
+ if ($xaction->getTransactionType() == $type_reload) {
+ $should_reload = true;
+ break;
+ }
+ }
+
+ if ($should_reload) {
$actor = $this->getActor();
$import_engine = $object->getEngine();
- $import_engine->didCreateImport($actor, $object);
+ $import_engine->importEventsFromSource($actor, $object);
}
return $xactions;
diff --git a/src/applications/calendar/import/PhabricatorCalendarICSFileImportEngine.php b/src/applications/calendar/import/PhabricatorCalendarICSFileImportEngine.php
--- a/src/applications/calendar/import/PhabricatorCalendarICSFileImportEngine.php
+++ b/src/applications/calendar/import/PhabricatorCalendarICSFileImportEngine.php
@@ -59,7 +59,7 @@
}
}
- public function didCreateImport(
+ public function importEventsFromSource(
PhabricatorUser $viewer,
PhabricatorCalendarImport $import) {
diff --git a/src/applications/calendar/import/PhabricatorCalendarICSURIImportEngine.php b/src/applications/calendar/import/PhabricatorCalendarICSURIImportEngine.php
--- a/src/applications/calendar/import/PhabricatorCalendarICSURIImportEngine.php
+++ b/src/applications/calendar/import/PhabricatorCalendarICSURIImportEngine.php
@@ -71,7 +71,7 @@
return pht('ICS URI');
}
- public function didCreateImport(
+ public function importEventsFromSource(
PhabricatorUser $viewer,
PhabricatorCalendarImport $import) {
diff --git a/src/applications/calendar/import/PhabricatorCalendarImportEngine.php b/src/applications/calendar/import/PhabricatorCalendarImportEngine.php
--- a/src/applications/calendar/import/PhabricatorCalendarImportEngine.php
+++ b/src/applications/calendar/import/PhabricatorCalendarImportEngine.php
@@ -25,7 +25,7 @@
abstract public function getDisplayName(PhabricatorCalendarImport $import);
- abstract public function didCreateImport(
+ abstract public function importEventsFromSource(
PhabricatorUser $viewer,
PhabricatorCalendarImport $import);
diff --git a/src/applications/calendar/importlog/PhabricatorCalendarImportUpdateLogType.php b/src/applications/calendar/importlog/PhabricatorCalendarImportUpdateLogType.php
--- a/src/applications/calendar/importlog/PhabricatorCalendarImportUpdateLogType.php
+++ b/src/applications/calendar/importlog/PhabricatorCalendarImportUpdateLogType.php
@@ -26,7 +26,7 @@
public function getDisplayIcon(
PhabricatorUser $viewer,
PhabricatorCalendarImportLog $log) {
- return 'fa-upload';
+ return 'fa-calendar';
}
public function getDisplayColor(
diff --git a/src/applications/calendar/xaction/PhabricatorCalendarImportReloadTransaction.php b/src/applications/calendar/xaction/PhabricatorCalendarImportReloadTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/calendar/xaction/PhabricatorCalendarImportReloadTransaction.php
@@ -0,0 +1,23 @@
+<?php
+
+final class PhabricatorCalendarImportReloadTransaction
+ extends PhabricatorCalendarImportTransactionType {
+
+ const TRANSACTIONTYPE = 'calendar.import.reload';
+
+ public function generateOldValue($object) {
+ return false;
+ }
+
+ public function applyExternalEffects($object, $value) {
+ // NOTE: This transaction does nothing directly; instead, the Editor
+ // reacts to it and performs the reload.
+ }
+
+ public function getTitle() {
+ return pht(
+ '%s reloaded this event source.',
+ $this->renderAuthor());
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 6:07 AM (8 h, 57 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6925188
Default Alt Text
D16747.id40333.diff (11 KB)
Attached To
Mode
D16747: Add an explicit "Reload Import" action to imports
Attached
Detach File
Event Timeline
Log In to Comment