Skip to content

Commit 425bd94

Browse files
authored
Community settings (#3655)
* Community settings WIP. * Adding more to community settings. * Translations (tmp) * Update express methods. * Fix community loading * Adding community settings link * Fixing dropdown menu offset * Adding proper community remove and purge dialogs * Adding ability to add and remove mods from community settings * Adding transferring community to community settings. * Fixing remove and transfer dialogs * Remove leaveModTeam from community sidebar * Fixing lint. * Make community settings only accessible by mod or admin with local community.
1 parent 87c330f commit 425bd94

22 files changed

+1842
-1350
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "lemmy-translations"]
22
path = lemmy-translations
33
url = https://github.com/lemmynet/lemmy-translations
4-
branch = main
4+
branch = community_settings_1

lemmy-translations

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"@types/bootstrap": "^5.2.10",
113113
"@types/compression": "^1.8.1",
114114
"@types/cookie-parser": "^1.4.7",
115-
"@types/express": "^5.0.1",
115+
"@types/express": "^5.0.6",
116116
"@types/html-to-text": "^9.0.4",
117117
"@types/markdown-it": "^14.1.2",
118118
"@types/markdown-it-container": "^2.0.10",

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/server/handlers/manifest-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default async (_req: Request, res: Response) => {
2020
}
2121
}
2222

23-
res.setHeader("content-type", "application/manifest+json");
23+
res.type("application/manifest+json");
2424

2525
res.send(manifest);
2626
};

src/server/handlers/robots-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Response } from "express";
22

33
export default async ({ res }: { res: Response }) => {
4-
res.setHeader("content-type", "text/plain; charset=utf-8");
4+
res.type("text/plain; charset=utf-8");
55

66
res.send(`User-Agent: *
77
Disallow: /login

src/server/middleware.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function setDefaultCsp({
1111
}) {
1212
res.locals.cspNonce = crypto.randomBytes(16).toString("hex");
1313

14-
res.setHeader(
14+
res.set(
1515
"Content-Security-Policy",
1616
`default-src 'self';
1717
manifest-src *;
@@ -50,15 +50,15 @@ export function setCacheControl(
5050
// Static content gets cached publicly for a day
5151
caching = "public, max-age=86400";
5252
} else {
53-
res.setHeader("Vary", "Cookie, Accept, Accept-Language");
53+
res.set("Vary", "Cookie, Accept, Accept-Language");
5454
if (getJwtCookie(req.headers)) {
5555
caching = "private";
5656
} else {
5757
caching = "public, max-age=60";
5858
}
5959
}
6060

61-
res.setHeader("Cache-Control", caching);
61+
res.set("Cache-Control", caching);
6262
}
6363

6464
next();

src/shared/components/common/badges.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ export function CommunityBadges({
2525
subject={community}
2626
lessBadges={lessBadges}
2727
/>
28-
{!lessBadges && (
29-
<li className="list-inline-item">
30-
<Link
31-
className="badge text-bg-secondary"
32-
to={`/modlog/${community.id}`}
33-
>
34-
{I18NextService.i18n.t("modlog")}
35-
</Link>
36-
</li>
37-
)}
3828
</ul>
3929
);
4030
}

src/shared/components/common/content-actions/content-action-dropdown.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
PersonView,
1313
PostView,
1414
} from "lemmy-js-client";
15-
import { amAdmin, amCommunityCreator, amMod, canAdmin } from "@utils/roles";
15+
import { amAdmin, amTopModExcludeMe, amMod, canAdmin } from "@utils/roles";
1616
import ActionButton from "./action-button";
1717
import classNames from "classnames";
1818
import { Link } from "inferno-router";
@@ -278,7 +278,7 @@ export default class ContentActionDropdown extends Component<
278278
<Icon icon="more-vertical" inline />
279279
</button>
280280

281-
<ul className="dropdown-menu dropdown-menu-end" id={dropdownId}>
281+
<ul className="dropdown-menu" id={dropdownId}>
282282
{this.state.dropdownOpenedOnce && (
283283
<>
284284
{/* Links / fedilinks */}
@@ -642,7 +642,7 @@ export default class ContentActionDropdown extends Component<
642642
</>
643643
)}
644644
{this.props.myUserInfo &&
645-
(amCommunityCreator(
645+
(amTopModExcludeMe(
646646
creator.id,
647647
moderators,
648648
this.props.myUserInfo,
Lines changed: 41 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,59 @@
11
import { getStaticDir } from "@utils/env";
22
import classNames from "classnames";
3-
import { Component } from "inferno";
43
import { I18NextService } from "../../services";
54

6-
interface IconProps {
5+
type IconProps = {
76
icon: string;
87
classes?: string;
98
inline?: boolean;
109
small?: boolean;
11-
}
10+
};
1211

13-
export class Icon extends Component<IconProps, any> {
14-
constructor(props: any, context: any) {
15-
super(props, context);
12+
export function Icon({ icon, classes, inline, small }: IconProps) {
13+
let iconAltText: string | undefined;
14+
if (icon === "plus-square" || icon === "minus-square") {
15+
iconAltText = `${I18NextService.i18n.t("show_content")}`;
1616
}
1717

18-
render() {
19-
let iconAltText: string | undefined;
20-
if (
21-
this.props.icon === "plus-square" ||
22-
this.props.icon === "minus-square"
23-
) {
24-
iconAltText = `${I18NextService.i18n.t("show_content")}`;
25-
}
26-
27-
return (
28-
<svg
29-
className={classNames("icon", this.props.classes, {
30-
"icon-inline": this.props.inline,
31-
small: this.props.small,
32-
})}
33-
{...(iconAltText
34-
? { role: "img", "aria-describedby": `${this.props.icon}-alt` }
35-
: {})}
36-
>
37-
{iconAltText && (
38-
<title id={`${this.props.icon}-alt`}>{iconAltText}</title>
39-
)}
40-
<use
41-
xlinkHref={`${getStaticDir()}/assets/symbols.svg#icon-${
42-
this.props.icon
43-
}`}
44-
></use>
45-
</svg>
46-
);
47-
}
18+
return (
19+
<svg
20+
className={classNames("icon", classes, {
21+
"icon-inline": inline,
22+
small: small,
23+
})}
24+
{...(iconAltText
25+
? { role: "img", "aria-describedby": `${icon}-alt` }
26+
: {})}
27+
>
28+
{iconAltText && <title id={`${icon}-alt`}>{iconAltText}</title>}
29+
<use
30+
xlinkHref={`${getStaticDir()}/assets/symbols.svg#icon-${icon}`}
31+
></use>
32+
</svg>
33+
);
4834
}
4935

50-
interface SpinnerProps {
36+
type SpinnerProps = {
5137
large?: boolean;
5238
className?: string;
39+
};
40+
41+
export function Spinner({ large, className }: SpinnerProps) {
42+
return (
43+
<Icon
44+
icon="spinner"
45+
classes={classNames("spin", className, {
46+
"spinner-large": large,
47+
})}
48+
/>
49+
);
5350
}
5451

55-
export class Spinner extends Component<SpinnerProps, any> {
56-
constructor(props: any, context: any) {
57-
super(props, context);
58-
}
59-
60-
render() {
61-
return (
62-
<Icon
63-
icon="spinner"
64-
classes={classNames("spin", this.props.className, {
65-
"spinner-large": this.props.large,
66-
})}
67-
/>
68-
);
69-
}
70-
}
71-
72-
export class PurgeWarning extends Component<any, any> {
73-
constructor(props: any, context: any) {
74-
super(props, context);
75-
}
76-
77-
render() {
78-
return (
79-
<div className="purge-warning mt-2 alert alert-danger" role="alert">
80-
<Icon icon="alert-triangle" classes="icon-inline me-2" />
81-
{I18NextService.i18n.t("purge_warning")}
82-
</div>
83-
);
84-
}
52+
export function PurgeWarning() {
53+
return (
54+
<div className="purge-warning mt-2 alert alert-danger" role="alert">
55+
<Icon icon="alert-triangle" classes="icon-inline me-2" />
56+
{I18NextService.i18n.t("purge_warning")}
57+
</div>
58+
);
8559
}

0 commit comments

Comments
 (0)