Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDO-3789] Expose Janitor toggle #513

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ export const EnvironmentEditableFields: React.FunctionComponent<
setDefaultCluster,
selfEmail,
}) => {
const [enableJanitor, setEnableJanitor] = useState(
environment?.enableJanitor != null
? environment.enableJanitor.toString()
: // Technically the API does a more complex default operation here if we didn't pass a value
// (false for static, true for templates, copy template for BEEs) but we optimize for the
// 99% case here by having UI-created anything default to true. If this component queried
// the template or something then we could recreate the API's behavior but that's more
// effort than we need right now.
"true",
);
const [requiresSuitability, setRequiresSuitability] = useState(
environment?.requiresSuitability != null
? environment.requiresSuitability.toString()
Expand All @@ -73,6 +83,37 @@ export const EnvironmentEditableFields: React.FunctionComponent<
);
return (
<div className="flex flex-col space-y-4">
{environment?.name?.includes("prod") || (
<div>
<h2 className="font-light text-2xl text-color-header-text">
Enable Janitor?
</h2>
<p>
The Janitor service helps reduce internal cloud costs in our
non-production environments by cleaning up resources after a set
period of time. Chart-level configuration may ignore this field,
especially for live environments.
</p>
{creating || (
<p className="mt-2">
Editing this field for an existing environment may not take effect
immediately or evenly; the entire environment and the generator
will need to be synced. Feel free to reach out to DevOps for help.
</p>
)}
<EnumInputSelect
name="enableJanitor"
className="grid grid-cols-2 mt-2"
fieldValue={enableJanitor}
setFieldValue={setEnableJanitor}
enums={[
["Yes", "true"],
["No", "false"],
]}
{...EnvironmentColors}
/>
</div>
)}
<div>
<h2 className="font-light text-2xl text-color-header-text">
Require Suitability?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export async function action({ request, params }: ActionFunctionArgs) {
requiresSuitability: formData.get("requiresSuitability") === "true",
namePrefixesDomain: formData.get("namePrefixesDomain") === "true",
preventDeletion: formData.get("preventDeletion") === "true",
enableJanitor: formData.get("enableJanitor") === "true",
};

return new EnvironmentsApi(SherlockConfiguration)
Expand Down
1 change: 1 addition & 0 deletions app/routes/_layout.environments.new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export async function action({ request }: ActionFunctionArgs) {
requiresSuitability: formData.get("requiresSuitability") === "true",
namePrefixesDomain: formData.get("namePrefixesDomain") === "true",
preventDeletion: formData.get("preventDeletion") === "true",
enableJanitor: formData.get("enableJanitor") === "true",
offlineScheduleBeginEnabled:
formData.get("offlineScheduleBeginEnabled") === "true",
offlineScheduleBeginTime:
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@remix-run/node": "^v2.9.2",
"@remix-run/react": "^v2.9.2",
"@remix-run/serve": "^v2.9.2",
"@sherlock-js-client/sherlock": "^1.5.17",
"@sherlock-js-client/sherlock": "^1.5.20",
"lucide-react": "^0.396.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
Loading