foreman-tasks 8.1.2 → 8.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/app/lib/actions/action_with_sub_plans.rb +2 -10
  4. data/app/lib/actions/bulk_action.rb +5 -5
  5. data/app/lib/actions/observable_action.rb +11 -2
  6. data/foreman-tasks.gemspec +1 -1
  7. data/lib/foreman_tasks/version.rb +1 -1
  8. data/package.json +6 -11
  9. data/test/unit/actions/action_with_sub_plans_test.rb +4 -0
  10. data/test/unit/task_groups_test.rb +4 -0
  11. metadata +4 -18
  12. data/.yo-rc.json +0 -5
  13. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.stories.js +0 -9
  14. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.stories.js +0 -55
  15. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.stories.js +0 -56
  16. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.stories.js +0 -33
  17. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.stories.js +0 -72
  18. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.stories.js +0 -51
  19. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.stories.js +0 -26
  20. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.stories.js +0 -55
  21. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.stories.js +0 -21
  22. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.stories.mdx +0 -57
  23. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.stories.js +0 -40
  24. data/webpack/stories/decorators/index.js +0 -1
  25. data/webpack/stories/decorators/withCardsDecorator.js +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f756b8531e37e0f3e1b5c8656497ef1386484aae197a25be5b157343b65d3859
4
- data.tar.gz: 6e83619c23d91aeaf92d3ddd01a76bb65f331d5c48041f3e1aa037d97c3da4f6
3
+ metadata.gz: 4ea98197d16aef3c4ca8f16c10b9533f7e89e916c8cefffed1e8523966dc85fa
4
+ data.tar.gz: fee12ffd69d32683f091f49c1362df778523a29bba97d411931c0608cedd19cc
5
5
  SHA512:
6
- metadata.gz: 96d0a2eb2c41ec9643119c8bb7e0447ddb43f249cf4d217713c77042fabdb54da44b635c9e4d538b9daca760fec82077810e31d684122313dc9fb1191a77c59f
7
- data.tar.gz: 73e47dceafb38096f63cf605d8016a3dfb112cc5320f2dd70fb527c805c99f86255c882e40b7504f9383e03dc441802b0cf208d4957ea3c77fde4b7dc5d93154
6
+ metadata.gz: fbeafbdf22b249957160385253f62b1f901cd4faca182c47fe5f637a375f55e98b57d7fe28ab814bf3f5fadb11aac50133b7f291e6371e2e1a8896c136410c4e
7
+ data.tar.gz: 946b98f863337862dfbd3b1cf6bd421b139836cd2920368e5642e50aed3a7ba1118bed49d481ee3e2ef208acd921275bcc3ef4c5b7316b1199b894cecbb715e2
data/.gitignore CHANGED
@@ -16,4 +16,3 @@ locale/*/*.po.time_stamp
16
16
  node_modules
17
17
  package-lock.json
18
18
  coverage/
19
- .storybook-dist
@@ -1,6 +1,6 @@
1
1
  module Actions
2
2
  class Actions::ActionWithSubPlans < Actions::EntryAction
3
- include Dynflow::Action::WithSubPlans
3
+ include Dynflow::Action::V2::WithSubPlans
4
4
 
5
5
  def plan(*_args)
6
6
  raise NotImplementedError
@@ -9,17 +9,9 @@ module Actions
9
9
  def humanized_output
10
10
  return unless counts_set?
11
11
  _('%{total} task(s), %{success} success, %{failed} fail') %
12
- { total: output[:total_count],
12
+ { total: total_count,
13
13
  success: output[:success_count],
14
14
  failed: output[:failed_count] }
15
15
  end
16
-
17
- def run_progress
18
- if counts_set? && output[:total_count] > 0
19
- (output[:success_count] + output[:failed_count]).to_f / output[:total_count]
20
- else
21
- 0.1
22
- end
23
- end
24
16
  end
25
17
  end
@@ -1,7 +1,5 @@
1
1
  module Actions
2
2
  class BulkAction < Actions::ActionWithSubPlans
3
- include Dynflow::Action::WithBulkSubPlans
4
-
5
3
  # == Parameters:
6
4
  # actions_class::
7
5
  # Class of action to trigger on targets
@@ -9,12 +7,14 @@ module Actions
9
7
  # Array of objects on which the action_class should be triggered
10
8
  # *args::
11
9
  # Arguments that all the targets share
12
- def plan(action_class, targets, *args)
10
+ def plan(action_class, targets, *args, concurrency_limit: nil, **kwargs)
13
11
  check_targets!(targets)
12
+ limit_concurrency_level!(concurrency_limit) if concurrency_limit
14
13
  plan_self(:action_class => action_class.to_s,
15
14
  :target_ids => targets.map(&:id),
16
15
  :target_class => targets.first.class.to_s,
17
- :args => args)
16
+ :args => args,
17
+ :kwargs => kwargs)
18
18
  end
19
19
 
20
20
  def run(event = nil)
@@ -51,7 +51,7 @@ module Actions
51
51
  missing = Array.new((current_batch - targets.map(&:id)).count) { nil }
52
52
 
53
53
  (targets + missing).map do |target|
54
- trigger(action_class, target, *input[:args])
54
+ trigger(action_class, target, *input[:args], **input[:kwargs])
55
55
  end
56
56
  end
57
57
 
@@ -36,7 +36,7 @@ module Actions
36
36
  end
37
37
 
38
38
  def event_names
39
- [event_name_base + '_' + event_name_suffix(:success)]
39
+ [:success, :failure].map { |suffix| event_name_base + '_' + event_name_suffix(suffix) }
40
40
  end
41
41
 
42
42
  def namespaced_event_names
@@ -51,7 +51,16 @@ module Actions
51
51
  def self.included(base)
52
52
  base.extend ClassMethods
53
53
  base.include ::Foreman::Observable
54
- base.execution_plan_hooks.use :emit_event, :on => :success
54
+ base.execution_plan_hooks.use :emit_event_success, :on => :success
55
+ base.execution_plan_hooks.use :emit_event_failure, :on => :failure
56
+ end
57
+
58
+ def emit_event_success(execution_plan)
59
+ emit_event(execution_plan, :success)
60
+ end
61
+
62
+ def emit_event_failure(execution_plan)
63
+ emit_event(execution_plan, :failure)
55
64
  end
56
65
 
57
66
  def emit_event(execution_plan, hook = :success)
@@ -26,7 +26,7 @@ same resource. It also optionally provides Dynflow infrastructure for using it f
26
26
  s.test_files = `git ls-files test`.split("\n")
27
27
  s.extra_rdoc_files = Dir['README*', 'LICENSE']
28
28
 
29
- s.add_dependency "dynflow", '>= 1.6.0'
29
+ s.add_dependency "dynflow", '>= 1.8.0'
30
30
  s.add_dependency 'fugit', '~> 1.8'
31
31
  s.add_dependency "get_process_mem" # for memory polling
32
32
  s.add_dependency "sinatra" # for Dynflow web console
@@ -1,3 +1,3 @@
1
1
  module ForemanTasks
2
- VERSION = '8.1.2'.freeze
2
+ VERSION = '8.3.0'.freeze
3
3
  end
data/package.json CHANGED
@@ -9,11 +9,7 @@
9
9
  "test": "tfm-test --plugin",
10
10
  "test:watch": "tfm-test --plugin --watchAll",
11
11
  "test:current": "tfm-test --plugin --watch",
12
- "publish-coverage": "tfm-publish-coverage",
13
- "stories": "tfm-stories --plugin",
14
- "stories:build": "tfm-build-stories --plugin",
15
- "stories:deploy": "surge --project .storybook-dist",
16
- "create-react-component": "yo react-domain"
12
+ "publish-coverage": "tfm-publish-coverage"
17
13
  },
18
14
  "repository": {
19
15
  "type": "git",
@@ -23,18 +19,17 @@
23
19
  "url": "http://projects.theforeman.org/projects/foreman-tasks/issues"
24
20
  },
25
21
  "peerDependencies": {
26
- "@theforeman/vendor": ">= 10.1.0"
22
+ "@theforeman/vendor": ">= 12.1.1"
27
23
  },
28
24
  "dependencies": {
29
25
  "c3": "^0.4.11"
30
26
  },
31
27
  "devDependencies": {
32
28
  "@babel/core": "^7.7.0",
33
- "@theforeman/builder": ">= 10.1.0",
34
- "@theforeman/eslint-plugin-foreman": ">= 10.1.0",
35
- "@theforeman/stories": ">= 10.1.0",
36
- "@theforeman/test": ">= 10.1.0",
37
- "@theforeman/vendor-dev": ">= 10.1.0",
29
+ "@theforeman/builder": ">= 12.1.1",
30
+ "@theforeman/eslint-plugin-foreman": ">= 12.1.1",
31
+ "@theforeman/test": ">= 12.1.1",
32
+ "@theforeman/vendor-dev": ">= 12.1.1",
38
33
  "babel-eslint": "^10.0.3",
39
34
  "eslint": "^6.7.2",
40
35
  "jed": "^1.1.1",
@@ -20,6 +20,10 @@ module ForemanTasks
20
20
  user = User.find(input[:user_id])
21
21
  trigger(ChildAction, user)
22
22
  end
23
+
24
+ def total_count
25
+ 1
26
+ end
23
27
  end
24
28
 
25
29
  class ChildAction < Actions::EntryAction
@@ -27,6 +27,10 @@ module ForemanTasks
27
27
  def create_sub_plans
28
28
  Array.new(input[:count]) { |i| trigger InheritingChildAction, i + 2 }
29
29
  end
30
+
31
+ def total_count
32
+ input[:count]
33
+ end
30
34
  end
31
35
 
32
36
  class ChildAction < Actions::EntryAction
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman-tasks
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.2
4
+ version: 8.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Nečas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-25 00:00:00.000000000 Z
11
+ date: 2023-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dynflow
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.6.0
19
+ version: 1.8.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.6.0
26
+ version: 1.8.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fugit
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -116,7 +116,6 @@ files:
116
116
  - ".rubocop_todo.yml"
117
117
  - ".stylelintrc"
118
118
  - ".tx/config"
119
- - ".yo-rc.json"
120
119
  - Gemfile
121
120
  - LICENSE
122
121
  - README.md
@@ -413,7 +412,6 @@ files:
413
412
  - webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap
414
413
  - webpack/ForemanTasks/Components/TaskDetails/TaskDetails.js
415
414
  - webpack/ForemanTasks/Components/TaskDetails/TaskDetails.scss
416
- - webpack/ForemanTasks/Components/TaskDetails/TaskDetails.stories.js
417
415
  - webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js
418
416
  - webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js
419
417
  - webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js
@@ -425,23 +423,19 @@ files:
425
423
  - webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsActions.test.js.snap
426
424
  - webpack/ForemanTasks/Components/TaskDetails/index.js
427
425
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.js
428
- - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.stories.js
429
426
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.test.js
430
427
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/__snapshots__/PausedTasksCard.test.js.snap
431
428
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.js
432
- - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.stories.js
433
429
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.test.js
434
430
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/__snapshots__/RunningTasksCard.test.js.snap
435
431
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.js
436
432
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.scss
437
- - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.stories.js
438
433
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.test.js
439
434
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/__snapshots__/ScheduledTasksCard.test.js.snap
440
435
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.js
441
436
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.test.js
442
437
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.js
443
438
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.scss
444
- - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.stories.js
445
439
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js
446
440
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardTable.js
447
441
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardTable.test.js
@@ -450,12 +444,10 @@ files:
450
444
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCardTable.test.js.snap
451
445
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.js
452
446
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.scss
453
- - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.stories.js
454
447
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.test.js
455
448
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/__snapshots__/TasksDonutCard.test.js.snap
456
449
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.js
457
450
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.scss
458
- - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.stories.js
459
451
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.test.js
460
452
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChartConstants.js
461
453
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChartHelper.js
@@ -464,21 +456,17 @@ files:
464
456
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/__snapshots__/TasksDonutChartHelper.test.js.snap
465
457
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.fixtures.js
466
458
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.js
467
- - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.stories.js
468
459
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.test.js
469
460
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/__snapshots__/TasksCardsGrid.test.js.snap
470
461
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.js
471
462
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.scss
472
- - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.stories.js
473
463
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
474
464
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/__snapshots__/TasksLabelsRow.test.js.snap
475
465
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.js
476
- - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.stories.mdx
477
466
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.test.js
478
467
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/__snapshots__/TimeDropDown.test.js.snap
479
468
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.js
480
469
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.scss
481
- - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.stories.js
482
470
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.test.js
483
471
  - webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/__snapshots__/TasksTimeRow.test.js.snap
484
472
  - webpack/ForemanTasks/Components/TasksDashboard/TasksDashboard.js
@@ -621,8 +609,6 @@ files:
621
609
  - webpack/__mocks__/foremanReact/routes/common/PageLayout/PageLayout.js
622
610
  - webpack/__mocks__/foremanReact/routes/common/PageLayout/components/ExportButton/ExportButton.js
623
611
  - webpack/index.js
624
- - webpack/stories/decorators/index.js
625
- - webpack/stories/decorators/withCardsDecorator.js
626
612
  homepage: https://github.com/theforeman/foreman-tasks
627
613
  licenses:
628
614
  - GPL-3.0
data/.yo-rc.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "generator-react-domain": {
3
- "depsInstalled": true
4
- }
5
- }
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import TaskDetails from './TaskDetails';
3
-
4
- export default {
5
- title: 'TaskDetails',
6
- component: TaskDetails,
7
- };
8
-
9
- export const Basic = () => <TaskDetails />;
@@ -1,55 +0,0 @@
1
- import React from 'react';
2
- import { action, number, select } from '@theforeman/stories';
3
- import { withCardsDecorator } from '../../../../../../../stories/decorators';
4
-
5
- import {
6
- TASKS_DASHBOARD_AVAILABLE_QUERY_MODES,
7
- TASKS_DASHBOARD_AVAILABLE_TIMES,
8
- TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
9
- } from '../../../../TasksDashboardConstants';
10
- import PausedTasksCard from './PausedTasksCard';
11
-
12
- export default {
13
- title: 'TasksDashboard/TasksCardsGrid/Cards/PausedTasksCard',
14
- component: PausedTasksCard,
15
- decorators: [withCardsDecorator],
16
- parameters: {
17
- centered: { disable: true },
18
- },
19
- };
20
-
21
- export const Basic = () => {
22
- const selectTime = select(
23
- 'time',
24
- TASKS_DASHBOARD_AVAILABLE_TIMES,
25
- PausedTasksCard.defaultProps.time
26
- );
27
-
28
- const selectMode = select(
29
- 'mode',
30
- { ...TASKS_DASHBOARD_AVAILABLE_QUERY_MODES, NONE: 'none', TOTAL: null },
31
- 'none'
32
- );
33
- return (
34
- <PausedTasksCard
35
- data={{
36
- last: number('data.last', 3),
37
- older: number('data.older', 5),
38
- }}
39
- time={selectTime}
40
- query={{
41
- state: select(
42
- 'query.state',
43
- {
44
- ...TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
45
- NONE: null,
46
- },
47
- TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.PAUSED
48
- ),
49
- mode: selectMode,
50
- time: selectTime,
51
- }}
52
- updateQuery={action('updateQuery')}
53
- />
54
- );
55
- };
@@ -1,56 +0,0 @@
1
- import React from 'react';
2
- import { number, select, action } from '@theforeman/stories';
3
-
4
- import { withCardsDecorator } from '../../../../../../../stories/decorators';
5
-
6
- import {
7
- TASKS_DASHBOARD_AVAILABLE_QUERY_MODES,
8
- TASKS_DASHBOARD_AVAILABLE_TIMES,
9
- TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
10
- } from '../../../../TasksDashboardConstants';
11
- import RunningTasksCard from './RunningTasksCard';
12
-
13
- export default {
14
- title: 'TasksDashboard/TasksCardsGrid/Cards/RunningTasksCard',
15
- component: RunningTasksCard,
16
- decorators: [withCardsDecorator],
17
- parameters: {
18
- centered: { disable: true },
19
- },
20
- };
21
-
22
- export const Basic = () => {
23
- const selectTime = select(
24
- 'time',
25
- TASKS_DASHBOARD_AVAILABLE_TIMES,
26
- RunningTasksCard.defaultProps.time
27
- );
28
-
29
- const selectMode = select(
30
- 'mode',
31
- { ...TASKS_DASHBOARD_AVAILABLE_QUERY_MODES, NONE: 'none', TOTAL: null },
32
- 'none'
33
- );
34
- return (
35
- <RunningTasksCard
36
- data={{
37
- last: number('data.last', 3),
38
- older: number('data.older', 5),
39
- }}
40
- time={selectTime}
41
- query={{
42
- state: select(
43
- 'query.state',
44
- {
45
- ...TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
46
- NONE: null,
47
- },
48
- TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.RUNNING
49
- ),
50
- mode: selectMode,
51
- time: selectTime,
52
- }}
53
- updateQuery={action('updateQuery')}
54
- />
55
- );
56
- };
@@ -1,33 +0,0 @@
1
- import React from 'react';
2
- import { number, select, action } from '@theforeman/stories';
3
-
4
- import { withCardsDecorator } from '../../../../../../../stories/decorators';
5
-
6
- import { TASKS_DASHBOARD_AVAILABLE_QUERY_STATES } from '../../../../TasksDashboardConstants';
7
- import ScheduledTasksCard from './ScheduledTasksCard';
8
-
9
- export default {
10
- title: 'TasksDashboard/TasksCardsGrid/Cards/ScheduledTasksCard',
11
- component: ScheduledTasksCard,
12
- decorators: [withCardsDecorator],
13
- parameters: {
14
- centered: { disable: true },
15
- },
16
- };
17
-
18
- export const Basic = () => {
19
- const selectState = select(
20
- 'query.state',
21
- { ...TASKS_DASHBOARD_AVAILABLE_QUERY_STATES, NONE: 'none' },
22
- 'none'
23
- );
24
- return (
25
- <ScheduledTasksCard
26
- data={number('data', 1)}
27
- query={{
28
- state: selectState,
29
- }}
30
- updateQuery={action('updateQuery')}
31
- />
32
- );
33
- };
@@ -1,72 +0,0 @@
1
- import React from 'react';
2
- import { number, select, action } from '@theforeman/stories';
3
-
4
- import { withCardsDecorator } from '../../../../../../../stories/decorators';
5
-
6
- import {
7
- TASKS_DASHBOARD_AVAILABLE_TIMES,
8
- TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
9
- TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS,
10
- TASKS_DASHBOARD_AVAILABLE_QUERY_MODES,
11
- } from '../../../../TasksDashboardConstants';
12
- import StoppedTasksCard from './StoppedTasksCard';
13
-
14
- export default {
15
- title: 'TasksDashboard/TasksCardsGrid/Cards/StoppedTasksCard',
16
- component: StoppedTasksCard,
17
- decorators: [withCardsDecorator],
18
- parameters: {
19
- centered: { disable: true },
20
- },
21
- };
22
-
23
- export const Basic = () => {
24
- const selectTime = select(
25
- 'time',
26
- TASKS_DASHBOARD_AVAILABLE_TIMES,
27
- StoppedTasksCard.defaultProps.time
28
- );
29
- const selectState = select(
30
- 'query.state',
31
- { ...TASKS_DASHBOARD_AVAILABLE_QUERY_STATES, NONE: null },
32
- TASKS_DASHBOARD_AVAILABLE_QUERY_STATES.STOPPED
33
- );
34
- const selectResult = select(
35
- 'query.result',
36
- { ...TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS, NONE: null },
37
- null
38
- );
39
- const selectMode = select(
40
- 'query.mode',
41
- { ...TASKS_DASHBOARD_AVAILABLE_QUERY_MODES, NONE: null },
42
- null
43
- );
44
- return (
45
- <div>
46
- <StoppedTasksCard
47
- data={{
48
- error: {
49
- total: number('errorTotal', 8),
50
- last: number('errorLast', 1),
51
- },
52
- warning: {
53
- total: number('warningTotal', 20),
54
- last: number('warningLast', 2),
55
- },
56
- success: {
57
- total: number('successTotal', 25),
58
- last: number('successLast', 3),
59
- },
60
- }}
61
- time={selectTime}
62
- query={{
63
- state: selectState,
64
- result: selectResult,
65
- mode: selectMode,
66
- time: selectTime,
67
- }}
68
- updateQuery={action('updateQuery')}
69
- />
70
- </div>
71
- );
72
- };
@@ -1,51 +0,0 @@
1
- import React from 'react';
2
- import { number, text, select, action } from '@theforeman/stories';
3
-
4
- import { withCardsDecorator } from '../../../../../../../stories/decorators';
5
-
6
- import {
7
- TASKS_DASHBOARD_AVAILABLE_QUERY_MODES,
8
- TASKS_DASHBOARD_AVAILABLE_TIMES,
9
- } from '../../../../TasksDashboardConstants';
10
- import TasksDonutCard from './TasksDonutCard';
11
-
12
- export default {
13
- title: 'TasksDashboard/TasksCardsGrid/Cards/TasksDonutCard',
14
- component: TasksDonutCard,
15
- decorators: [withCardsDecorator],
16
- parameters: {
17
- centered: { disable: true },
18
- },
19
- };
20
-
21
- export const Basic = () => {
22
- const selectTime = select(
23
- 'time',
24
- TASKS_DASHBOARD_AVAILABLE_TIMES,
25
- TasksDonutCard.defaultProps.time
26
- );
27
-
28
- const selectMode = select(
29
- 'mode',
30
- { ...TASKS_DASHBOARD_AVAILABLE_QUERY_MODES, NONE: 'none' },
31
- 'none'
32
- );
33
-
34
- return (
35
- <TasksDonutCard
36
- title={text('title', 'Some Title')}
37
- data={{
38
- last: number('data.last', 3),
39
- older: number('data.older', 5),
40
- }}
41
- time={selectTime}
42
- query={{
43
- state: text('query.state', 'some-state'),
44
- mode: selectMode,
45
- time: selectTime,
46
- }}
47
- wantedQueryState={text('wantedQueryState', 'wanted-state')}
48
- updateQuery={action('updateQuery')}
49
- />
50
- );
51
- };
@@ -1,26 +0,0 @@
1
- import React from 'react';
2
- import { number, text, select, action } from '@theforeman/stories';
3
-
4
- import { TASKS_DONUT_CHART_FOCUSED_ON_OPTIONS_ARRAY } from './TasksDonutChartConstants';
5
- import TasksDonutChart from './TasksDonutChart';
6
-
7
- export default {
8
- title: 'TasksDashboard/TasksCardsGrid/Charts/TasksDonutChart',
9
- component: TasksDonutChart,
10
- };
11
-
12
- export const Basic = () => (
13
- <TasksDonutChart
14
- last={number('last', 3)}
15
- older={number('older', 5)}
16
- time={text('time', '24h')}
17
- focusedOn={select(
18
- 'focusedOn',
19
- TASKS_DONUT_CHART_FOCUSED_ON_OPTIONS_ARRAY,
20
- TasksDonutChart.defaultProps.focusedOn
21
- )}
22
- onTotalClick={action('onTotalClick')}
23
- onLastClick={action('onLastClick')}
24
- onOlderClick={action('onOlderClick')}
25
- />
26
- );
@@ -1,55 +0,0 @@
1
- import React from 'react';
2
- import { object, select, action } from '@theforeman/stories';
3
-
4
- import {
5
- TASKS_DASHBOARD_AVAILABLE_TIMES,
6
- TASKS_DASHBOARD_AVAILABLE_QUERY_STATES,
7
- TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS,
8
- TASKS_DASHBOARD_AVAILABLE_QUERY_MODES,
9
- } from '../../TasksDashboardConstants';
10
- import { MOCKED_DATA } from './TasksCardsGrid.fixtures';
11
- import TasksCardsGrid from './TasksCardsGrid';
12
-
13
- export default {
14
- title: 'TasksDashboard/TasksCardsGrid/TasksCardsGrid',
15
- component: TasksCardsGrid,
16
- };
17
-
18
- const createSelect = (name, options) =>
19
- select(name, { ...options, NONE: 'none' }, 'none');
20
-
21
- export const Basic = () => {
22
- const selectTime = select(
23
- 'time',
24
- TASKS_DASHBOARD_AVAILABLE_TIMES,
25
- TasksCardsGrid.defaultProps.time
26
- );
27
- const selectState = createSelect(
28
- 'query.state',
29
- TASKS_DASHBOARD_AVAILABLE_QUERY_STATES
30
- );
31
- const selectResult = createSelect(
32
- 'query.result',
33
- TASKS_DASHBOARD_AVAILABLE_QUERY_RESULTS
34
- );
35
- const selectMode = createSelect(
36
- 'query.mode',
37
- TASKS_DASHBOARD_AVAILABLE_QUERY_MODES
38
- );
39
-
40
- return (
41
- <div>
42
- <TasksCardsGrid
43
- time={selectTime}
44
- query={{
45
- state: selectState,
46
- result: selectResult,
47
- mode: selectMode,
48
- time: selectTime,
49
- }}
50
- data={object('data', MOCKED_DATA)}
51
- updateQuery={action('updateQuery')}
52
- />
53
- </div>
54
- );
55
- };
@@ -1,21 +0,0 @@
1
- import React from 'react';
2
- import { object, action } from '@theforeman/stories';
3
-
4
- import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../TasksDashboardConstants';
5
- import TasksLabelsRow from './TasksLabelsRow';
6
-
7
- export default {
8
- title: 'TasksDashboard/TasksLabelsRow',
9
- component: TasksLabelsRow,
10
- };
11
-
12
- export const Basic = () => (
13
- <TasksLabelsRow
14
- query={object('query', {
15
- state: 'running',
16
- mode: 'last',
17
- time: TASKS_DASHBOARD_AVAILABLE_TIMES.H24,
18
- })}
19
- updateQuery={action('updateQuery')}
20
- />
21
- );
@@ -1,57 +0,0 @@
1
- import { Meta, Story, Preview, Props, action } from '@theforeman/stories';
2
-
3
- import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../../../TasksDashboardConstants';
4
- import TimeDropDown from './TimeDropDown';
5
-
6
- <Meta
7
- title="TasksDashboard/TasksTimeRow/TimeDropDown"
8
- component={TimeDropDown}
9
- />
10
-
11
- # TimeDropDown
12
-
13
- Render a dropdown with the available dashboard times to render.
14
-
15
- <Props of={TimeDropDown} />
16
-
17
- The available-times defined as a constant at `Components/TasksDashboard/TasksDashboardConstants.js`:
18
-
19
- ```js
20
- import { TASKS_DASHBOARD_AVAILABLE_TIMES } from './Components/TasksDashboard/TasksDashboardConstants';
21
- ```
22
-
23
- To set the current selected time, set the `selectedTime` prop to `TASKS_DASHBOARD_AVAILABLE_TIMES.H24`.
24
-
25
- <Preview>
26
- <Story name="24 hours">
27
- <TimeDropDown
28
- id="time-period-dropdown"
29
- selectedTime={TASKS_DASHBOARD_AVAILABLE_TIMES.H24}
30
- onChange={action('onChange')}
31
- />
32
- </Story>
33
- </Preview>
34
-
35
- To set the current selected time, set the `selectedTime` prop to `TASKS_DASHBOARD_AVAILABLE_TIMES.H12`.
36
-
37
- <Preview>
38
- <Story name="12 hours">
39
- <TimeDropDown
40
- id="time-period-dropdown"
41
- selectedTime={TASKS_DASHBOARD_AVAILABLE_TIMES.H12}
42
- onChange={action('onChange')}
43
- />
44
- </Story>
45
- </Preview>
46
-
47
- To set the current selected time, set the `selectedTime` prop to `TASKS_DASHBOARD_AVAILABLE_TIMES.WEEK`.
48
-
49
- <Preview>
50
- <Story name="week">
51
- <TimeDropDown
52
- id="time-period-dropdown"
53
- selectedTime={TASKS_DASHBOARD_AVAILABLE_TIMES.WEEK}
54
- onChange={action('onChange')}
55
- />
56
- </Story>
57
- </Preview>
@@ -1,40 +0,0 @@
1
- /* eslint-disable react-hooks/rules-of-hooks */
2
- import React, { useState } from 'react';
3
- import { select, action } from '@theforeman/stories';
4
-
5
- import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../TasksDashboardConstants';
6
- import TasksTimeRow from './TasksTimeRow';
7
-
8
- export default {
9
- title: 'TasksDashboard/TasksTimeRow',
10
- component: TasksTimeRow,
11
- };
12
-
13
- export const withState = () => {
14
- const [time, updateTime] = useState(TASKS_DASHBOARD_AVAILABLE_TIMES.H24);
15
-
16
- return <TasksTimeRow time={time} updateTime={updateTime} />;
17
- };
18
-
19
- export const withKnobs = () => (
20
- <TasksTimeRow
21
- time={select(
22
- 'time',
23
- TASKS_DASHBOARD_AVAILABLE_TIMES,
24
- TASKS_DASHBOARD_AVAILABLE_TIMES.H24
25
- )}
26
- updateTime={action('updateTime')}
27
- />
28
- );
29
-
30
- export const with24Hours = () => (
31
- <TasksTimeRow time={TASKS_DASHBOARD_AVAILABLE_TIMES.H24} />
32
- );
33
-
34
- export const with12Hours = () => (
35
- <TasksTimeRow time={TASKS_DASHBOARD_AVAILABLE_TIMES.H12} />
36
- );
37
-
38
- export const withWeek = () => (
39
- <TasksTimeRow time={TASKS_DASHBOARD_AVAILABLE_TIMES.WEEK} />
40
- );
@@ -1 +0,0 @@
1
- export * from './withCardsDecorator';
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
-
3
- export const withCardsDecorator = storyFn => (
4
- <div
5
- style={{
6
- width: '100%',
7
- height: '100vh',
8
- backgroundColor: '#F5F5F5',
9
- padding: '50px',
10
- }}
11
- >
12
- <div style={{ width: '300px', margin: 'auto' }}>{storyFn()}</div>
13
- </div>
14
- );