diff --git a/panel/context/auth.tsx b/panel/context/auth.tsx index 4156ddaf..1b179726 100644 --- a/panel/context/auth.tsx +++ b/panel/context/auth.tsx @@ -1,4 +1,5 @@ import { Component, createContext, createSignal, JSX, onMount, useContext } from 'solid-js' +import { AuthSuccess } from '~/graphql/generated/graphql' import { query } from '../graphql' import { ADMIN_LOGIN_MUTATION, ADMIN_LOGOUT_MUTATION } from '../graphql/mutations' import { @@ -10,7 +11,6 @@ import { getCsrfTokenFromCookie, saveAuthToken } from '../utils/auth' -import { AuthSuccess } from '~/graphql/generated/graphql' /** * Модуль авторизации * @module auth @@ -164,10 +164,7 @@ export const AuthProvider: Component = (props) => { export const logout = async () => { console.log('[Auth] Executing standalone logout...') try { - const result = await query<{ logout: AuthSuccess }>( - `${location.origin}/graphql`, - ADMIN_LOGOUT_MUTATION - ) + const result = await query<{ logout: AuthSuccess }>(`${location.origin}/graphql`, ADMIN_LOGOUT_MUTATION) console.log('[Auth] Standalone logout result:', result) if (result?.logout?.success) { clearAuthTokens() diff --git a/panel/modals/RolesModal.tsx b/panel/modals/RolesModal.tsx index 02ab34c3..d25f2520 100644 --- a/panel/modals/RolesModal.tsx +++ b/panel/modals/RolesModal.tsx @@ -17,8 +17,14 @@ export interface UserEditModalProps { }) => Promise } -// Доступные роли в системе (без роли Администратор - она определяется автоматически) +// Доступные роли в системе const AVAILABLE_ROLES = [ + { + id: 'Администратор', + name: 'Системный администратор', + description: 'Администраторы определяются автоматически по настройкам сервера', + emoji: '🪄' + }, { id: 'Редактор', name: 'Редактор', @@ -51,7 +57,7 @@ const UserEditModal: Component = (props) => { email: props.user.email || '', name: props.user.name || '', slug: props.user.slug || '', - roles: props.user.roles?.filter((role) => role !== 'Администратор') || [] // Исключаем админскую роль из ручного управления + roles: props.user.roles || [] // Включаем все роли, включая администратора }) const [errors, setErrors] = createSignal>({}) @@ -94,7 +100,7 @@ const UserEditModal: Component = (props) => { email: props.user.email || '', name: props.user.name || '', slug: props.user.slug || '', - roles: props.user.roles?.filter((role) => role !== 'Администратор') || [] // Исключаем админскую роль + roles: props.user.roles || [] // Включаем все роли, включая администратора }) setErrors({}) } @@ -109,6 +115,11 @@ const UserEditModal: Component = (props) => { } const handleRoleToggle = (roleId: string) => { + // Роль администратора нельзя изменить вручную + if (roleId === 'Администратор') { + return + } + setFormData((prev) => { const currentRoles = prev.roles const newRoles = currentRoles.includes(roleId) @@ -149,7 +160,7 @@ const UserEditModal: Component = (props) => { } // Роли (админы освобождаются от этого требования) - if (!isAdmin() && data.roles.length === 0) { + if (!isAdmin() && data.roles.filter((role) => role !== 'Администратор').length === 0) { newErrors.roles = 'Выберите хотя бы одну роль (или назначьте админский email)' } @@ -215,7 +226,7 @@ const UserEditModal: Component = (props) => { {/* Текущие роли в строку */} -
+
diff --git a/panel/ui/HTMLEditor.tsx b/panel/ui/HTMLEditor.tsx index 1d17cdc9..d7d3e135 100644 --- a/panel/ui/HTMLEditor.tsx +++ b/panel/ui/HTMLEditor.tsx @@ -355,13 +355,14 @@ const HTMLEditor = (props: HTMLEditorProps) => { if (token.startsWith('')) { // Открывающий тег - const isSelfClosing = token.endsWith('/>') || + const isSelfClosing = + token.endsWith('/>') || /^<(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)(\s|>)/i.test(token) - formatted += indentStr.repeat(indent) + token + '\n' + formatted += `${indentStr.repeat(indent)}${token}\n` if (!isSelfClosing) { indent++ @@ -369,7 +370,7 @@ const HTMLEditor = (props: HTMLEditorProps) => { } else { // Текстовое содержимое if (token.length > 0) { - formatted += indentStr.repeat(indent) + token + '\n' + formatted += `${indentStr.repeat(indent)}${token}\n` } } }