2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 } from './OnboardConstants.js';
21 import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js';
22 import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js';
23 import VersionsPageActionHelper from 'sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js';
25 import { itemTypes } from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js';
26 import PermissionsActionHelper from 'sdc-app/onboarding/permissions/PermissionsActionHelper.js';
27 import { actionTypes as filterActionTypes } from './filter/FilterConstants.js';
28 import { versionStatus } from 'sdc-app/common/helpers/ItemsHelperConstants.js';
30 const OnboardActionHelper = {
31 resetOnboardStore(dispatch) {
33 type: actionTypes.RESET_ONBOARD_STORE
36 changeActiveTab(dispatch, activeTab) {
38 type: actionTypes.CHANGE_ACTIVE_ONBOARD_TAB,
42 type: filterActionTypes.FILTER_DATA_CHANGED,
44 activeTab === tabsMapping.WORKSPACE
46 versionStatus: versionStatus.DRAFT
49 versionStatus: versionStatus.CERTIFIED
53 changeSearchValue(dispatch, searchValue, activeTab) {
55 type: actionTypes.CHANGE_SEARCH_VALUE,
56 payload: { searchValue, activeTab }
59 clearSearchValue(dispatch) {
61 type: actionTypes.CLEAR_SEARCH_VALUE,
63 searchValue: searchValueObj
68 loadVLMScreen(dispatch, { id: licenseModelId, name }, users, tab) {
69 if (tab === tabsMapping.WORKSPACE) {
70 VersionsPageActionHelper.fetchVersions(dispatch, {
71 itemId: licenseModelId,
72 itemType: itemTypes.LICENSE_MODEL
73 }).then(({ results }) => {
74 results = results.filter(
75 version => version.status === versionStatus.DRAFT
77 if (results.length !== 1) {
78 ScreensHelper.loadScreen(dispatch, {
79 screen: enums.SCREEN.VERSIONS_PAGE,
80 screenType: screenTypes.LICENSE_MODEL,
83 licenseModel: { name },
88 PermissionsActionHelper.fetchItemUsers(dispatch, {
89 itemId: licenseModelId,
92 ScreensHelper.loadLandingScreen(dispatch, {
93 screenType: screenTypes.LICENSE_MODEL,
94 props: { licenseModelId, version: results[0] }
100 if (tab === tabsMapping.CATALOG) {
101 ScreensHelper.loadScreen(dispatch, {
102 screen: enums.SCREEN.VERSIONS_PAGE,
103 screenType: screenTypes.LICENSE_MODEL,
106 licenseModel: { name },
112 loadVSPScreen(dispatch, softwareProduct, users, tab) {
114 id: softwareProductId,
115 vendorId: licenseModelId,
119 if (tab === tabsMapping.WORKSPACE) {
120 VersionsPageActionHelper.fetchVersions(dispatch, {
121 itemId: softwareProductId,
122 itemType: itemTypes.SOFTWARE_PRODUCT
123 }).then(({ results }) => {
124 results = results.filter(
125 version => version.status === versionStatus.DRAFT
127 if (results.length !== 1) {
128 ScreensHelper.loadScreen(dispatch, {
129 screen: enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE,
130 screenType: screenTypes.SOFTWARE_PRODUCT,
135 vendorId: licenseModelId,
142 PermissionsActionHelper.fetchItemUsers(dispatch, {
143 itemId: softwareProductId,
146 ScreensHelper.loadLandingScreen(dispatch, {
147 screenType: screenTypes.SOFTWARE_PRODUCT,
158 if (tab === tabsMapping.CATALOG) {
159 ScreensHelper.loadScreen(dispatch, {
160 screen: enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE,
161 screenType: screenTypes.SOFTWARE_PRODUCT,
166 vendorId: licenseModelId,
176 export default OnboardActionHelper;