1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Godbout\Alfred\Time\Menus\Clockify; |
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 Setup extends Menu |
12
|
|
|
{ |
13
|
30 |
|
public static function scriptFilter() |
14
|
|
|
{ |
15
|
30 |
|
ScriptFilter::add( |
16
|
30 |
|
self::apikey(), |
17
|
30 |
|
self::state(), |
18
|
30 |
|
self::back() |
19
|
|
|
); |
20
|
30 |
|
} |
21
|
|
|
|
22
|
30 |
|
private static function apikey() |
23
|
|
|
{ |
24
|
30 |
|
return Item::create() |
25
|
30 |
|
->title(self::apikeyTitle()) |
26
|
30 |
|
->subtitle(self::apikeySubtitle()) |
27
|
30 |
|
->arg('clockify_setup_apikey') |
28
|
30 |
|
->icon(Icon::create('resources/icons/clockify.png')); |
29
|
|
|
} |
30
|
|
|
|
31
|
30 |
|
private static function apikeyTitle() |
32
|
|
|
{ |
33
|
30 |
|
return empty(Workflow::getConfig()->read('clockify.api_token')) ? 'Set API KEY' : 'Update API KEY'; |
34
|
|
|
} |
35
|
|
|
|
36
|
30 |
|
private static function apikeySubtitle() |
37
|
|
|
{ |
38
|
30 |
|
$apikey = Workflow::getConfig()->read('clockify.api_token'); |
39
|
|
|
|
40
|
30 |
|
return empty($apikey) ? 'No API KEY found' : 'Current API KEY: ' . substr($apikey, 0, 11) . '...'; |
41
|
|
|
} |
42
|
|
|
|
43
|
30 |
|
private static function state() |
44
|
|
|
{ |
45
|
30 |
|
return Item::create() |
46
|
30 |
|
->title(self::stateTitle()) |
47
|
30 |
|
->subtitle(self::stateSubtitle()) |
48
|
30 |
|
->arg('clockify_setup_state') |
49
|
30 |
|
->variable('clockify_enabled', Workflow::getConfig()->read('clockify.is_active') ? 'false' : 'true') |
50
|
30 |
|
->icon(Icon::create('resources/icons/clockify.png')); |
51
|
|
|
} |
52
|
|
|
|
53
|
30 |
|
private static function stateTitle() |
54
|
|
|
{ |
55
|
30 |
|
return (Workflow::getConfig()->read('clockify.is_active') === true) ? 'Disable' : 'Enable'; |
56
|
|
|
} |
57
|
|
|
|
58
|
30 |
|
private static function stateSubtitle() |
59
|
|
|
{ |
60
|
30 |
|
return (Workflow::getConfig()->read('clockify.is_active') === true) ? 'Currently enabled' : 'Currently disabled'; |
61
|
|
|
} |
62
|
|
|
|
63
|
30 |
|
private static function back() |
64
|
|
|
{ |
65
|
30 |
|
return Item::create() |
66
|
30 |
|
->title('Back') |
67
|
30 |
|
->arg('setup') |
68
|
30 |
|
->icon(Icon::create('resources/icons/icon.png')); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|