Skip to content

Commit

Permalink
[DDO-3789] Expose Janitor toggle (#513)
Browse files Browse the repository at this point in the history
* fails typecheck

* updated client library
  • Loading branch information
jack-r-warren authored Jul 17, 2024
1 parent 14b5703 commit 8ce94fd
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 5 deletions.
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
1 change: 1 addition & 0 deletions app/routes/_layout.environments.$environmentName.edit.tsx
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

0 comments on commit 8ce94fd

Please sign in to comment.