<commit_before>import { MODAL, TOOLBAR } from 'utils/Issuers';
import { UPDATE, CREATE, REF } from 'constants/Actions';
import joinKeys from 'utils/joinKeys';
import deprecated from 'utils/deprecated';
import routerStore from 'stores/routerStore';

export default class Actions {
	get props() {
		return this._reactInstance.props;
	}

	get store() {
		return this.props.store;
	}

	get issuers() {
		return this.props.issuers;
	}

	get pageContext() {
		return this.props.pageContext;
	}

	get selectedKeys() {
		const { store, tableRowKey } = this.props;
		return tableRowKey ? [tableRowKey] : store.selectedKeys;
	}

	get selectedKeysString() {
		return joinKeys(this.selectedKeys);
	}

	get selectedKeysHead() {
		return this.selectedKeys.length ? this.selectedKeys[0] : undefined;
	}

	constructor(reactInstance) {
		this._reactInstance = reactInstance;
	}

	getSelectedKeysString = () => this.selectedKeysString;

	getData = () => this.store.getData(this.selectedKeysHead);

	dispatch = (name, modalParams) => {
		const { pageContext, modalStore, issuers, enforceModal } = this.props;
		const keys = this.selectedKeysString;
		if (
			!enforceModal &&
			!modalParams &&
			pageContext.useDetail &&
			(name === CREATE || name === UPDATE) &&
			issuers.has(TOOLBAR) &&
			!issuers.has(MODAL)
		) {
			const path = name === UPDATE ? `/update/${keys}` : '/create';
			routerStore.location.pathname += path;
		} else {
			modalStore.open({
				keys,
				...modalParams,
				name,
			});
			return modalStore.close.bind(modalStore);
		}
	};

	create = (modalParams) => {
		return this.dispatch(CREATE, modalParams);
	};

	update = (modalParams) => {
		return this.dispatch(UPDATE, modalParams);
	};

	ref = (modalParams) => {
		return this.dispatch(UPDATE, {
			fetch: 'fetch',
			save: 'request',
			width: 880,
			...modalParams,
		});
	};

	open = deprecated((name, params = {}) => {
		const { modalStore } = this.props;
		const keys = this.selectedKeysString;
		modalStore.open({
			keys,
			...params,
			name,
		});
		return modalStore.close.bind(modalStore);
	}, '`open()` is deprecated, please use dispatch() instead');

	openCreaterModal = deprecated((params = {}) => {
		return this.open(CREATE, params);<commit_msg>fix actions.ref bug<commit_after>import { MODAL, TOOLBAR } from 'utils/Issuers';
import { UPDATE, CREATE, REF } from 'constants/Actions';
import joinKeys from 'utils/joinKeys';
import deprecated from 'utils/deprecated';
import routerStore from 'stores/routerStore';

export default class Actions {
	get props() {
		return this._reactInstance.props;
	}

	get store() {
		return this.props.store;
	}

	get issuers() {
		return this.props.issuers;
	}

	get pageContext() {
		return this.props.pageContext;
	}

	get selectedKeys() {
		const { store, tableRowKey } = this.props;
		return tableRowKey ? [tableRowKey] : store.selectedKeys;
	}

	get selectedKeysString() {
		return joinKeys(this.selectedKeys);
	}

	get selectedKeysHead() {
		return this.selectedKeys.length ? this.selectedKeys[0] : undefined;
	}

	constructor(reactInstance) {
		this._reactInstance = reactInstance;
	}

	getSelectedKeysString = () => this.selectedKeysString;

	getData = () => this.store.getData(this.selectedKeysHead);

	dispatch = (name, modalParams) => {
		const { pageContext, modalStore, issuers, enforceModal } = this.props;
		const keys = this.selectedKeysString;
		if (
			!enforceModal &&
			!modalParams &&
			pageContext.useDetail &&
			(name === CREATE || name === UPDATE) &&
			issuers.has(TOOLBAR) &&
			!issuers.has(MODAL)
		) {
			const path = name === UPDATE ? `/update/${keys}` : '/create';
			routerStore.location.pathname += path;
		} else {
			modalStore.open({
				keys,
				...modalParams,
				name,
			});
			return modalStore.close.bind(modalStore);
		}
	};

	create = (modalParams) => {
		return this.dispatch(CREATE, modalParams);
	};

	update = (modalParams) => {
		return this.dispatch(UPDATE, modalParams);
	};

	ref = (modalParams) => {
		return this.dispatch(REF, {
			fetch: 'fetch',
			save: 'request',
			width: 880,
			...modalParams,
		});
	};

	open = deprecated((name, params = {}) => {
		const { modalStore } = this.props;
		const keys = this.selectedKeysString;
		modalStore.open({
			keys,
			...params,
			name,
		});
		return modalStore.close.bind(modalStore);
	}, '`open()` is deprecated, please use dispatch() instead');

	openCreaterModal = deprecated((params = {}) => {
		return this.open(CREATE, params);
{'fraction_non_alphanumeric': 0.150100964774512, 'fraction_numerical': 0.0017949293246578416, 'mean_word_length': 3.793548387096774, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5808613', 'n_tokens_mistral': 1647, 'n_tokens_neox': 1452, 'n_words': 311}