Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
use semantic headings in LabsUserSettingsTab
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerry Archibald committed May 4, 2023
1 parent 603e2f8 commit dd55605
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 150 deletions.
1 change: 0 additions & 1 deletion res/css/_components.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,6 @@
@import "./views/settings/tabs/user/_GeneralUserSettingsTab.pcss";
@import "./views/settings/tabs/user/_HelpUserSettingsTab.pcss";
@import "./views/settings/tabs/user/_KeyboardUserSettingsTab.pcss";
@import "./views/settings/tabs/user/_LabsUserSettingsTab.pcss";
@import "./views/settings/tabs/user/_MjolnirUserSettingsTab.pcss";
@import "./views/settings/tabs/user/_PreferencesUserSettingsTab.pcss";
@import "./views/settings/tabs/user/_SecurityUserSettingsTab.pcss";
Expand Down
5 changes: 0 additions & 5 deletions res/css/views/beta/_BetaCard.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ limitations under the License.
*/

.mx_BetaCard {
margin-bottom: $spacing-20;
padding: $spacing-24;
background-color: $system;
border-radius: 8px;
Expand Down Expand Up @@ -114,10 +113,6 @@ limitations under the License.
}
}
}

&:last-child {
margin-bottom: 0;
}
}

.mx_BetaCard_betaPill {
Expand Down
27 changes: 0 additions & 27 deletions res/css/views/settings/tabs/user/_LabsUserSettingsTab.pcss

This file was deleted.

51 changes: 29 additions & 22 deletions src/components/views/settings/tabs/user/LabsUserSettingsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import BetaCard from "../../../beta/BetaCard";
import SettingsFlag from "../../../elements/SettingsFlag";
import { LabGroup, labGroupNames } from "../../../../../settings/Settings";
import { EnhancedMap } from "../../../../../utils/maps";
import { SettingsSection } from "../../shared/SettingsSection";
import SettingsSubsection, { SettingsSubsectionText } from "../../shared/SettingsSubsection";
import SettingsTab from "../SettingsTab";

export default class LabsUserSettingsTab extends React.Component<{}> {
private readonly labs: string[];
Expand Down Expand Up @@ -54,11 +57,11 @@ export default class LabsUserSettingsTab extends React.Component<{}> {
let betaSection: JSX.Element | undefined;
if (this.betas.length) {
betaSection = (
<div data-testid="labs-beta-section" className="mx_SettingsTab_section">
<>
{this.betas.map((f) => (
<BetaCard key={f} featureId={f} />
))}
</div>
</>
);
}

Expand Down Expand Up @@ -93,31 +96,35 @@ export default class LabsUserSettingsTab extends React.Component<{}> {
labsSections = (
<>
{sortBy(Array.from(groups.entries()), "0").map(([group, flags]) => (
<div className="mx_SettingsTab_section" key={group} data-testid={`labs-group-${group}`}>
<span className="mx_SettingsTab_subheading">{_t(labGroupNames[group])}</span>
<SettingsSubsection
key={group}
data-testid={`labs-group-${group}`}
heading={_t(labGroupNames[group])}
>
{flags}
</div>
</SettingsSubsection>
))}
</>
);
}

return (
<div className="mx_SettingsTab mx_LabsUserSettingsTab">
<div className="mx_SettingsTab_heading">{_t("Upcoming features")}</div>
<div className="mx_SettingsTab_subsectionText">
{_t(
"What's next for %(brand)s? " +
"Labs are the best way to get things early, " +
"test out new features and help shape them before they actually launch.",
{ brand: SdkConfig.get("brand") },
)}
</div>
{betaSection}
<SettingsTab>
<SettingsSection heading={_t("Upcoming features")}>
<SettingsSubsectionText>
{_t(
"What's next for %(brand)s? " +
"Labs are the best way to get things early, " +
"test out new features and help shape them before they actually launch.",
{ brand: SdkConfig.get("brand") },
)}
</SettingsSubsectionText>
{betaSection}
</SettingsSection>

{labsSections && (
<>
<div className="mx_SettingsTab_heading">{_t("Early previews")}</div>
<div className="mx_SettingsTab_subsectionText">
<SettingsSection heading={_t("Early previews")}>
<SettingsSubsectionText>
{_t(
"Feeling experimental? " +
"Try out our latest ideas in development. " +
Expand All @@ -139,11 +146,11 @@ export default class LabsUserSettingsTab extends React.Component<{}> {
},
},
)}
</div>
</SettingsSubsectionText>
{labsSections}
</>
</SettingsSection>
)}
</div>
</SettingsTab>
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License.
*/

import React from "react";
import { render, waitFor } from "@testing-library/react";
import { render, screen, waitFor } from "@testing-library/react";
import { defer } from "matrix-js-sdk/src/utils";

import LabsUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/LabsUserSettingsTab";
Expand Down Expand Up @@ -51,26 +51,27 @@ describe("<LabsUserSettingsTab />", () => {
});

it("renders settings marked as beta as beta cards", () => {
const { getByTestId } = render(getComponent());
expect(getByTestId("labs-beta-section")).toMatchSnapshot();
render(getComponent());
expect(screen.getByText("Upcoming features").parentElement!).toMatchSnapshot();
});

it("does not render non-beta labs settings when disabled in config", () => {
const { container } = render(getComponent());
render(getComponent());
expect(sdkConfigSpy).toHaveBeenCalledWith("show_labs_settings");

const labsSections = container.getElementsByClassName("mx_SettingsTab_section");
// only section is beta section
expect(labsSections.length).toEqual(1);
expect(screen.queryByText("Early previews")).not.toBeInTheDocument();
});

it("renders non-beta labs settings when enabled in config", () => {
// enable labs
sdkConfigSpy.mockImplementation((configName) => configName === "show_labs_settings");
const { container } = render(getComponent());

const labsSections = container.getElementsByClassName("mx_SettingsTab_section");
expect(labsSections).toHaveLength(12);
// non-beta labs section
expect(screen.getByText("Early previews")).toBeInTheDocument();
const labsSections = container.getElementsByClassName("mx_SettingsSubsection");
expect(labsSections).toHaveLength(11);
});

it("allow setting a labs flag which requires unstable support once support is confirmed", async () => {
Expand Down
Loading

0 comments on commit dd55605

Please sign in to comment.