fix: use fresh project status and rights after reload
After F5 without projectId in the address the hub and sidebar showed the status and edit right saved in sessionStorage, so a project switched to Архивный or a revoked edit0 right was ignored until the project was picked again. The fresh list from SharePoint now always wins; the saved copy is used only while the list is loading. Found in T-HUB-07/09. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -85,6 +85,23 @@ export function isSectionAvailable(page: PageId, project: IAccessibleProject): b
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Текущий проект: id из адреса, а без него — сохранённый в сессии выбор.
|
||||
* Данные (статус, права) берутся из свежего списка с сервера; сохранённая копия — только пока список
|
||||
* не загрузился или если проекта в нём нет. Иначе после смены статуса / прав F5 показывал бы старые.
|
||||
*/
|
||||
export function resolveCurrentProject(
|
||||
projects: IAccessibleProject[],
|
||||
routeProjectId: number | undefined,
|
||||
storedProject: IAccessibleProject | undefined
|
||||
): IAccessibleProject | undefined {
|
||||
const targetId = routeProjectId ?? storedProject?.id;
|
||||
if (targetId === undefined) return undefined;
|
||||
const fresh = projects.filter((project) => project.id === targetId)[0];
|
||||
if (fresh) return fresh;
|
||||
return storedProject?.id === targetId ? storedProject : undefined;
|
||||
}
|
||||
|
||||
/** Выгрузка за период недоступна только для архивного проекта. */
|
||||
export function isExportAvailable(project: IAccessibleProject): boolean {
|
||||
return getStatusKind(project.status) !== 'archive';
|
||||
|
||||
Reference in New Issue
Block a user