Improve server picker layout and profile activation flow
This commit is contained in:
@@ -138,8 +138,9 @@ function ServerRow({
|
||||
onClick={() => onSelect(server.id)}
|
||||
>
|
||||
<strong>{server.label}</strong>
|
||||
{(server.city || server.country) && <small>{[server.city, server.country].filter(Boolean).join(' · ')}</small>}
|
||||
</button>
|
||||
{(ping || onFavorite) && <div className="client-server-meta">
|
||||
<div className="client-server-meta">
|
||||
<ServerHealth ping={ping} />
|
||||
{onFavorite && <button
|
||||
className={`client-server-favorite${favorite ? ' is-active' : ''}`}
|
||||
@@ -148,7 +149,7 @@ function ServerRow({
|
||||
aria-label={`${favorite ? 'Убрать из избранного' : 'Добавить в избранное'}: ${server.label}`}
|
||||
onClick={() => onFavorite(server.id)}
|
||||
>★</button>}
|
||||
</div>}
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
|
||||
@@ -308,7 +309,7 @@ export function ServerPicker({
|
||||
...servers.filter(({ id }) => id !== selectedServerId),
|
||||
].slice(0, SIMPLE_SERVER_LIMIT);
|
||||
|
||||
return <section className="client-servers is-scalable" aria-label="Выберите сервер">
|
||||
return <section className={`client-servers is-scalable${servers.length <= SIMPLE_SERVER_LIMIT ? ' is-short' : ''}`} aria-label="Выберите сервер">
|
||||
{prompt && <span className="client-server-prompt">Выберите сервер</span>}
|
||||
<div className="client-server-toolbar">
|
||||
<span className="client-server-toolbar-title">Список серверов</span>
|
||||
|
||||
@@ -408,6 +408,12 @@ function ProfileGroup({
|
||||
|| feature.operations.profileRefresh?.target === profile.id;
|
||||
const controlsBlocked = operationBlocked(feature.operations, 'profileSelect');
|
||||
const selectedServer = profileServer(profile, profile.desiredServerId);
|
||||
const canActivate = !applied && feature.selection.desiredProfileId !== profile.id;
|
||||
const localStatus = profileError?.message || (profile.subscription.status === 'stale'
|
||||
? `Последнее обновление не удалось. Данные от ${profile.subscription.fetchedAt
|
||||
? new Date(profile.subscription.fetchedAt).toLocaleString('ru-RU', { dateStyle: 'short', timeStyle: 'short' })
|
||||
: 'предыдущей загрузки'}.`
|
||||
: '');
|
||||
return <section className={`client-profile-group${expanded ? ' is-expanded' : ''}${applied ? ' is-active' : ''}`}>
|
||||
<div className="client-profile-header">
|
||||
<button
|
||||
@@ -426,7 +432,12 @@ function ProfileGroup({
|
||||
<small>{subscriptionDomain(profile.subscription.host)}</small>
|
||||
</span>
|
||||
</button>
|
||||
<ProfileUsage profile={profile} />
|
||||
{canActivate ? <button
|
||||
className="client-profile-activate"
|
||||
type="button"
|
||||
disabled={feature.activateBlocked || !selectedServer}
|
||||
onClick={() => feature.onActivate(profile.id)}
|
||||
>Сделать активной</button> : <ProfileUsage profile={profile} />}
|
||||
<button
|
||||
className={`client-profile-refresh${refreshing ? ' is-refreshing' : ''}`}
|
||||
type="button"
|
||||
@@ -472,13 +483,7 @@ function ProfileGroup({
|
||||
<span role="status">{feature.renameDuplicate ? 'Такое имя уже используется.' : ''}</span>
|
||||
</form>}
|
||||
|
||||
<div className="client-profile-local-status" role="status">
|
||||
{profileError?.message || (profile.subscription.status === 'stale'
|
||||
? `Последнее обновление не удалось. Данные от ${profile.subscription.fetchedAt
|
||||
? new Date(profile.subscription.fetchedAt).toLocaleString('ru-RU', { dateStyle: 'short', timeStyle: 'short' })
|
||||
: 'предыдущей загрузки'}.`
|
||||
: '\u00a0')}
|
||||
</div>
|
||||
{localStatus && <div className="client-profile-local-status" role="status">{localStatus}</div>}
|
||||
|
||||
{visited && <div
|
||||
id={`client-profile-${profile.id}`}
|
||||
@@ -486,12 +491,6 @@ function ProfileGroup({
|
||||
aria-hidden={!expanded}
|
||||
inert={!expanded ? true : undefined}
|
||||
>
|
||||
{!applied && feature.selection.desiredProfileId !== profile.id && <button
|
||||
className="client-profile-activate"
|
||||
type="button"
|
||||
disabled={feature.activateBlocked || !selectedServer}
|
||||
onClick={() => feature.onActivate(profile.id)}
|
||||
>Сделать активной</button>}
|
||||
{!profile.desiredServerId && <p className="client-profile-server-hint">Выберите сервер этой подписки</p>}
|
||||
{renderServerPicker(profile, {
|
||||
disabled: controlsBlocked,
|
||||
|
||||
Reference in New Issue
Block a user