talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 1 | /*! |
| 2 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
| 3 | * |
| 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 |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 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. |
| 15 | */ |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 16 | import { |
| 17 | actionTypes, |
| 18 | VERSION_CREATION_FORM_NAME, |
| 19 | defaultState |
| 20 | } from './VersionsPageCreationConstants.js'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 21 | |
| 22 | export default (state = {}, action) => { |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame] | 23 | switch (action.type) { |
| 24 | case actionTypes.OPEN: |
| 25 | return { |
| 26 | ...state, |
| 27 | formReady: null, |
| 28 | formName: VERSION_CREATION_FORM_NAME, |
| 29 | data: { ...defaultState }, |
| 30 | genericFieldInfo: { |
| 31 | description: { |
| 32 | isValid: true, |
| 33 | errorText: '', |
| 34 | validations: [ |
| 35 | { type: 'required', data: true }, |
| 36 | { type: 'maxLength', data: 120 } |
| 37 | ] |
| 38 | }, |
| 39 | creationMethod: { |
| 40 | isValid: true, |
| 41 | errorText: '', |
| 42 | validations: [{ type: 'required', data: true }] |
| 43 | } |
| 44 | } |
| 45 | }; |
| 46 | case actionTypes.CLOSE: |
| 47 | return {}; |
| 48 | default: |
| 49 | return state; |
| 50 | } |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 51 | }; |