/*
 * Copyright © 2016-2018 European Support Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import keyMirror from 'nfvo-utils/KeyMirror.js';

export const DATE_FORMAT = 'MM/DD/YYYY';

export const actionTypes = keyMirror(
    {
        SET_CURRENT_SCREEN: null,
        SET_CURRENT_LICENSE_MODEL: null,
        SET_CURRENT_SCREEN_VERSION: null,
        UPDATE_CURRENT_SCREEN_PROPS: null,
        UPDATE_ITEM_STATUS: null,
        UPDATE_ITEM_ARCHIVE_STATUS: null
    },
    'onboardingMain'
);

export const screenTypes = keyMirror({
    LICENSE_MODEL: null,
    SOFTWARE_PRODUCT: null,
    SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL: null
});

const breadcrumbsEnum = {
    LICENSE_MODEL: 'LICENSE_MODEL',
    VERSIONS_PAGE: 'VERSIONS_PAGE',
    LICENSE_MODEL_OVERVIEW: 'LICENSE_MODEL_OVERVIEW',
    LICENSE_AGREEMENTS: 'LICENSE_AGREEMENTS',
    FEATURE_GROUPS: 'FEATURE_GROUPS',
    ENTITLEMENT_POOLS: 'ENTITLEMENT_POOLS',
    LICENSE_KEY_GROUPS: 'LICENSE_KEY_GROUPS',
    ACTIVITY_LOG: 'ACTIVITY_LOG',

    SOFTWARE_PRODUCT: 'SOFTWARE_PRODUCT',
    SOFTWARE_PRODUCT_VERSIONS_PAGE: 'SOFTWARE_PRODUCT_VERSIONS_PAGE',
    SOFTWARE_PRODUCT_LANDING_PAGE: 'SOFTWARE_PRODUCT_LANDING_PAGE',
    SOFTWARE_PRODUCT_DETAILS: 'SOFTWARE_PRODUCT_DETAILS',
    SOFTWARE_PRODUCT_ATTACHMENTS: 'SOFTWARE_PRODUCT_ATTACHMENTS',
    SOFTWARE_PRODUCT_PROCESSES: 'SOFTWARE_PRODUCT_PROCESSES',
    SOFTWARE_PRODUCT_DEPLOYMENT: 'SOFTWARE_PRODUCT_DEPLOYMENT',
    SOFTWARE_PRODUCT_NETWORKS: 'SOFTWARE_PRODUCT_NETWORKS',
    SOFTWARE_PRODUCT_VALIDATION: 'SOFTWARE_PRODUCT_VALIDATION',
    SOFTWARE_PRODUCT_VALIDATION_RESULTS: 'SOFTWARE_PRODUCT_VALIDATION_RESULTS',
    SOFTWARE_PRODUCT_DEPENDENCIES: 'SOFTWARE_PRODUCT_DEPENDENCIES',
    SOFTWARE_PRODUCT_ACTIVITY_LOG: 'SOFTWARE_PRODUCT_ACTIVITY_LOG',
    SOFTWARE_PRODUCT_COMPONENTS: 'SOFTWARE_PRODUCT_COMPONENTS',
    SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
        'SOFTWARE_PRODUCT_COMPONENT_PROCESSES',
    SOFTWARE_PRODUCT_COMPONENT_NETWORK: 'SOFTWARE_PRODUCT_COMPONENT_NETWORK',
    SOFTWARE_PRODUCT_COMPONENT_STORAGE: 'SOFTWARE_PRODUCT_COMPONENT_STORAGE',
    SOFTWARE_PRODUCT_COMPONENT_GENERAL: 'SOFTWARE_PRODUCT_COMPONENT_GENERAL',
    SOFTWARE_PRODUCT_COMPONENT_COMPUTE: 'SOFTWARE_PRODUCT_COMPONENT_COMPUTE',
    SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
        'SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING',
    SOFTWARE_PRODUCT_COMPONENT_MONITORING:
        'SOFTWARE_PRODUCT_COMPONENT_MONITORING',
    SOFTWARE_PRODUCT_COMPONENT_IMAGES: 'SOFTWARE_PRODUCT_COMPONENT_IMAGES'
};

export const enums = keyMirror({
    BREADCRUMS: { ...breadcrumbsEnum },

    SCREEN: {
        ONBOARDING_CATALOG: 'ONBOARDING_CATALOG',
        VERSIONS_PAGE: breadcrumbsEnum.VERSIONS_PAGE,
        LICENSE_MODEL_OVERVIEW: breadcrumbsEnum.LICENSE_MODEL_OVERVIEW,
        LICENSE_AGREEMENTS: breadcrumbsEnum.LICENSE_AGREEMENTS,
        FEATURE_GROUPS: breadcrumbsEnum.FEATURE_GROUPS,
        ENTITLEMENT_POOLS: breadcrumbsEnum.ENTITLEMENT_POOLS,
        LICENSE_KEY_GROUPS: breadcrumbsEnum.LICENSE_KEY_GROUPS,
        ACTIVITY_LOG: breadcrumbsEnum.ACTIVITY_LOG,

        SOFTWARE_PRODUCT_VERSIONS_PAGE:
            breadcrumbsEnum.SOFTWARE_PRODUCT_VERSIONS_PAGE,
        SOFTWARE_PRODUCT_LANDING_PAGE:
            breadcrumbsEnum.SOFTWARE_PRODUCT_LANDING_PAGE,
        SOFTWARE_PRODUCT_DETAILS: breadcrumbsEnum.SOFTWARE_PRODUCT_DETAILS,
        SOFTWARE_PRODUCT_ATTACHMENTS:
            breadcrumbsEnum.SOFTWARE_PRODUCT_ATTACHMENTS,
        SOFTWARE_PRODUCT_ATTACHMENTS_SETUP:
            'SOFTWARE_PRODUCT_ATTACHMENTS_SETUP',
        SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION:
            'SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION',
        SOFTWARE_PRODUCT_ATTACHMENTS_VIEW_VALIDATION:
            'SOFTWARE_PRODUCT_ATTACHMENTS_VIEW_VALIDATION',
        SOFTWARE_PRODUCT_PROCESSES: breadcrumbsEnum.SOFTWARE_PRODUCT_PROCESSES,
        SOFTWARE_PRODUCT_DEPLOYMENT:
            breadcrumbsEnum.SOFTWARE_PRODUCT_DEPLOYMENT,
        SOFTWARE_PRODUCT_NETWORKS: breadcrumbsEnum.SOFTWARE_PRODUCT_NETWORKS,
        SOFTWARE_PRODUCT_VALIDATION:
            breadcrumbsEnum.SOFTWARE_PRODUCT_VALIDATION,
        SOFTWARE_PRODUCT_VALIDATION_RESULTS:
            breadcrumbsEnum.SOFTWARE_PRODUCT_VALIDATION_RESULTS,
        SOFTWARE_PRODUCT_DEPENDENCIES:
            breadcrumbsEnum.SOFTWARE_PRODUCT_DEPENDENCIES,
        SOFTWARE_PRODUCT_ACTIVITY_LOG:
            breadcrumbsEnum.SOFTWARE_PRODUCT_ACTIVITY_LOG,
        SOFTWARE_PRODUCT_COMPONENTS:
            breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENTS,
        SOFTWARE_PRODUCT_COMPONENT_PROCESSES:
            breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_PROCESSES,
        SOFTWARE_PRODUCT_COMPONENT_COMPUTE:
            breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_COMPUTE,
        SOFTWARE_PRODUCT_COMPONENT_STORAGE:
            breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_STORAGE,
        SOFTWARE_PRODUCT_COMPONENT_NETWORK:
            breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_NETWORK,
        SOFTWARE_PRODUCT_COMPONENT_GENERAL:
            breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_GENERAL,
        SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING:
            breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING,
        SOFTWARE_PRODUCT_COMPONENT_MONITORING:
            breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_MONITORING,
        SOFTWARE_PRODUCT_COMPONENT_IMAGES:
            breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_IMAGES
    }
});

export const onboardingActions = {
    updateItemArchivedStatus: isArchived => ({
        type: actionTypes.UPDATE_ITEM_ARCHIVE_STATUS,
        isArchived
    })
};
