Skip to content

Commit

Permalink
DEVPROD-4198: Add prompt when pausing sleep-scheduled host (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophstad authored May 28, 2024
1 parent 958c11a commit ed23d87
Show file tree
Hide file tree
Showing 23 changed files with 584 additions and 253 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ yarn test

To run a particular workspace's unit tests from root:
```bash
yarn test --selectProjects [workspace-name]
yarn test --project [workspace-name]
```
29 changes: 7 additions & 22 deletions apps/parsley/src/gql/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1091,8 +1091,7 @@ export type MutationAddAnnotationIssueArgs = {
};

export type MutationAddFavoriteProjectArgs = {
identifier?: InputMaybe<Scalars["String"]["input"]>;
opts?: InputMaybe<AddFavoriteProjectInput>;
opts: AddFavoriteProjectInput;
};

export type MutationAttachProjectToNewRepoArgs = {
Expand Down Expand Up @@ -1135,16 +1134,11 @@ export type MutationCreatePublicKeyArgs = {
};

export type MutationDeactivateStepbackTaskArgs = {
buildVariantName?: InputMaybe<Scalars["String"]["input"]>;
opts?: InputMaybe<DeactivateStepbackTaskInput>;
projectId?: InputMaybe<Scalars["String"]["input"]>;
taskName?: InputMaybe<Scalars["String"]["input"]>;
opts: DeactivateStepbackTaskInput;
};

export type MutationDefaultSectionToRepoArgs = {
opts?: InputMaybe<DefaultSectionToRepoInput>;
projectId?: InputMaybe<Scalars["String"]["input"]>;
section?: InputMaybe<ProjectSettingsSection>;
opts: DefaultSectionToRepoInput;
};

export type MutationDeleteDistroArgs = {
Expand Down Expand Up @@ -1204,9 +1198,7 @@ export type MutationOverrideTaskDependenciesArgs = {
};

export type MutationPromoteVarsToRepoArgs = {
opts?: InputMaybe<PromoteVarsToRepoInput>;
projectId?: InputMaybe<Scalars["String"]["input"]>;
varNames?: InputMaybe<Array<Scalars["String"]["input"]>>;
opts: PromoteVarsToRepoInput;
};

export type MutationRemoveAnnotationIssueArgs = {
Expand All @@ -1217,8 +1209,7 @@ export type MutationRemoveAnnotationIssueArgs = {
};

export type MutationRemoveFavoriteProjectArgs = {
identifier?: InputMaybe<Scalars["String"]["input"]>;
opts?: InputMaybe<RemoveFavoriteProjectInput>;
opts: RemoveFavoriteProjectInput;
};

export type MutationRemoveItemFromCommitQueueArgs = {
Expand Down Expand Up @@ -2095,14 +2086,12 @@ export type QueryProjectArgs = {

export type QueryProjectEventsArgs = {
before?: InputMaybe<Scalars["Time"]["input"]>;
identifier?: InputMaybe<Scalars["String"]["input"]>;
limit?: InputMaybe<Scalars["Int"]["input"]>;
projectIdentifier?: InputMaybe<Scalars["String"]["input"]>;
projectIdentifier: Scalars["String"]["input"];
};

export type QueryProjectSettingsArgs = {
identifier?: InputMaybe<Scalars["String"]["input"]>;
projectIdentifier?: InputMaybe<Scalars["String"]["input"]>;
projectIdentifier: Scalars["String"]["input"];
};

export type QueryRepoEventsArgs = {
Expand Down Expand Up @@ -2604,8 +2593,6 @@ export type Task = {
status: Scalars["String"]["output"];
stepbackInfo?: Maybe<StepbackInfo>;
tags: Array<Scalars["String"]["output"]>;
/** @deprecated Use files instead */
taskFiles: TaskFiles;
taskGroup?: Maybe<Scalars["String"]["output"]>;
taskGroupMaxHosts?: Maybe<Scalars["Int"]["output"]>;
/** taskLogs returns the tail 100 lines of the task's logs. */
Expand Down Expand Up @@ -2689,8 +2676,6 @@ export type TaskFiles = {
/** TaskFilterOptions defines the parameters that are used when fetching tasks from a Version. */
export type TaskFilterOptions = {
baseStatuses?: InputMaybe<Array<Scalars["String"]["input"]>>;
/** @deprecated Use includeNeverActivatedTasks instead */
includeEmptyActivation?: InputMaybe<Scalars["Boolean"]["input"]>;
includeNeverActivatedTasks?: InputMaybe<Scalars["Boolean"]["input"]>;
limit?: InputMaybe<Scalars["Int"]["input"]>;
page?: InputMaybe<Scalars["Int"]["input"]>;
Expand Down
1 change: 1 addition & 0 deletions apps/spruce/cypress/integration/projectSettings/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe("Access page", () => {
cy.validateToast("success", "Successfully updated project");
// Assert persistence
cy.reload();
saveButtonEnabled(false);
cy.get("@usernameInput").should("not.exist");
});

Expand Down
10 changes: 1 addition & 9 deletions apps/spruce/src/components/DayPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,11 @@ import { useCallback, useState } from "react";
import styled from "@emotion/styled";
import { palette } from "@leafygreen-ui/palette";
import { transitionDuration } from "@leafygreen-ui/tokens";
import { days } from "constants/fieldMaps";
import { size } from "constants/tokens";

const { gray, white } = palette;

const days = [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
];
const emptyState = new Array(days.length).fill(false);

type DayPickerState = Array<boolean>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ interface Props {
canEditRdpPassword: boolean;
canEditSshKeys: boolean;
disableExpirationCheckbox: boolean;
hostUptimeValidation?: {
hostUptimeWarnings?: {
enabledHoursCount: number;
errors: string[];
warnings: string[];
};
instanceTypes: string[];
Expand All @@ -32,7 +31,7 @@ export const getFormSchema = ({
canEditRdpPassword,
canEditSshKeys,
disableExpirationCheckbox,
hostUptimeValidation,
hostUptimeWarnings,
instanceTypes,
myPublicKeys,
noExpirationCheckboxTooltip,
Expand All @@ -41,7 +40,7 @@ export const getFormSchema = ({
}: Props): ReturnType<GetFormSchema> => {
const expirationDetails = getExpirationDetailsSchema({
disableExpirationCheckbox,
hostUptimeValidation,
hostUptimeWarnings,
noExpirationCheckboxTooltip,
timeZone,
});
Expand Down
17 changes: 7 additions & 10 deletions apps/spruce/src/components/Spawn/getFormSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ import {
const today = new Date();

type HostUptimeProps = {
hostUptimeValidation?: {
hostUptimeWarnings?: {
enabledHoursCount: number;
errors: string[];
warnings: string[];
};
timeZone?: string;
};

const getHostUptimeSchema = ({
hostUptimeValidation,
hostUptimeWarnings,
timeZone,
}: HostUptimeProps) => ({
schema: {
Expand Down Expand Up @@ -160,12 +159,11 @@ const getHostUptimeSchema = ({
"ui:descriptionNode": (
<Details
timeZone={timeZone}
totalUptimeHours={hostUptimeValidation?.enabledHoursCount}
totalUptimeHours={hostUptimeWarnings?.enabledHoursCount}
/>
),
"ui:showLabel": false,
"ui:warnings": hostUptimeValidation?.warnings,
"ui:errors": hostUptimeValidation?.errors,
"ui:warnings": hostUptimeWarnings?.warnings,
},
},
});
Expand All @@ -183,9 +181,8 @@ const Details: React.FC<{ timeZone: string; totalUptimeHours: number }> = ({

type ExpirationProps = {
disableExpirationCheckbox: boolean;
hostUptimeValidation?: {
hostUptimeWarnings?: {
enabledHoursCount: number;
errors: string[];
warnings: string[];
};
noExpirationCheckboxTooltip?: string;
Expand All @@ -194,12 +191,12 @@ type ExpirationProps = {

export const getExpirationDetailsSchema = ({
disableExpirationCheckbox,
hostUptimeValidation,
hostUptimeWarnings,
noExpirationCheckboxTooltip,
timeZone,
}: ExpirationProps) => {
const defaultExpiration = getDefaultExpiration();
const hostUptime = getHostUptimeSchema({ hostUptimeValidation, timeZone });
const hostUptime = getHostUptimeSchema({ hostUptimeWarnings, timeZone });
return {
schema: {
title: "Expiration Details",
Expand Down
4 changes: 3 additions & 1 deletion apps/spruce/src/components/Spawn/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ export { DetailsCard } from "./DetailsCard";
export { MountVolumeSelect } from "./MountVolumeSelect";
export {
defaultSleepSchedule,
getEnabledHoursCount,
getHostUptimeFromGql,
validateUptimeSchedule,
getHostUptimeWarnings,
isNullSleepSchedule,
validator,
} from "./utils";
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ interface Props {
isVirtualWorkStation: boolean;
name?: string;
}[];
hostUptimeValidation?: {
hostUptimeWarnings?: {
enabledHoursCount: number;
errors: string[];
warnings: string[];
};
isMigration: boolean;
Expand All @@ -47,7 +46,7 @@ export const getFormSchema = ({
disableExpirationCheckbox,
distroIdQueryParam,
distros,
hostUptimeValidation,
hostUptimeWarnings,
isMigration,
isVirtualWorkstation,
myPublicKeys,
Expand All @@ -74,7 +73,7 @@ export const getFormSchema = ({

const expirationDetails = getExpirationDetailsSchema({
disableExpirationCheckbox,
hostUptimeValidation,
hostUptimeWarnings,
noExpirationCheckboxTooltip,
timeZone,
});
Expand Down
Loading

0 comments on commit ed23d87

Please sign in to comment.