|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Godbout\Alfred\Time\Menus\Harvest; |
|
4
|
|
|
|
|
5
|
|
|
use Godbout\Alfred\Time\Menus\Menu; |
|
6
|
|
|
use Godbout\Alfred\Time\Workflow; |
|
7
|
|
|
use Godbout\Alfred\Workflow\Icon; |
|
8
|
|
|
use Godbout\Alfred\Workflow\Item; |
|
9
|
|
|
use Godbout\Alfred\Workflow\ScriptFilter; |
|
10
|
|
|
|
|
11
|
|
|
class SetupCredentials extends Menu |
|
12
|
|
|
{ |
|
13
|
12 |
|
public static function scriptFilter() |
|
14
|
|
|
{ |
|
15
|
12 |
|
ScriptFilter::add( |
|
16
|
12 |
|
self::accountId(), |
|
17
|
12 |
|
self::apitoken(), |
|
18
|
12 |
|
self::back() |
|
19
|
|
|
); |
|
20
|
12 |
|
} |
|
21
|
|
|
|
|
22
|
12 |
|
private static function apitoken() |
|
23
|
|
|
{ |
|
24
|
12 |
|
return Item::create() |
|
25
|
12 |
|
->title(self::apitokenTitle()) |
|
26
|
12 |
|
->subtitle(self::apitokenSubtitle()) |
|
27
|
12 |
|
->arg('harvest_setup_apitoken') |
|
28
|
12 |
|
->icon(Icon::create('resources/icons/harvest.png')); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
12 |
|
private static function accountId() |
|
32
|
|
|
{ |
|
33
|
12 |
|
return Item::create() |
|
34
|
12 |
|
->title(self::accountIdTitle()) |
|
35
|
12 |
|
->subtitle(self::accountIdSubtitle()) |
|
36
|
12 |
|
->arg('harvest_setup_account_id') |
|
37
|
12 |
|
->icon(Icon::create('resources/icons/harvest.png')); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
12 |
|
private static function apitokenTitle() |
|
41
|
|
|
{ |
|
42
|
12 |
|
return empty(Workflow::getConfig()->read('harvest.api_token')) ? 'Set API token' : 'Update API token'; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
12 |
|
private static function apitokenSubtitle() |
|
46
|
|
|
{ |
|
47
|
12 |
|
$apitoken = Workflow::getConfig()->read('harvest.api_token'); |
|
48
|
|
|
|
|
49
|
12 |
|
return empty($apitoken) ? 'No API token found' : 'Current API token: ' . substr($apitoken, 0, 11) . '...'; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
12 |
|
private static function accountIdTitle() |
|
53
|
|
|
{ |
|
54
|
12 |
|
return empty(Workflow::getConfig()->read('harvest.account_id')) ? 'Set Account ID' : 'Update Account ID'; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
12 |
|
private static function accountIdSubtitle() |
|
58
|
|
|
{ |
|
59
|
12 |
|
$accountId = Workflow::getConfig()->read('harvest.account_id'); |
|
60
|
|
|
|
|
61
|
12 |
|
return empty($accountId) ? 'No Account ID found' : 'Current Account ID: ' . substr($accountId, 0, 4) . '...'; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
12 |
|
private static function back() |
|
65
|
|
|
{ |
|
66
|
12 |
|
return Item::create() |
|
67
|
12 |
|
->title('Back') |
|
68
|
12 |
|
->arg('harvest_setup') |
|
69
|
12 |
|
->icon(Icon::create('resources/icons/harvest.png')); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|