Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notifications: design and configuration updates #4562

Merged
merged 5 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add floatingbellindicator configuration
  • Loading branch information
kabeaty committed Feb 26, 2024
commit 279ddc6266f9d1ff3dbe7b0d604a250e82acf459
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.disabledLabel {
color: var(--palette-grey-400);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Localized } from "@fluent/react/compat";
import React, { FunctionComponent } from "react";
import { FormSpy } from "react-final-form";
import { graphql } from "react-relay";

import {
Expand All @@ -13,11 +14,14 @@ import ConfigBox from "../../ConfigBox";
import Header from "../../Header";
import OnOffField from "../../OnOffField";

import styles from "./InPageNotificationsConfig.css";

// eslint-disable-next-line no-unused-expressions
graphql`
fragment InPageNotificationsConfig_formValues on Settings {
inPageNotifications {
enabled
floatingBellIndicator
}
}
`;
Expand Down Expand Up @@ -49,6 +53,29 @@ const InPageNotificationsConfig: FunctionComponent<Props> = ({ disabled }) => (
</Localized>
<OnOffField name="inPageNotifications.enabled" disabled={disabled} />
</FormField>
<FormSpy subscription={{ values: true }}>
{(props) => {
const inPageDisabled = !props.values.inPageNotifications?.enabled;
return (
<FormField container={<FieldSet />}>
<Localized id="configure-general-inPageNotifications-floatingBellIndicator">
<Label
className={
disabled || inPageDisabled ? styles.disabledLabel : ""
}
component="legend"
>
Floating bell indicator
</Label>
</Localized>
<OnOffField
name="inPageNotifications.floatingBellIndicator"
disabled={disabled || inPageDisabled}
/>
</FormField>
);
}}
</FormSpy>
</ConfigBox>
);

Expand Down
10 changes: 9 additions & 1 deletion client/src/core/client/stream/App/TabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export interface Props {
showNotificationsTab: boolean;
hasNewNotifications: boolean;
userNotificationsEnabled: boolean;
inPageNotifications?: {
enabled: boolean | null;
floatingBellIndicator: boolean | null;
} | null;
mode:
| "COMMENTS"
| "QA"
Expand Down Expand Up @@ -199,7 +203,11 @@ const AppTabBar: FunctionComponent<Props> = (props) => {
)}
tabID="NOTIFICATIONS"
variant="notifications"
float="right"
float={
props.inPageNotifications?.floatingBellIndicator
? "right"
: "none"
}
title={notificationsText}
>
<div className={cn(styles.notificationsIcon)}>
Expand Down
16 changes: 10 additions & 6 deletions client/src/core/client/stream/App/TabBarContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ export const TabBarContainer: FunctionComponent<Props> = ({

return (
<>
{!!viewer && !!settings?.inPageNotifications?.enabled && (
<FloatingNotificationButton
viewerID={viewer?.id}
enabled={!!viewer?.inPageNotifications?.enabled}
/>
)}
{!!viewer &&
!!settings?.inPageNotifications?.enabled &&
!!settings?.inPageNotifications?.floatingBellIndicator && (
<FloatingNotificationButton
viewerID={viewer?.id}
enabled={!!viewer?.inPageNotifications?.enabled}
/>
)}
<IntersectionProvider threshold={[0, 1]}>
<TabBar
mode={story ? story.settings.mode : GQLSTORY_MODE.COMMENTS}
Expand All @@ -112,6 +114,7 @@ export const TabBarContainer: FunctionComponent<Props> = ({
}
hasNewNotifications={!!hasNewNotifications}
userNotificationsEnabled={!!viewer?.inPageNotifications?.enabled}
inPageNotifications={settings?.inPageNotifications}
onTabClick={handleSetActiveTab}
/>
</IntersectionProvider>
Expand Down Expand Up @@ -143,6 +146,7 @@ const enhanced = withSetActiveTabMutation(
featureFlags
inPageNotifications {
enabled
floatingBellIndicator
}
}
`,
Expand Down
3 changes: 2 additions & 1 deletion client/src/core/client/stream/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ export const settings = createFixture<GQLSettings>({
},
},
inPageNotifications: {
enabled: false,
enabled: true,
floatingBellIndicator: true,
},
});

Expand Down
11 changes: 11 additions & 0 deletions client/src/core/client/stream/test/profile/preferences.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ it("render email notifications form", async () => {
await act(async () => {
await createTestRenderer({
resolvers: createResolversStub<GQLResolver>({
Query: {
settings: () => {
return {
...settings,
inPageNotifications: {
enabled: false,
floatingBellIndicator: true,
},
};
},
},
Mutation: {
updateEmailNotificationSettings,
},
Expand Down
2 changes: 1 addition & 1 deletion client/src/core/client/test/helpers/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function createUser() {
},
ignoreable: true,
inPageNotifications: {
enabled: false,
enabled: true,
},
});
}
Expand Down
1 change: 1 addition & 0 deletions locales/en-US/admin.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ configure-general-inPageNotifications-explanation = Add notifications to Coral.
of your team, when a Pending comment is published. Commenters can
disable visual notification indicators in their Profile preferences. This will remove e-mail notifications.
configure-general-inPageNotifications-enabled = In-page notifications enabled
configure-general-inPageNotifications-floatingBellIndicator = Floating bell indicator

#### Closed Stream Message
configure-general-closedStreamMessage-title = Closed comment stream message
Expand Down
5 changes: 3 additions & 2 deletions server/src/core/server/graph/resolvers/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const Settings: GQLSettingsTypeResolver<Tenant> = {
return flairBadges;
},
dsa: ({ dsa = defaultDSAConfiguration }) => dsa,
inPageNotifications: ({ inPageNotifications = { enabled: false } }) =>
inPageNotifications,
inPageNotifications: ({
inPageNotifications = { enabled: true, floatingBellIndicator: true },
}) => inPageNotifications,
};
8 changes: 8 additions & 0 deletions server/src/core/server/graph/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,8 @@ type PremoderateEmailAddressConfiguration {

type InPageNotificationsConfiguration {
enabled: Boolean

floatingBellIndicator: Boolean
}

input TooManyPeriodsConfigInput {
Expand Down Expand Up @@ -6439,6 +6441,12 @@ input InPageNotificationsConfigurationInput {
enabled when true turns on in-page notifications as an option for commenters.
"""
enabled: Boolean

"""
floatingBellIndicator when true shows a floating bell for notifications; when false,
there is no floating bell and the Notifications tab is aligned left.
"""
floatingBellIndicator: Boolean
}

"""
Expand Down
1 change: 1 addition & 0 deletions server/src/core/server/models/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ export interface TopCommenterConfig {

export interface InPageNotificationsConfig {
enabled?: boolean;
floatingBellIndicator?: boolean;
}

export interface PremoderateEmailAddressConfig {
Expand Down
3 changes: 2 additions & 1 deletion server/src/core/server/models/tenant/tenant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ export const combineTenantDefaultsAndInput = (
enabled: false,
},
inPageNotifications: {
enabled: false,
enabled: true,
floatingBellIndicator: true,
},
};

Expand Down
3 changes: 2 additions & 1 deletion server/src/core/server/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ export const createTenantFixture = (
oEmbedAllowedOrigins: [],
},
inPageNotifications: {
enabled: false,
enabled: true,
floatingBellIndicator: true,
},
};

Expand Down
Loading