Page MenuHomePhabricator

Moderize Countdown
ClosedPublic

Authored by chad on Jul 20 2015, 6:24 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Dec 21, 5:23 PM
Unknown Object (File)
Thu, Dec 19, 12:56 AM
Unknown Object (File)
Mon, Dec 16, 6:35 PM
Unknown Object (File)
Mon, Dec 16, 2:39 PM
Unknown Object (File)
Fri, Dec 13, 1:20 AM
Unknown Object (File)
Tue, Dec 3, 1:26 PM
Unknown Object (File)
Tue, Dec 3, 1:26 PM
Unknown Object (File)
Tue, Dec 3, 1:26 PM

Details

Reviewers
epriestley
btrahan
Maniphest Tasks
T8895: Modernize Countdown
Commits
Restricted Diffusion Commit
rPfdd6351a64a0: Moderize Countdown
Summary

[DRAFT] Ref T8895. Makes a reasonable attempt at:

  • Project Support
  • Timeline / History
  • Better Search
  • Better ObjectItemLists
Test Plan

Needs better testing (I'm sleepy)

Diff Detail

Repository
rP Phabricator
Branch
countdown-projects
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 7324
Build 7688: [Placeholder Plan] Wait for 30 Seconds
Build 7687: arc lint + arc unit

Event Timeline

chad retitled this revision from to Moderize Countdown.
chad updated this object.
chad edited the test plan for this revision. (Show Details)
chad added reviewers: epriestley, btrahan.
epriestley edited edge metadata.

This is great!

I think I caught one actual bug (getTitle() instead of getEpoch() in the Editor). Otherwise just various nits / modernization things.

resources/sql/autopatches/20150719.countdown.2.sql
2–3

We should also set all existing countdowns to have the authorPHID as the edit policy, to preserve the old behavior (e.g., if only alincoln could edit a countdown before this change, only alincoln should be able to edit it after this change).

To do this, you can add a third patch like this:

UPDATE {$NAMESPACE}_countdown.countdown SET editPolicy = authorPHID WHERE editPolicy = '';

That will copy the authorPHID into the editPolicy for countdowns with no edit policy. User PHIDs as policies mean "just that user", so this will preserve the old policy.

src/applications/countdown/controller/PhabricatorCountdownEditController.php
5–6

You can delete this stuff now after modernizing with handleRequest().

10

You should read id out of the $request, using $request->getURIData('id'), and remove the $id property on the class. Generally, modern stuff should usually look something like:

final class SomethingWhateverController
  extends SomethingController {

  // Most controllers now have no properties. A few complex controllers still will.
  // Most controllers now have no willProcessRequest() method.

  public function handleRequest(AphrontRequest $request) {
    $viewer = $this->getViewer();

    // Read any URI properties from `$request` here, into local variables.
    $id = $request->getURIData('id');
    if ($id) {
      // ...

Overall, the goal of this change is just to make controllers a bit simpler -- before, like 50% of them had an $id property (or something similar) which was used in ~1 place and a willProcessRequest() method that did almost nothing. The new way isn't a big change, but gives us like 5 lines of code instead of 10, and is a bit simpler, especially for small controllers.

34

Minor, but prefer PhabricatorTime::getNow() to time() (see T6991).

108–109

There's a task for cleaning this up somewhere, but this way of doing things is a little out of date.

Instead, just call setValue($v_view) on the AphrontPolicyControl, like how every other control works. You'll also need to initialize $v_view and $v_edit near line 48, where other properties are initialized.

This change just makes policy handling more consistent, so the policy controls work like other controls do instead of in a special way.

144–146

Very minor, but you can appendControl() instead of appendChild() to get setUser() for free. That is, this:

id(new AphrontFormView())
  ->appendChild(
    id(new SomeControl())
      ->setUser($viewer))

...can be simplified slightly like this, which is equivalent:

id(new AphrontFormView())
  ->appendControl(
    id(new SomeControl()))
172

(One level too-indented?)

src/applications/countdown/controller/PhabricatorCountdownViewController.php
35

Prefer PhabricatorTime::getNow().

src/applications/countdown/editor/PhabricatorCountdownEditor.php
36

This should likely be getEpoch() or something simialr.

141

Not quite English.

src/applications/countdown/query/PhabricatorCountdownQuery.php
26–32

To make this more general, it might be better structured as withEndDateInRange($start, $end) or similar, where either parameter can be null to indicate that you don't care (i.e., an open-ended range). You can look at PhabricatorWorkerTriggerQuery->withNextEventBetween() for an example of how to implement this. This isn't too important, but increases the generality of the query at little cost.

src/applications/countdown/query/PhabricatorCountdownSearchEngine.php
106

(Indent one off?)

src/applications/countdown/storage/PhabricatorCountdown.php
112–114

Maybe we should consider removing this automatic capability now that there's a real edit policy, although I don't think it's too important and giving the author special privileges seems reasonable-ish.

This revision now requires changes to proceed.Jul 20 2015, 8:06 PM
src/applications/countdown/editor/PhabricatorCountdownEditor.php
36

omg i spent at least 30 minutes trying to find this bug last night.

eadler added inline comments.
src/applications/countdown/storage/PhabricatorCountdown.php
112–114

I'd rather see countdown objects work like any other policy applicable object and the author shouldn't get special permissions

chad marked 14 inline comments as done.Jul 20 2015, 9:59 PM
chad added inline comments.
src/applications/countdown/storage/PhabricatorCountdown.php
112–114

Most objects give the author special permissions. In fact I can't find an example that doesn't offhand.

chad added inline comments.
src/applications/countdown/storage/PhabricatorCountdown.php
112–114

Ohhh.... I'm confusing author/owner. In that case it seems split randomly. In things we assume ownership will tend to stay with authorship, we grant the permissions (like Paste, Pholio, Legalpad). Things that seem more transitory, we go with owner (Task).

chad edited edge metadata.
chad marked 2 inline comments as done.
  • Updates per comments.
chad edited edge metadata.
  • Copy/Paste similar date range searching ala Calendar
  • return false on automatic capabilities?

We should be able to do that date stuff a lot more simply, but I might need to fix SearchEngine or add a new field type or something. Let me figure that out so I can give you guidance on it. Calendar isn't a great example because it's burdened by a bunch of legacy/complexity stuff.

epriestley edited edge metadata.

I think providing a path forward isn't trivial, so how about this for now:

  • Remove "Start Date Range" control from UI.
  • Remove "End Date Range" control from UI.
  • Remove getQueryDateRange() and getSafeDate() methods on the SearchEngine.
  • Make "upcoming" just do withDateRange(PhabricatorTime::getNow(), null) if set.
  • (The Query implementation is great as-is, and doesn't need to change at all.)

Then we can land this and I can sort out the controls later.

If you really want the controls now, I can work on sorting out the field values now -- specifically, you should not need getQueryDateRange() or getSafeDate() to implement a control of this type -- but this seems probably-not-critical.

This revision now requires changes to proceed.Jul 21 2015, 11:53 AM
chad edited edge metadata.
  • Just use "Upcoming"
epriestley edited edge metadata.
This revision is now accepted and ready to land.Jul 22 2015, 8:25 PM
This revision was automatically updated to reflect the committed changes.