Skip to content

Commit

Permalink
refactor(coral): Update text for blocked actions (#1667)
Browse files Browse the repository at this point in the history
* Extend tests for deletion blocking topic and connector
* Update text for blocked edit of topic and connector.
* Update text for blocked claim request.
* Update text for blocked schema request.
* Update text for blocked promotion.

Signed-off-by: Mirjam Aulbach <[email protected]>
  • Loading branch information
programmiri authored Aug 23, 2023
1 parent 68c4211 commit 84e3033
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 27 deletions.
8 changes: 4 additions & 4 deletions coral/src/app/features/components/ClaimBanner.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe("ClaimBanner", () => {

it("shows information that the topic has a pending request", () => {
const description = screen.getByText(
`${testProps.entityName} has pending requests. Your team cannot claim ownership at this time.`
`Your team cannot claim ownership at this time. ${testProps.entityName} has pending requests.`
);

expect(description).toBeVisible();
Expand All @@ -101,7 +101,7 @@ describe("ClaimBanner", () => {

it("shows information that the connector has a pending request", () => {
const description = screen.getByText(
`${testProps.entityName} has pending requests. Your team cannot claim ownership at this time.`
`Your team cannot claim ownership at this time. ${testProps.entityName} has pending requests.`
);

expect(description).toBeVisible();
Expand All @@ -127,7 +127,7 @@ describe("ClaimBanner", () => {

it("shows information that the topic has an open claim request", () => {
const description = screen.getByText(
`A claim request for ${testProps.entityName} is already in progress.`
`Your team cannot claim ownership at this time. A claim request for ${testProps.entityName} is already in progress.`
);

expect(description).toBeVisible();
Expand Down Expand Up @@ -162,7 +162,7 @@ describe("ClaimBanner", () => {

it("shows information that the connector has an open claim request", () => {
const description = screen.getByText(
`A claim request for ${testProps.entityName} is already in progress.`
`Your team cannot claim ownership at this time. A claim request for ${testProps.entityName} is already in progress.`
);

expect(description).toBeVisible();
Expand Down
5 changes: 3 additions & 2 deletions coral/src/app/features/components/ClaimBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const ClaimBanner = ({
<Banner image={illustration} layout="vertical" title={""}>
<Box.Flex minHeight={"full"}>
<Box.Flex component={"p"} alignSelf={"center"}>
{`${entityName} has pending requests. Your team cannot claim ownership at this time.`}
{`Your team cannot claim ownership at this time. ${entityName} has pending requests.`}
</Box.Flex>
</Box.Flex>
</Banner>
Expand All @@ -42,7 +42,8 @@ const ClaimBanner = ({
return (
<Banner image={illustration} layout="vertical" title={""}>
<Box component={"p"} marginBottom={"l1"}>
A claim request for {entityName} is already in progress.
Your team cannot claim ownership at this time. A claim request for{" "}
{entityName} is already in progress.
</Box>
<InternalLinkButton
to={`/requests/${entityType}s?search=${entityName}&requestType=CLAIM&status=CREATED&page=1`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ describe("EntityDetailsHeader", () => {
expect(link).toHaveAttribute("aria-disabled", "true");
expect(link).not.toHaveAttribute("href");
expect(link).toHaveAccessibleName(
"Edit topic. The topic has a pending request."
"Edit topic. You cannot edit the topic at this time. my-nice-topic has a pending request."
);
});
});
Expand All @@ -459,7 +459,7 @@ describe("EntityDetailsHeader", () => {
expect(link).toHaveAttribute("aria-disabled", "true");
expect(link).not.toHaveAttribute("href");
expect(link).toHaveAccessibleName(
"Edit connector. The connector has a pending request."
"Edit connector. You cannot edit the connector at this time. my-nice-connector has a pending request."
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion coral/src/app/features/components/EntityDetailsHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function EntityDetailsHeader(props: TopicOverviewHeaderProps) {

{showEditButton && hasPendingRequest && (
<DisabledButtonTooltip
tooltip={`The ${entity.type} has a pending request.`}
tooltip={`You cannot edit the ${entity.type} at this time. ${entity.name} has a pending request.`}
role={"link"}
>
{`Edit ${entity.type}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,14 @@ describe("ConnectorSettings", () => {

afterAll(cleanup);

it("shows information connector can not be deleted at the moment", () => {
const information = screen.getByText(
"You can not create a delete request for this connector:"
);

expect(information).toBeVisible();
});

it("shows information that connector has a pending request and open ACL requests", () => {
const reasonsList = screen.getByRole("list");
const listItem = within(reasonsList).getAllByRole("listitem");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ describe("PromotionBanner", () => {

it("shows information about the open request", () => {
const information = screen.getByText(
`${testTopicName} has a pending request.`
`You cannot promote the schema at this time. ${testTopicName} has a pending request.`
);

expect(information).toBeVisible();
Expand Down Expand Up @@ -183,7 +183,7 @@ describe("PromotionBanner", () => {

it("shows information about the open request", () => {
const information = screen.getByText(
`${testTopicName} has a pending request.`
`You cannot promote the topic at this time. ${testTopicName} has a pending request.`
);

expect(information).toBeVisible();
Expand Down Expand Up @@ -221,7 +221,7 @@ describe("PromotionBanner", () => {

it("shows information about the open request", () => {
const information = screen.getByText(
`A claim request for ${testTopicName} is in progress.`
`You cannot promote the schema at this time. A claim request for ${testTopicName} is in progress.`
);

expect(information).toBeVisible();
Expand Down Expand Up @@ -259,7 +259,7 @@ describe("PromotionBanner", () => {

it("shows information about the open request", () => {
const information = screen.getByText(
`A claim request for ${testTopicName} is in progress.`
`You cannot promote the topic at this time. A claim request for ${testTopicName} is in progress.`
);

expect(information).toBeVisible();
Expand Down Expand Up @@ -297,7 +297,7 @@ describe("PromotionBanner", () => {

it("shows information about the open request", () => {
const information = screen.getByText(
`An promotion request for ${testTopicName} is already in progress.`
`You cannot promote the schema at this time. An promotion request for ${testTopicName} is already in progress.`
);

expect(information).toBeVisible();
Expand Down Expand Up @@ -335,7 +335,7 @@ describe("PromotionBanner", () => {

it("shows information about the open request", () => {
const information = screen.getByText(
`An promotion request for ${testTopicName} is already in progress.`
`You cannot promote the topic at this time. An promotion request for ${testTopicName} is already in progress.`
);

expect(information).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@ import { InternalLinkButton } from "src/app/components/InternalLinkButton";
import illustration from "src/app/images/topic-details-banner-Illustration.svg";
import { PromotionStatus } from "src/domain/promotion";

type RequestTypeLocal = "CLAIM" | "ALL" | "PROMOTE";
type EntityTypeLocal = "schema" | "topic";

interface PromotionBannerProps {
// `entityName` is only optional on
// KlawApiModel<"PromotionStatus">
// so we can't rely on it to be part of
// the promotionDetails
entityName: string;
promotionDetails: PromotionStatus;
type: "schema" | "topic";
type: EntityTypeLocal;
promoteElement: ReactElement;
hasOpenClaimRequest: boolean;
hasOpenRequest: boolean;
hasError: boolean;
errorMessage: string;
}

type RequestTypeLocal = "CLAIM" | "ALL" | "PROMOTE";
function getRequestType({
hasOpenClaimRequest,
hasOpenPromotionRequest,
Expand All @@ -41,7 +43,7 @@ function createLink({
entityName,
requestType,
}: {
type: "schema" | "topic";
type: EntityTypeLocal;
entityName: string;
requestType: RequestTypeLocal;
}): string {
Expand All @@ -51,19 +53,23 @@ function createLink({
}

function createText({
type,
entityName,
requestType,
}: {
type: "schema" | "topic";
entityName: string;
requestType: RequestTypeLocal;
}): string {
const defaultText = `You cannot promote the ${type} at this time.`;

if (requestType === "PROMOTE") {
return `An promotion request for ${entityName} is already in progress.`;
return `${defaultText} An promotion request for ${entityName} is already in progress.`;
}
if (requestType === "CLAIM") {
return `A claim request for ${entityName} is in progress.`;
return `${defaultText} A claim request for ${entityName} is in progress.`;
}
return `${entityName} has a pending request.`;
return `${defaultText} ${entityName} has a pending request.`;
}

const PromotionBanner = ({
Expand Down Expand Up @@ -104,7 +110,7 @@ const PromotionBanner = ({
hasOpenPromotionRequest,
});
const link = createLink({ type, entityName, requestType });
const text = createText({ entityName, requestType });
const text = createText({ type, entityName, requestType });

return (
<Banner image={illustration} layout="vertical" title={""}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ describe("TopicDetailsSchema", () => {

it("shows information that there is a pending request", () => {
const info = screen.getByText(
`A schema request for ${testTopicName} is already in progress.`
`You cannot request a schema at this time. A schema request for ${testTopicName} is already in progress.`
);

expect(info).toBeVisible();
Expand Down Expand Up @@ -503,7 +503,7 @@ describe("TopicDetailsSchema", () => {

it("shows information that there is a pending request", () => {
const info = screen.getByText(
`A schema request for ${testTopicName} is already in progress.`
`You cannot request a schema at this time. A schema request for ${testTopicName} is already in progress.`
);

expect(info).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ describe("NoSchemaBanner", () => {

it("shows information about pending request", () => {
const text = screen.getByText(
`A schema request for ${testTopicName} is already in progress.`
`You cannot request a schema at this time. A schema request for ${testTopicName} is already in progress.`
);

expect(text).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("OpenSchemaRequestAlert", () => {

it("shows information about pending request", () => {
const text = screen.getByText(
`A schema request for ${testTopicName} is already in progress.`
`You cannot request a schema at this time. A schema request for ${testTopicName} is already in progress.`
);

expect(text).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function OpenSchemaRequestAlert({
<Box marginBottom={marginBottom}>
<Alert type={"warning"}>
<span>
{`A schema request for ${topicName} is already in progress.`}
{`You cannot request a schema at this time. A schema request for ${topicName} is already in progress.`}
</span>{" "}
<Link
to={`/requests/schemas?status=CREATED&page=1&search=${topicName}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,14 @@ describe("TopicSettings", () => {

afterAll(cleanup);

it("shows information topic can not be deleted at the moment", () => {
const information = screen.getByText(
"You can not create a delete request for this topic:"
);

expect(information).toBeVisible();
});

it("shows information that topic has a pending request and open ACL requests", () => {
const reasonsList = screen.getByRole("list");
const listItem = within(reasonsList).getAllByRole("listitem");
Expand Down

0 comments on commit 84e3033

Please sign in to comment.