const hours = (h: number) => (h === 1 ? "hour" : "hours"); const days = (d: number) => (d === 1 ? "day" : "days"); export const DefaultTTLHelperText = (props: { ttl?: number }) => { const { ttl = 0 } = props; // Error will show once field is considered touched if (ttl < 0) { return null; } if (ttl === 0) { return Workspaces will run until stopped manually.; } return ( Workspaces will default to stopping after {ttl} {hours(ttl)} after being started. ); }; export const ActivityBumpHelperText = (props: { bump?: number }) => { const { bump = 0 } = props; // Error will show once field is considered touched if (bump < 0) { return null; } if (bump === 0) { return ( Workspaces will not have their stop time automatically extended based on user activity. Users can still manually delay the stop time. ); } return ( Workspaces will be automatically bumped by {bump} {hours(bump)} when user activity is detected. ); }; export const FailureTTLHelperText = (props: { ttl?: number }) => { const { ttl = 0 } = props; // Error will show once field is considered touched if (ttl < 0) { return null; } if (ttl === 0) { return Coder will not automatically stop failed workspaces.; } return ( Coder will attempt to stop failed workspaces after {ttl} {days(ttl)}. ); }; export const DormancyTTLHelperText = (props: { ttl?: number }) => { const { ttl = 0 } = props; // Error will show once field is considered touched if (ttl < 0) { return null; } if (ttl === 0) { return Coder will not mark workspaces as dormant.; } return ( Coder will mark workspaces as dormant after {ttl} {days(ttl)} without user connections. ); }; export const DormancyAutoDeletionTTLHelperText = (props: { ttl?: number }) => { const { ttl = 0 } = props; // Error will show once field is considered touched if (ttl < 0) { return null; } if (ttl === 0) { return Coder will not automatically delete dormant workspaces.; } return ( Coder will automatically delete dormant workspaces after {ttl} {days(ttl)} . ); };