Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "lemmy-translations"]
path = lemmy-translations
url = https://github.com/lemmynet/lemmy-translations
branch = main
branch = community_settings_1
2 changes: 1 addition & 1 deletion lemmy-translations
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"@types/bootstrap": "^5.2.10",
"@types/compression": "^1.8.1",
"@types/cookie-parser": "^1.4.7",
"@types/express": "^5.0.1",
"@types/express": "^5.0.6",
"@types/html-to-text": "^9.0.4",
"@types/markdown-it": "^14.1.2",
"@types/markdown-it-container": "^2.0.10",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/server/handlers/manifest-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default async (_req: Request, res: Response) => {
}
}

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

res.send(manifest);
};
2 changes: 1 addition & 1 deletion src/server/handlers/robots-handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Response } from "express";

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

res.send(`User-Agent: *
Disallow: /login
Expand Down
6 changes: 3 additions & 3 deletions src/server/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function setDefaultCsp({
}) {
res.locals.cspNonce = crypto.randomBytes(16).toString("hex");

res.setHeader(
res.set(
"Content-Security-Policy",
`default-src 'self';
manifest-src *;
Expand Down Expand Up @@ -50,15 +50,15 @@ export function setCacheControl(
// Static content gets cached publicly for a day
caching = "public, max-age=86400";
} else {
res.setHeader("Vary", "Cookie, Accept, Accept-Language");
res.set("Vary", "Cookie, Accept, Accept-Language");
if (getJwtCookie(req.headers)) {
caching = "private";
} else {
caching = "public, max-age=60";
}
}

res.setHeader("Cache-Control", caching);
res.set("Cache-Control", caching);
}

next();
Expand Down
10 changes: 0 additions & 10 deletions src/shared/components/common/badges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ export function CommunityBadges({
subject={community}
lessBadges={lessBadges}
/>
{!lessBadges && (
<li className="list-inline-item">
<Link
className="badge text-bg-secondary"
to={`/modlog/${community.id}`}
>
{I18NextService.i18n.t("modlog")}
</Link>
</li>
)}
</ul>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
PersonView,
PostView,
} from "lemmy-js-client";
import { amAdmin, amCommunityCreator, amMod, canAdmin } from "@utils/roles";
import { amAdmin, amTopModExcludeMe, amMod, canAdmin } from "@utils/roles";
import ActionButton from "./action-button";
import classNames from "classnames";
import { Link } from "inferno-router";
Expand Down Expand Up @@ -278,7 +278,7 @@ export default class ContentActionDropdown extends Component<
<Icon icon="more-vertical" inline />
</button>

<ul className="dropdown-menu dropdown-menu-end" id={dropdownId}>
<ul className="dropdown-menu" id={dropdownId}>
{this.state.dropdownOpenedOnce && (
<>
{/* Links / fedilinks */}
Expand Down Expand Up @@ -642,7 +642,7 @@ export default class ContentActionDropdown extends Component<
</>
)}
{this.props.myUserInfo &&
(amCommunityCreator(
(amTopModExcludeMe(
creator.id,
moderators,
this.props.myUserInfo,
Expand Down
108 changes: 41 additions & 67 deletions src/shared/components/common/icon.tsx
Original file line number Diff line number Diff line change
@@ -1,85 +1,59 @@
import { getStaticDir } from "@utils/env";
import classNames from "classnames";
import { Component } from "inferno";
import { I18NextService } from "../../services";

interface IconProps {
type IconProps = {
icon: string;
classes?: string;
inline?: boolean;
small?: boolean;
}
};

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

render() {
let iconAltText: string | undefined;
if (
this.props.icon === "plus-square" ||
this.props.icon === "minus-square"
) {
iconAltText = `${I18NextService.i18n.t("show_content")}`;
}

return (
<svg
className={classNames("icon", this.props.classes, {
"icon-inline": this.props.inline,
small: this.props.small,
})}
{...(iconAltText
? { role: "img", "aria-describedby": `${this.props.icon}-alt` }
: {})}
>
{iconAltText && (
<title id={`${this.props.icon}-alt`}>{iconAltText}</title>
)}
<use
xlinkHref={`${getStaticDir()}/assets/symbols.svg#icon-${
this.props.icon
}`}
></use>
</svg>
);
}
return (
<svg
className={classNames("icon", classes, {
"icon-inline": inline,
small: small,
})}
{...(iconAltText
? { role: "img", "aria-describedby": `${icon}-alt` }
: {})}
>
{iconAltText && <title id={`${icon}-alt`}>{iconAltText}</title>}
<use
xlinkHref={`${getStaticDir()}/assets/symbols.svg#icon-${icon}`}
></use>
</svg>
);
}

interface SpinnerProps {
type SpinnerProps = {
large?: boolean;
className?: string;
};

export function Spinner({ large, className }: SpinnerProps) {
return (
<Icon
icon="spinner"
classes={classNames("spin", className, {
"spinner-large": large,
})}
/>
);
}

export class Spinner extends Component<SpinnerProps, any> {
constructor(props: any, context: any) {
super(props, context);
}

render() {
return (
<Icon
icon="spinner"
classes={classNames("spin", this.props.className, {
"spinner-large": this.props.large,
})}
/>
);
}
}

export class PurgeWarning extends Component<any, any> {
constructor(props: any, context: any) {
super(props, context);
}

render() {
return (
<div className="purge-warning mt-2 alert alert-danger" role="alert">
<Icon icon="alert-triangle" classes="icon-inline me-2" />
{I18NextService.i18n.t("purge_warning")}
</div>
);
}
export function PurgeWarning() {
return (
<div className="purge-warning mt-2 alert alert-danger" role="alert">
<Icon icon="alert-triangle" classes="icon-inline me-2" />
{I18NextService.i18n.t("purge_warning")}
</div>
);
}
2 changes: 1 addition & 1 deletion src/shared/components/common/image-upload-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type BaseProps = {
imageSrc?: string;
rounded?: boolean;
disabled: boolean;
onImageChange: (imageSrc?: string) => void;
onImageChange(imageSrc?: string): void;
noConfirmation?: boolean;
};

Expand Down
25 changes: 24 additions & 1 deletion src/shared/components/common/modal/mod-action-form-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ interface ModActionFormModalPropsPurgePerson {
creator: Person;
}

interface ModActionFormModalPropsPurgeCommunity {
modActionType: "purge-community";
onSubmit(reason: string): void;
community: Community;
}

interface ModActionFormModalPropsRemove {
modActionType: "remove-post" | "remove-comment";
modActionType: "remove-post" | "remove-comment" | "remove-community";
onSubmit(reason: string): void;
isRemoved: boolean;
}
Expand All @@ -69,6 +75,7 @@ type ModActionFormModalProps = (
| ModActionFormModalPropsCommunityBan
| ModActionFormModalPropsRest
| ModActionFormModalPropsPurgePerson
| ModActionFormModalPropsPurgeCommunity
| ModActionFormModalPropsRemove
| ModActionFormModalPropsLock
) & { onCancel(): void; show: boolean; children?: InfernoNode };
Expand Down Expand Up @@ -360,6 +367,12 @@ export default class ModActionFormModal extends Component<
});
}

case "purge-community": {
return I18NextService.i18n.t("purge_community_with_name", {
community: getApubName(this.props.community),
});
}

case "remove-post": {
return I18NextService.i18n.t(
this.props.isRemoved ? "restore_post" : "remove_post",
Expand All @@ -372,6 +385,12 @@ export default class ModActionFormModal extends Component<
);
}

case "remove-community": {
return I18NextService.i18n.t(
this.props.isRemoved ? "restore_community" : "remove_community",
);
}

case "report-post": {
return I18NextService.i18n.t("report_post");
}
Expand Down Expand Up @@ -405,11 +424,13 @@ export default class ModActionFormModal extends Component<

case "purge-post":
case "purge-comment":
case "purge-community":
case "purge-person": {
return I18NextService.i18n.t("purge");
}

case "remove-post":
case "remove-community":
case "remove-comment": {
return I18NextService.i18n.t(
this.props.isRemoved ? "restore" : "remove",
Expand Down Expand Up @@ -450,12 +471,14 @@ export default class ModActionFormModal extends Component<

case "purge-post":
case "purge-comment":
case "purge-community":
case "purge-person": {
translation = "purging";
break;
}

case "remove-post":
case "remove-community":
case "remove-comment": {
translation = this.props.isRemoved ? "restoring" : "removing";
break;
Expand Down
Loading