<commit_before>import PageSeoService from "../services/pageSeoService";
import {pageSeoTypes as ActionTypes}  from "../constants/actionTypes";
import pageActionTypes  from "../constants/actionTypes/pageActionTypes";
const pageSeoActions = {
    openNewForm() {
        return (dispatch) => {
            dispatch({
                type: ActionTypes.SEO_OPEN_NEW_FORM
            });
        };
    },
    closeNewForm() {
        return (dispatch) => {
            dispatch({
                type: ActionTypes.SEO_CLOSE_NEW_FORM
            });
        };
    },
    openEditForm(url) {
        return (dispatch) => {
            dispatch({
                type: ActionTypes.SEO_OPEN_EDIT_FORM,
                payload: {
                    url
                }
            });
        };
    },
    closeEditForm() {
        return (dispatch) => {
            dispatch({
                type: ActionTypes.SEO_CLOSE_EDIT_FORM
            });
        };
    },
    change(key, value) {
        return (dispatch) => {
            dispatch({
                type: ActionTypes.SEO_CHANGE_URL,
                payload: {
                    key: key,
                    value: value
                }
            });
        };        
    },
    addUrl(url, primaryAliasId) {
        return (dispatch, getState) => {
            dispatch({
                type: ActionTypes.SEO_ADD_URL
            });

            const {pages} = getState();
            const tabId = pages.selectedPage.tabId;
            PageSeoService.add(url, tabId, primaryAliasId).then((response) => {
                const newUrl = {
                    ...url
                };  
                if (!response.Success) {
                    dispatch({
                        type: ActionTypes.ERROR_SEO_ADDING_URL,
                        data: {error: response.ErrorMessage}
                    });
                    return;
                }
                newUrl.id = response.Id;
                dispatch({
                    type: ActionTypes.SEO_ADDED_URL
                });
                dispatch({
                    type: pageActionTypes.ADD_CUSTOM_URL,
                    payload: {
                        newUrl
                    }
                });                                
            }).catch((error) => {
                dispatch({
                    type: ActionTypes.ERROR_SEO_ADDING_URL,
                    data: {error}
                });
            }); 
        };
    },
    saveUrl(url, primaryAliasId) {
        return (dispatch, getState) => {
            dispatch({
                type: ActionTypes.SEO_SAVE_URL
            });

            const {pages} = getState();
            const tabId = pages.selectedPage.tabId;
            PageSeoService.save(url, tabId, primaryAliasId).then((response) => {
                if (!response.Success) {
                    dispatch({
                        type: ActionTypes.ERROR_SEO_SAVING_URL,
                        data: {error: response.ErrorMessage}
                    });
                    return;
                }
                
                dispatch({
                    type: ActionTypes.SEO_SAVED_URL
                });
                dispatch({
                    type: pageActionTypes.REPLACE_CUSTOM_URL,
                    payload: {
                        url
                    }
                });                           
            }).catch((error) => {
                dispatch({<commit_msg>DNN-9919: show error msg for saveing url failure<commit_after>import PageSeoService from "../services/pageSeoService";
import {pageSeoTypes as ActionTypes}  from "../constants/actionTypes";
import pageActionTypes  from "../constants/actionTypes/pageActionTypes";
import util from "utils";
const pageSeoActions = {
    openNewForm() {
        return (dispatch) => {
            dispatch({
                type: ActionTypes.SEO_OPEN_NEW_FORM
            });
        };
    },
    closeNewForm() {
        return (dispatch) => {
            dispatch({
                type: ActionTypes.SEO_CLOSE_NEW_FORM
            });
        };
    },
    openEditForm(url) {
        return (dispatch) => {
            dispatch({
                type: ActionTypes.SEO_OPEN_EDIT_FORM,
                payload: {
                    url
                }
            });
        };
    },
    closeEditForm() {
        return (dispatch) => {
            dispatch({
                type: ActionTypes.SEO_CLOSE_EDIT_FORM
            });
        };
    },
    change(key, value) {
        return (dispatch) => {
            dispatch({
                type: ActionTypes.SEO_CHANGE_URL,
                payload: {
                    key: key,
                    value: value
                }
            });
        };        
    },
    addUrl(url, primaryAliasId) {
        return (dispatch, getState) => {
            dispatch({
                type: ActionTypes.SEO_ADD_URL
            });

            const {pages} = getState();
            const tabId = pages.selectedPage.tabId;
            PageSeoService.add(url, tabId, primaryAliasId).then((response) => {
                const newUrl = {
                    ...url
                };  
                if (!response.Success) {
                    dispatch({
                        type: ActionTypes.ERROR_SEO_ADDING_URL,
                        data: {error: response.ErrorMessage}
                    });
                    return;
                }
                newUrl.id = response.Id;
                dispatch({
                    type: ActionTypes.SEO_ADDED_URL
                });
                dispatch({
                    type: pageActionTypes.ADD_CUSTOM_URL,
                    payload: {
                        newUrl
                    }
                });                                
            }).catch((error) => {
                dispatch({
                    type: ActionTypes.ERROR_SEO_ADDING_URL,
                    data: {error}
                });
            }); 
        };
    },
    saveUrl(url, primaryAliasId) {
        return (dispatch, getState) => {
            dispatch({
                type: ActionTypes.SEO_SAVE_URL
            });

            const {pages} = getState();
            const tabId = pages.selectedPage.tabId;
            PageSeoService.save(url, tabId, primaryAliasId).then((response) => {
                if (!response.Success) {
                    dispatch({
                        type: ActionTypes.ERROR_SEO_SAVING_URL,
                        data: {error: response.ErrorMessage}
                    });
                    util.utilities.notifyError(response.ErrorMessage);
                    return;
                }
                
                dispatch({
                    type: ActionTypes.SEO_SAVED_URL
                });
                dispatch({
                    type: pageActionTypes.REPLACE_CUSTOM_URL,
                    payload: {
                        url
                    }
                });                           
            }).catch((error) => {
                dispatch({
{'fraction_non_alphanumeric': 0.09657975890103729, 'fraction_numerical': 0.000560695262125035, 'mean_word_length': 0.9737206085753803, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '143019', 'n_tokens_mistral': 1781, 'n_tokens_neox': 1669, 'n_words': 281}