2021-11-11 11:23:49 +05:30
|
|
|
import { STATUSES } from '../constants';
|
2021-10-27 15:23:28 +05:30
|
|
|
import { NEW_NAME_FIELD } from './constants';
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
export function isNameValid(importTarget, validationRegex) {
|
|
|
|
return validationRegex.test(importTarget[NEW_NAME_FIELD]);
|
2021-10-27 15:23:28 +05:30
|
|
|
}
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
export function getInvalidNameValidationMessage(importTarget) {
|
|
|
|
return importTarget.validationErrors?.find(({ field }) => field === NEW_NAME_FIELD)?.message;
|
2021-10-27 15:23:28 +05:30
|
|
|
}
|
2021-11-11 11:23:49 +05:30
|
|
|
|
|
|
|
export function isFinished(group) {
|
2021-12-11 22:18:48 +05:30
|
|
|
return [STATUSES.FINISHED, STATUSES.FAILED].includes(group.progress?.status);
|
2021-11-11 11:23:49 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
export function isAvailableForImport(group) {
|
2021-12-11 22:18:48 +05:30
|
|
|
return !group.progress || isFinished(group);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function isSameTarget(importTarget) {
|
|
|
|
return (target) =>
|
|
|
|
target !== importTarget &&
|
|
|
|
target.newName.toLowerCase() === importTarget.newName.toLowerCase() &&
|
|
|
|
target.targetNamespace.id === importTarget.targetNamespace.id;
|
2021-11-11 11:23:49 +05:30
|
|
|
}
|