Remove standalone Activity log page (Refs #153)
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
const historyFilters = ['host', 'type', 'source', 'state', 'days', 'q', 'limit', 'offset'];
|
||||
|
||||
/** Route retired activity bookmarks to the existing history that owns their scope. */
|
||||
export function activityRedirectHref(url: URL): string {
|
||||
const params = new URLSearchParams();
|
||||
const copy = (keys: string[]) => {
|
||||
for (const key of keys) {
|
||||
const value = url.searchParams.get(key);
|
||||
if (value) params.set(key, value);
|
||||
}
|
||||
};
|
||||
const server = url.searchParams.get('server')?.trim();
|
||||
const host = url.searchParams.get('host')?.trim();
|
||||
const source = url.searchParams.get('source');
|
||||
let path: string;
|
||||
let hash = '';
|
||||
if (server) {
|
||||
path = `/servers/${encodeURIComponent(server)}`;
|
||||
params.set('tab', 'history');
|
||||
copy(historyFilters);
|
||||
hash = url.hash;
|
||||
} else if (host || source === 'host') {
|
||||
path = '/hosts/operations';
|
||||
if (host) params.set('host', host);
|
||||
} else if (source === 'maintenance' || source === 'recovery') {
|
||||
path = '/maintenance';
|
||||
params.set('view', 'activity');
|
||||
copy(historyFilters);
|
||||
hash = url.hash;
|
||||
} else if (source === 'campaign') {
|
||||
path = '/campaigns';
|
||||
copy(['q']);
|
||||
} else if (source === 'beta') {
|
||||
path = '/betas';
|
||||
params.set('view', 'history');
|
||||
copy(['q']);
|
||||
} else {
|
||||
path = '/provisioning';
|
||||
params.set('view', 'history');
|
||||
if (source === 'autoscaling') params.set('source', source);
|
||||
}
|
||||
copy(['returnTo']);
|
||||
return path + (params.size ? `?${params}` : '') + hash;
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import { activityRedirectHref } from './activity-redirect.js';
|
||||
|
||||
const origin = 'https://electric-cherry.invalid';
|
||||
const pagePath =
|
||||
/^\/(?:$|activity|operations|autoscaling|account|bank|capacity|metrics|server-keys|settings(?:\/users)?|servers\/[^/]+|hosts(?:\/[^/]+)?|collections(?:\/launches\/[^/]+)?|(?:scripts|configs|plugins|betas|campaigns|maintenance|provisioning|matches)(?:\/[^/]+)?|game-files|leaderboard(?:\/players\/[^/]+(?:\/[^/]+)?)?)$/;
|
||||
@@ -16,6 +18,8 @@ export function safeReturnHref(value: string | null | undefined, fallback: strin
|
||||
try {
|
||||
const url = new URL(value, origin);
|
||||
if (url.origin !== origin || !pagePath.test(url.pathname)) return fallback;
|
||||
if (url.pathname === '/activity' || url.pathname === '/operations')
|
||||
return activityRedirectHref(url);
|
||||
return url.pathname + url.search + url.hash;
|
||||
} catch {
|
||||
return fallback;
|
||||
@@ -45,8 +49,6 @@ export function returnLabel(href: string): string {
|
||||
if (path.startsWith('/hosts/')) return 'Back to host';
|
||||
const names: Record<string, string> = {
|
||||
'': 'Servers',
|
||||
activity: 'Activity',
|
||||
operations: 'Activity',
|
||||
autoscaling: 'Autoscaling',
|
||||
collections: 'Collections',
|
||||
hosts: 'Hosts',
|
||||
|
||||
@@ -28,8 +28,7 @@ export const navigationGroups: NavigationGroup[] = [
|
||||
label: 'Hosts',
|
||||
href: '/hosts',
|
||||
shortcut: 'o',
|
||||
matches: (path) =>
|
||||
path === '/hosts' || /^\/hosts\/(?!operations(?:\/|$))/.test(path)
|
||||
matches: (path) => path === '/hosts' || path.startsWith('/hosts/')
|
||||
},
|
||||
{ label: 'Capacity', href: '/capacity' },
|
||||
{ label: 'Autoscaling', href: '/autoscaling' },
|
||||
@@ -52,13 +51,6 @@ export const navigationGroups: NavigationGroup[] = [
|
||||
id: 'activity',
|
||||
label: 'Activity',
|
||||
items: [
|
||||
{
|
||||
label: 'Activity log',
|
||||
href: '/activity',
|
||||
shortcut: 'd',
|
||||
matches: (path) =>
|
||||
path === '/activity' || path === '/operations' || path === '/hosts/operations'
|
||||
},
|
||||
{
|
||||
label: 'Provisioning',
|
||||
href: '/provisioning',
|
||||
|
||||
Reference in New Issue
Block a user