2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
16 import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js';
17 import Configuration from 'sdc-app/config/Configuration.js';
18 import {permissionTypes} from 'sdc-app/onboarding/permissions/PermissionsConstants.js';
19 import {actionsEnum as VersionControllerActionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
20 import {actionTypes as onboardingActionTypes} from 'sdc-app/onboarding/OnboardingConstants.js';
23 const restPrefix = Configuration.get('restPrefix');
24 return `${restPrefix}/v1.0/items`;
28 performVCAction({itemId, version, action, comment}) {
29 const {id: versionId} = version;
32 ...action === VersionControllerActionsEnum.COMMIT && {commitRequest: {message: comment}}
34 return RestAPIUtil.put(`${baseUrl()}/${itemId}/versions/${versionId}/actions`, data);
37 fetchVersions({itemId}) {
38 return RestAPIUtil.fetch(`${baseUrl()}/${itemId}/versions`);
41 fetchVersion({itemId, versionId}) {
42 return RestAPIUtil.fetch(`${baseUrl()}/${itemId}/versions/${versionId}`);
45 fetchActivityLog({itemId, versionId}) {
46 return RestAPIUtil.fetch(`${baseUrl()}/${itemId}/versions/${versionId}/activity-logs`);
49 fetchUsers({itemId}) {
50 return RestAPIUtil.fetch(`${baseUrl()}/${itemId}/permissions`);
53 updateContributors({itemId, removedUsersIds, addedUsersIds}) {
54 return RestAPIUtil.put(`${baseUrl()}/${itemId}/permissions/${permissionTypes.CONTRIBUTOR}`, {removedUsersIds, addedUsersIds});
57 changeOwner({itemId, ownerId}) {
58 return RestAPIUtil.put(`${baseUrl()}/${itemId}/permissions/${permissionTypes.OWNER}`, {removedUsersIds: [], addedUsersIds: [ownerId]});
61 checkItemStatus(dispatch, {itemId, versionId}) {
62 return ItemsHelper.fetchVersion({itemId, versionId}).then(response => {
63 let state = response && response.state || {};
64 const {baseId, description, id, name, status} = response;
67 type: onboardingActionTypes.UPDATE_ITEM_STATUS,
69 itemStatus: response.status,
70 updatedVersion: {baseId, description, id, name, status}
72 return Promise.resolve(response);
78 export default ItemsHelper;