7b862b9438
* Delete the proxy app (was v2) * Delete RunPresenterElectric * Select the best proj/org/env * Storing current proj/env in DB. Initial selection logic working with tasks page * 2sm needed to be in the Tailwind merge list * Move the task stream route (although we don’t actually use the env for now) * Alerts moved from /v3 * API keys page moved from /v3 * Concurrency page moved from /v3 * WIP on side menu sections * Improved the accordion animation * Moved schedules from /v3 * More pages moved * Move pages working * Run page working * Schedules working * Moved deployments * Alert pages moved * Delete electric hooks, not used * Started setting up blank states * Test page working * Removed “Select task” from the test page * Some work on deployment page * Style tweaks * Redirect from project root to approriate env * Improved env selector styling * Fix for jsx errors * Better min width on env selector * Improved the env switching logic * Added deployments to env routing * Redirect deployments to the correct env * Redirect run from proj to env * JSX icon fix * Only allow single env schedules from now on * Remove env var count from the API keys page * Move improvements and redirects * Project settings moved * Fix for scroll area on test page * Tweaked the test design * Made recent payloads column narrower * Improved the test layout some more * Added org icon, new project selector menu * WIP on org switching menu * Org switching is working * New menu working well, removed old side menu items * Buttons can now have a component name or an actual component for their icons * Removed the Projects page, instead redirect appropriately * Fix for broken blank states * Minor run table improvements * Removed unused switcher log and logic * Concurrency page fix for invalid html, improved layout * Minor improvements * Moved the side menu to the project level * Improved account styling * Moved org settings pages (with redirects) * Add current plan to billing side menu link * Upgrade to get staging from env dropdown * New env badge on concurrency limits page * Show Run Engine version in span presenter * New promote icon * Concurrency limits page is the sum of engine v1 + v2 queues * Fix for missing batch import * Added currentConcurrencyOfEnvQueue function * Basic avatar setting working * Avatar setting is working * You can change the color of your icon * Avatar improvements * Bugfix for mising prop * Removed some old env badges * Fixed replaying * Removed EnvironmentLabel * Old env badge deleted, changed everywhere to the new one * Fix for Slack integration paths * Fix for waitpoint completion form moving * Bulk replay/cancel env fix * Fix for alert webhook path * Redirect projects/v3/* to project/* * Fixes for CLI redirect routes * Remove welcome email (unused) * Change how we count schedules towards your limits * Use new schedules limits when checking a schedule * Added projectId back in to task queries (indexes) * WIP dev presence * CLI modal * Moved things around and use Context * Fix for p inside p * Dev connected status on run page * Correct dev env (not a teammates) * Show disconnected message at the end * Minor tweak on project dropdown icon padding * Fix for inconsistent date format for presence * Added a message when pushing to the billing page * Center the team page * Project settings page centered * Improvements to the dev presence
69 lines
1.7 KiB
TypeScript
69 lines
1.7 KiB
TypeScript
import { type RuntimeEnvironmentType } from "@trigger.dev/database";
|
|
|
|
const environmentSortOrder: RuntimeEnvironmentType[] = [
|
|
"DEVELOPMENT",
|
|
"PREVIEW",
|
|
"STAGING",
|
|
"PRODUCTION",
|
|
];
|
|
|
|
type SortType = {
|
|
type: RuntimeEnvironmentType;
|
|
userName?: string | null;
|
|
};
|
|
|
|
export function sortEnvironments<T extends SortType>(environments: T[]): T[] {
|
|
return environments.sort((a, b) => {
|
|
const aIndex = environmentSortOrder.indexOf(a.type);
|
|
const bIndex = environmentSortOrder.indexOf(b.type);
|
|
|
|
const difference = aIndex - bIndex;
|
|
|
|
if (difference === 0) {
|
|
//same environment so sort by name
|
|
const usernameA = a.userName || "";
|
|
const usernameB = b.userName || "";
|
|
return usernameA.localeCompare(usernameB);
|
|
}
|
|
|
|
return difference;
|
|
});
|
|
}
|
|
|
|
type FilterableEnvironment =
|
|
| {
|
|
type: RuntimeEnvironmentType;
|
|
orgMemberId?: string;
|
|
}
|
|
| {
|
|
type: RuntimeEnvironmentType;
|
|
//intentionally vague so we can match anything
|
|
orgMember?: Record<string, any>;
|
|
};
|
|
|
|
export function filterOrphanedEnvironments<T extends FilterableEnvironment>(
|
|
environments: T[]
|
|
): T[] {
|
|
return environments.filter((environment) => {
|
|
if (environment.type !== "DEVELOPMENT") return true;
|
|
|
|
if ("orgMemberId" in environment) {
|
|
return !!environment.orgMemberId;
|
|
}
|
|
|
|
if ("orgMember" in environment) {
|
|
return !!environment.orgMember;
|
|
}
|
|
|
|
return false;
|
|
});
|
|
}
|
|
|
|
export function onlyDevEnvironments<T extends FilterableEnvironment>(environments: T[]): T[] {
|
|
return environments.filter((e) => e.type === "DEVELOPMENT");
|
|
}
|
|
|
|
export function exceptDevEnvironments<T extends FilterableEnvironment>(environments: T[]): T[] {
|
|
return environments.filter((e) => e.type !== "DEVELOPMENT");
|
|
}
|