Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 19 additions & 0 deletions client/containers/App/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@
outline: none;
flex-grow: 1;
}
/* Let the pub page fill the viewport, so its grey bottom section reaches the footer instead
of leaving a white gap when the pub is shorter than the screen. Every link in the chain
has to be a column flex container for the next one to grow into it:

#app > #main-content > #pub-container > .pub-document-component > .pub-bottom-component

.pub-document-component (pubDocument.scss) declares `flex-grow: 1` and is a column flex container;
.pub-grid absorbs leftover space while .pub-bottom-component (pubBottom.scss) stays at content height.
These rules connect that chain by making #main-content and #pub-container flex columns. Skipped on the dashboard, which has its own
padded #main-content layout and no growing root. */
&:not(.dashboard) #main-content {
display: flex;
flex-direction: column;
#pub-container {
display: flex;
flex-direction: column;
flex-grow: 1;
}
}
.duqduq-warning {
position: fixed;
right: 10px;
Expand Down
3 changes: 2 additions & 1 deletion client/containers/Pub/PubDocument/PubBottom/pubBottom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

.pub-bottom-component {
background: #f6f4f4;
flex-grow: 1;
/* Stay at content height — .pub-grid takes the leftover viewport space instead. */
flex-grow: 0;
overflow: hidden;
padding: 2em 0em;
margin-top: 2em;
Expand Down
11 changes: 10 additions & 1 deletion client/containers/Pub/PubDocument/PubDocument.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const PubDocument = () => {
const { isViewingHistory } = historyData;
const { communityData, scopeData, featureFlags } = usePageContext();
const pubEdgeDisplay = useFacetsQuery((F) => F.PubEdgeDisplay);
const { canEdit, canEditDraft } = scopeData.activePermissions;
const { canEdit, canEditDraft, canCreateDiscussions } = scopeData.activePermissions;
const { isReviewingPub } = pubData;
const mainContentRef = useRef<null | HTMLDivElement>(null);
const sideContentRef = useRef(null);
Expand All @@ -51,6 +51,14 @@ const PubDocument = () => {

const showPubFileImport = (canEdit || canEditDraft) && !isReadOnly;

/* Only show the Comments section if there's something to read, or this reader can actually */
/* post. Otherwise it's an empty box with sort/filter controls that do nothing — which is what */
/* a logged-out visitor saw on a Community that limits commenting to members and contributors, */
/* or that disabled it outright. Discussions arrive already sanitized (spam, banned authors */
/* and draft-vs-release visibility are filtered server-side), so an empty list here means */
/* there is nothing this reader is allowed to see. */
const showDiscussions = canCreateDiscussions || !!pubData.discussions?.length;

if (hidePubBody) {
return null;
}
Expand Down Expand Up @@ -125,6 +133,7 @@ const PubDocument = () => {
</div>
<PubBottom
pubData={pubData}
showDiscussions={showDiscussions}
updateLocalData={updateLocalData}
sideContentRef={sideContentRef}
mainContentRef={mainContentRef}
Expand Down
7 changes: 7 additions & 0 deletions client/containers/Pub/PubDocument/pubDocument.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
flex-direction: column;
flex-grow: 1;

/* Absorb any leftover viewport height into the body rather than the bottom section, so a pub
shorter than the screen keeps a compact License / Comments strip sitting on the footer
instead of stretching it into a tall grey band. */
.pub-grid {
flex-grow: 1;
}

.top-pub-edges {
margin-top: 30px;
margin-bottom: 30px;
Expand Down
4 changes: 3 additions & 1 deletion server/publicPermissions/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
Table,
} from 'sequelize-typescript';

import { discussionCreationAccessValues } from 'types/community';

import { Pub } from '../models';

@Table
Expand All @@ -33,7 +35,7 @@ export class PublicPermissions extends Model<
declare canCreateDiscussions: boolean | null;

@Default('public')
@Column(DataType.ENUM('public', 'contributors', 'members', 'disabled'))
@Column(DataType.ENUM(...discussionCreationAccessValues))
declare discussionCreationAccess: CreationOptional<DiscussionCreationAccess>;

@Column(DataType.BOOLEAN)
Expand Down
7 changes: 6 additions & 1 deletion types/community.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ export type CommunityHeaderLink = {

export type Community = SerializedModel<CommunityModel>;

export type DiscussionCreationAccess = 'public' | 'contributors-members' | 'disabled';
export const discussionCreationAccessValues = [
'public',
'contributors-members',
'disabled',
] as const;
export type DiscussionCreationAccess = (typeof discussionCreationAccessValues)[number];
4 changes: 3 additions & 1 deletion utils/api/contracts/publicPermissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import type { AppRouter } from '@ts-rest/core';
import { extendZodWithOpenApi } from '@anatine/zod-openapi';
import { z } from 'zod';

import { discussionCreationAccessValues } from 'types/community';

extendZodWithOpenApi(z);

export const publicPermissionsRouter = {
Expand All @@ -11,7 +13,7 @@ export const publicPermissionsRouter = {
method: 'PUT',
summary: 'Update who is able to create new discussions',
body: z.object({
discussionCreationAccess: z.enum(['public', 'contributors', 'members', 'disabled']),
discussionCreationAccess: z.enum(discussionCreationAccessValues),
}),
responses: {
200: z.object({ success: z.boolean() }),
Expand Down
4 changes: 3 additions & 1 deletion utils/api/schemas/community.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type * as types from 'types';

import { z } from 'zod';

import { discussionCreationAccessValues } from 'types/community';

import { baseSchema } from '../utils/baseSchema';
import { analyticsSettingsSchema } from './analyticsSettings';

Expand Down Expand Up @@ -152,5 +154,5 @@ export const communityUpdateSchema = communitySchema
})
.extend({
communityId: communitySchema.shape.id,
discussionCreationAccess: z.enum(['public', 'contributors-members', 'disabled']).optional(),
discussionCreationAccess: z.enum(discussionCreationAccessValues).optional(),
});
Loading