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
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
16 import React from 'react';
17 import PropTypes from 'prop-types';
18 import i18n from 'nfvo-utils/i18n/i18n.js';
19 import ClickOutsideWrapper from 'nfvo-components/clickOutsideWrapper/ClickOutsideWrapper.jsx';
20 import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js';
21 import Overlay from 'nfvo-components/overlay/Overlay.jsx';
22 import Permissions from './Permissions.jsx';
24 const VCButton = ({ name, tooltipText, disabled, onClick, dataTestId }) => {
25 let onClickAction = disabled ? () => {} : onClick;
28 className={`action-button-wrapper ${
29 disabled ? 'disabled' : 'clickable'
31 onClick={onClickAction}>
32 <div className="action-buttons-svg">
35 labelPosition="bottom"
36 labelClassName="action-button-label"
37 data-test-id={dataTestId}
46 const Separator = () => <div className="vc-separator" />;
48 const SubmitButton = ({ onClick, disabled }) => (
50 onClick={() => onClick()}
51 data-test-id="vc-submit-btn"
52 className={`vc-submit-button ${disabled ? 'disabled' : ''}`}>
53 <SVGIcon name="check" iconClassName="vc-v-submit" disabled={disabled} />
58 const ActionButtons = ({
68 onOpenCommentCommitModal,
84 <div className="action-buttons">
85 <ClickOutsideWrapper onClose={onClosePermissions}>
88 dataTestId="vc-permission-btn"
89 onClick={onClickPermissions}
90 name="version-controller-permissions"
91 tooltipText={i18n('Permissons')}
97 onManagePermissions={onManagePermissions}
98 permissions={permissions}
99 onClosePermissions={onClosePermissions}
103 </ClickOutsideWrapper>
106 <div className="collaborator-action-buttons">
109 <div className="vc-save-section">
111 dataTestId="vc-save-btn"
112 onClick={() => onSave()}
113 name="version-controller-save"
114 tooltipText={i18n('Save')}
115 disabled={isReadOnlyMode || !isFormDataValid}
121 dataTestId="vc-sync-btn"
123 name="version-controller-sync"
124 tooltipText={i18n('Sync')}
125 disabled={!isCollaborator || isUpToDate || isCertified}
128 dataTestId="vc-commit-btn"
130 onOpenCommentCommitModal({
132 title: i18n('Commit')
135 name="version-controller-commit"
136 tooltipText={i18n('Share')}
137 disabled={isReadOnlyMode || !isDirty || isOutOfSync}
141 dataTestId="vc-revert-btn"
142 onClick={onOpenRevisionsModal}
143 name="version-controller-revert"
144 tooltipText={i18n('Revert')}
145 disabled={isReadOnlyMode || isOutOfSync}
149 <div className="vc-submit-section">
167 ActionButtons.propTypes = {
168 version: PropTypes.object,
169 onSubmit: PropTypes.func,
170 onRevert: PropTypes.func,
171 onSave: PropTypes.func,
172 isLatestVersion: PropTypes.bool,
173 isCheckedIn: PropTypes.bool,
174 isCheckedOut: PropTypes.bool,
175 isFormDataValid: PropTypes.bool,
176 isReadOnlyMode: PropTypes.bool
179 export default ActionButtons;