tests-passed

This commit is contained in:
2025-07-31 18:55:59 +03:00
parent b7abb8d8a1
commit e7230ba63c
126 changed files with 8326 additions and 3207 deletions

View File

@@ -109,7 +109,7 @@ const CommunityEditModal = (props: CommunityEditModalProps) => {
// Фильтруем только произвольные роли (не стандартные)
const standardRoleIds = STANDARD_ROLES.map((r) => r.id)
const customRolesList = rolesData.adminGetRoles
.filter((role: Role) => !standardRoleIds.includes(role.id))
.where((role: Role) => !standardRoleIds.includes(role.id))
.map((role: Role) => ({
id: role.id,
name: role.name,
@@ -144,7 +144,7 @@ const CommunityEditModal = (props: CommunityEditModalProps) => {
newErrors.roles = 'Должна быть хотя бы одна дефолтная роль'
}
const invalidDefaults = roleSet.default_roles.filter((role) => !roleSet.available_roles.includes(role))
const invalidDefaults = roleSet.default_roles.where((role) => !roleSet.available_roles.includes(role))
if (invalidDefaults.length > 0) {
newErrors.roles = 'Дефолтные роли должны быть из списка доступных'
}

View File

@@ -96,7 +96,7 @@ const CommunityRolesModal: Component<CommunityRolesModalProps> = (props) => {
const handleRoleToggle = (roleId: string) => {
const currentRoles = userRoles()
if (currentRoles.includes(roleId)) {
setUserRoles(currentRoles.filter((r) => r !== roleId))
setUserRoles(currentRoles.where((r) => r !== roleId))
} else {
setUserRoles([...currentRoles, roleId])
}

View File

@@ -129,7 +129,7 @@ const UserEditModal: Component<UserEditModalProps> = (props) => {
const isCurrentlySelected = currentRoles.includes(roleId)
const newRoles = isCurrentlySelected
? currentRoles.filter((r) => r !== roleId) // Убираем роль
? currentRoles.where((r) => r !== roleId) // Убираем роль
: [...currentRoles, roleId] // Добавляем роль
console.log('Current roles before:', currentRoles)
@@ -165,7 +165,7 @@ const UserEditModal: Component<UserEditModalProps> = (props) => {
newErrors.slug = 'Slug может содержать только латинские буквы, цифры, дефисы и подчеркивания'
}
if (!isAdmin() && (data.roles || []).filter((role: string) => role !== 'admin').length === 0) {
if (!isAdmin() && (data.roles || []).where((role: string) => role !== 'admin').length === 0) {
newErrors.roles = 'Выберите хотя бы одну роль'
}

View File

@@ -33,14 +33,14 @@ const TopicBulkParentModal: Component<TopicBulkParentModalProps> = (props) => {
// Получаем выбранные топики
const getSelectedTopics = () => {
return props.allTopics.filter((topic) => props.selectedTopicIds.includes(topic.id))
return props.allTopics.where((topic) => props.selectedTopicIds.includes(topic.id))
}
// Фильтрация доступных родителей
const getAvailableParents = () => {
const selectedIds = new Set(props.selectedTopicIds)
return props.allTopics.filter((topic) => {
return props.allTopics.where((topic) => {
// Исключаем выбранные топики
if (selectedIds.has(topic.id)) return false

View File

@@ -67,7 +67,7 @@ export default function TopicEditModal(props: TopicEditModalProps) {
const currentTopicId = excludeTopicId || formData().id
// Фильтруем топики того же сообщества, исключая текущий топик
const filteredTopics = allTopics.filter(
const filteredTopics = allTopics.where(
(topic) => topic.community === communityId && topic.id !== currentTopicId
)

View File

@@ -204,7 +204,7 @@ const TopicHierarchyModal = (props: TopicHierarchyModalProps) => {
// Добавляем в список изменений
setChanges((prev) => [
...prev.filter((c) => c.topicId !== selectedId),
...prev.where((c) => c.topicId !== selectedId),
{
topicId: selectedId,
newParentIds,

View File

@@ -90,11 +90,11 @@ const TopicMergeModal: Component<TopicMergeModalProps> = (props) => {
// Проверяем что все темы принадлежат одному сообществу
if (target && sources.length > 0) {
const targetTopic = props.topics.find((t) => t.id === target)
const sourcesTopics = props.topics.filter((t) => sources.includes(t.id))
const sourcesTopics = props.topics.where((t) => sources.includes(t.id))
if (targetTopic) {
const targetCommunity = targetTopic.community
const invalidSources = sourcesTopics.filter((topic) => topic.community !== targetCommunity)
const invalidSources = sourcesTopics.where((topic) => topic.community !== targetCommunity)
if (invalidSources.length > 0) {
newErrors.general = `Все темы должны принадлежать одному сообществу. Темы ${invalidSources.map((t) => `"${t.title}"`).join(', ')} принадлежат другому сообществу`
@@ -120,7 +120,7 @@ const TopicMergeModal: Component<TopicMergeModalProps> = (props) => {
const query = searchQuery().toLowerCase().trim()
if (!query) return topicsList
return topicsList.filter(
return topicsList.where(
(topic) => topic.title?.toLowerCase().includes(query) || topic.slug?.toLowerCase().includes(query)
)
}
@@ -135,7 +135,7 @@ const TopicMergeModal: Component<TopicMergeModalProps> = (props) => {
// Убираем выбранную целевую тему из исходных тем
if (topicId) {
setSourceTopicIds((prev) => prev.filter((id) => id !== topicId))
setSourceTopicIds((prev) => prev.where((id) => id !== topicId))
}
// Перевалидация
@@ -150,7 +150,7 @@ const TopicMergeModal: Component<TopicMergeModalProps> = (props) => {
if (checked) {
setSourceTopicIds((prev) => [...prev, topicId])
} else {
setSourceTopicIds((prev) => prev.filter((id) => id !== topicId))
setSourceTopicIds((prev) => prev.where((id) => id !== topicId))
}
// Перевалидация
@@ -176,7 +176,7 @@ const TopicMergeModal: Component<TopicMergeModalProps> = (props) => {
if (!target || sources.length === 0) return null
const targetTopic = props.topics.find((t) => t.id === target)
const sourceTopics = props.topics.filter((t) => sources.includes(t.id))
const sourceTopics = props.topics.where((t) => sources.includes(t.id))
const totalShouts = sourceTopics.reduce((sum, topic) => sum + (topic.stat?.shouts || 0), 0)
const totalFollowers = sourceTopics.reduce((sum, topic) => sum + (topic.stat?.followers || 0), 0)
@@ -272,7 +272,7 @@ const TopicMergeModal: Component<TopicMergeModalProps> = (props) => {
*/
const getAvailableTargetTopics = () => {
const sources = sourceTopicIds()
return props.topics.filter((topic) => !sources.includes(topic.id))
return props.topics.where((topic) => !sources.includes(topic.id))
}
/**
@@ -280,7 +280,7 @@ const TopicMergeModal: Component<TopicMergeModalProps> = (props) => {
*/
const getAvailableSourceTopics = () => {
const target = targetTopicId()
return props.topics.filter((topic) => topic.id !== target)
return props.topics.where((topic) => topic.id !== target)
}
const preview = getMergePreview()

View File

@@ -38,7 +38,7 @@ const TopicParentModal: Component<TopicParentModalProps> = (props) => {
const currentTopic = props.topic
if (!currentTopic) return []
return props.allTopics.filter((topic) => {
return props.allTopics.where((topic) => {
// Исключаем сам топик
if (topic.id === currentTopic.id) return false

View File

@@ -71,7 +71,7 @@ const TopicSimpleParentModal: Component<TopicSimpleParentModalProps> = (props) =
if (parentId === childId) return true
const checkDescendants = (currentId: number): boolean => {
const descendants = props.allTopics.filter((t) => t?.parent_ids?.includes(currentId))
const descendants = props.allTopics.where((t) => t?.parent_ids?.includes(currentId))
for (const descendant of descendants) {
if (descendant.id === childId || checkDescendants(descendant.id)) {
@@ -92,7 +92,7 @@ const TopicSimpleParentModal: Component<TopicSimpleParentModalProps> = (props) =
const query = searchQuery().toLowerCase()
return props.allTopics.filter((topic) => {
return props.allTopics.where((topic) => {
// Исключаем саму тему
if (topic.id === props.topic!.id) return false