Skip to content

Commit

Permalink
DEVPROD-4757 Add additional confirmation to default to repo button (#100
Browse files Browse the repository at this point in the history
)
  • Loading branch information
khelif96 authored May 2, 2024
1 parent 95f9f94 commit 3d3d4db
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 deletions.
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 @@ -43,6 +43,7 @@ describe("Access page", () => {

it("Clicking on 'Default to Repo on Page' selects the 'Default to repo (unrestricted)' radio box and produces a success banner", () => {
cy.dataCy("default-to-repo-button").click();
cy.getInputByLabel('Type "confirm" to confirm your action').type("confirm");
cy.dataCy("default-to-repo-modal").contains("Confirm").click();
cy.validateToast("success", "Successfully defaulted page to repo");
cy.getInputByLabel("Default to repo (unrestricted)").should("be.checked");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,10 @@ describe("Project Settings when defaulting to repo", () => {
cy.dataCy("navitem-github-commitqueue").click();
cy.dataCy("default-to-repo-button").click();
cy.dataCy("default-to-repo-modal").should("be.visible");
cy.dataCy("default-to-repo-modal").contains("button", "Confirm").click();
cy.getInputByLabel('Type "confirm" to confirm your action').type(
"confirm",
);
cy.dataCy("default-to-repo-modal").contains("Confirm").click();
cy.validateToast("success", "Successfully defaulted page to repo");
cy.dataCy("accordion-toggle").scrollIntoView();
cy.dataCy("accordion-toggle")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ describe("Repo Settings", () => {
cy.visit(getAccessRoute(projectUseRepoEnabled));
cy.dataCy("default-to-repo-button").click();
cy.dataCy("default-to-repo-modal").should("be.visible");
cy.dataCy("default-to-repo-modal").contains("button", "Confirm").click();
cy.getInputByLabel('Type "confirm" to confirm your action').type(
"confirm",
);
cy.dataCy("default-to-repo-modal").contains("Confirm").click();
cy.validateToast("success", "Successfully defaulted page to repo");
cy.dataCy("navitem-patch-aliases").click();
cy.dataCy("expandable-card-title").contains("my alias name");
Expand Down
6 changes: 5 additions & 1 deletion apps/spruce/src/constants/externalResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export const wikiBaseUrl =

export const wikiUrl = `${wikiBaseUrl}/Home`;

export const projectDistroSettingsDocumentationUrl = `${wikiBaseUrl}/Project-Configuration/Project-and-Distro-Settings`;
const projectSettingsDocumentationUrl = `${wikiBaseUrl}/Project-Configuration`;

export const projectDistroSettingsDocumentationUrl = `${projectSettingsDocumentationUrl}/Project-and-Distro-Settings`;

export const projectSettingsRepoSettingsDocumentationUrl = `${projectSettingsDocumentationUrl}/Repo-Level-Settings`;

export const versionControlDocumentationUrl = `${projectDistroSettingsDocumentationUrl}#version-control`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { useMutation } from "@apollo/client";
import { Body } from "@leafygreen-ui/typography";
import { useProjectSettingsAnalytics } from "analytics";
import { ConfirmationModal } from "components/ConfirmationModal";
import { StyledLink } from "components/styles";
import { projectSettingsRepoSettingsDocumentationUrl } from "constants/externalResources";
import { useToastContext } from "context/toast";
import {
DefaultSectionToRepoMutation,
Expand Down Expand Up @@ -55,9 +58,20 @@ export const DefaultSectionToRepoModal = ({
handleClose();
}}
open={open}
variant="danger"
requiredInputText="confirm"
title="Are you sure you want to default all settings in this section to the repo settings?"
>
Settings will continue to be modifiable at the project level.
<>
<Body weight="medium">
This operation is not reversible and will overwrite any existing
project settings! Read more{" "}
<StyledLink href={projectSettingsRepoSettingsDocumentationUrl}>
here.
</StyledLink>
</Body>
Settings will continue to be modifiable at the project level.
</>
</ConfirmationModal>
);
};
1 change: 1 addition & 0 deletions apps/spruce/src/pages/projectSettings/HeaderButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export const HeaderButtons: React.FC<Props> = ({ id, projectType, tab }) => {
<Button
onClick={() => setDefaultModalOpen(true)}
data-cy="default-to-repo-button"
title="Clicking this button will open a confirmation modal with more information."
>
Default to Repo on Page
</Button>
Expand Down

0 comments on commit 3d3d4db

Please sign in to comment.