Fix profile server selection activation state
Build and Deploy Gateway / build-and-push (push) Successful in 20s
Build and Deploy Gateway / deploy (push) Successful in 7s

This commit is contained in:
2026-08-11 10:11:13 +03:00
parent 17849ffd73
commit 7e4da4bdcf
11 changed files with 60 additions and 62 deletions
@@ -32,6 +32,7 @@ interface ServerPickerRenderState {
leaving: boolean;
revealVersion: number;
anchorServerId: string;
selectedServerId: string;
}
interface SubscriptionFeatureOptions {
@@ -45,7 +46,6 @@ interface SubscriptionFeatureOptions {
onAdd: (label: string, url: string) => Promise<unknown>;
onRefresh: (profileId: string) => Promise<unknown>;
onForget: (profileId: string, mode: 'delete' | 'stop-and-delete') => Promise<unknown>;
onActivate: (profileId: string) => Promise<unknown>;
onDismissError: () => void;
}
@@ -64,7 +64,6 @@ export function useSubscriptionFeature({
onAdd,
onRefresh,
onForget,
onActivate,
onDismissError,
}: SubscriptionFeatureOptions) {
const [open, setOpen] = useState(false);
@@ -281,7 +280,6 @@ export function useSubscriptionFeature({
addBlocked: operationBlocked(operations, 'profileAdd'),
refreshBlocked: operationBlocked(operations, 'profileRefresh'),
deleteBlocked: operationBlocked(operations, 'profileDelete'),
activateBlocked: operationBlocked(operations, 'profileActivate'),
toggle: () => setOpen((current) => !current),
close: () => setOpen(false),
showAdd,
@@ -296,7 +294,6 @@ export function useSubscriptionFeature({
cancelDelete: () => setDeleteId(''),
confirmDelete,
refresh,
onActivate,
};
}
@@ -394,8 +391,9 @@ function ProfileGroup({
const refreshing = feature.refreshingIds.includes(profile.id)
|| feature.operations.profileRefresh?.target === profile.id;
const controlsBlocked = operationBlocked(feature.operations, 'profileSelect');
const selectedServer = profileServer(profile, profile.desiredServerId);
const visibleServerId = applied ? feature.selection.appliedServerId : profile.desiredServerId;
const visibleServerId = applied
? feature.selection.appliedServerId
: desired ? profile.desiredServerId : '';
const visibleServer = profileServer(profile, visibleServerId)
|| (applied && feature.selection.appliedServerSnapshot?.id === visibleServerId
? feature.selection.appliedServerSnapshot
@@ -403,7 +401,6 @@ function ProfileGroup({
const visibleServerLocation = [visibleServer?.city, visibleServer?.country]
.filter((value): value is string => typeof value === 'string' && Boolean(value))
.join(' · ');
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' })
@@ -431,12 +428,7 @@ function ProfileGroup({
<small>{profileDetails}</small>
</span>
</button>
{canActivate ? <button
className="client-profile-activate"
type="button"
disabled={feature.activateBlocked || !selectedServer}
onClick={() => feature.onActivate(profile.id)}
>Сделать активной</button> : <ProfileUsage profile={profile} />}
{(applied || desired) && <ProfileUsage profile={profile} />}
<button
className={`client-profile-refresh${refreshing ? ' is-refreshing' : ''}`}
type="button"
@@ -483,12 +475,13 @@ function ProfileGroup({
inert={!expanded ? true : undefined}
>
<div className="client-profile-body-inner">
{!profile.desiredServerId && <p className="client-profile-server-hint">Выберите сервер этой подписки</p>}
{!visibleServerId && <p className="client-profile-server-hint">Выберите сервер этой подписки</p>}
{renderServerPicker(profile, {
disabled: controlsBlocked,
leaving: false,
revealVersion: feature.revealVersions[profile.id] || 0,
anchorServerId: visibleServer?.id || '',
selectedServerId: visibleServerId,
})}
</div>
</div>}