Skip to content

Commit f4b409c

Browse files
committed
Fixed a few bugs
1 parent b7c3f19 commit f4b409c

File tree

8 files changed

+65
-18
lines changed

8 files changed

+65
-18
lines changed

services/madoc-ts/src/frontend/shared/components/TermsPopup.tsx

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import React from 'react';
22
import { useTranslation } from 'react-i18next';
33
import { useSite, useUser } from '../hooks/use-site';
44
import { HrefLink } from '../utility/href-link';
5+
import { useLocation } from 'react-router-dom';
56

67
export function TermsPopup() {
78
const user = useUser();
89
const site = useSite();
910
const { t } = useTranslation();
11+
const location = useLocation();
12+
const [closed, setClosed] = React.useState(false);
1013

1114
if (!user || !site.latestTerms) {
1215
return null;
@@ -34,6 +37,14 @@ export function TermsPopup() {
3437
return null;
3538
}
3639

40+
if (location.pathname === '/terms') {
41+
return null;
42+
}
43+
44+
if (closed) {
45+
return null;
46+
}
47+
3748
return (
3849
<div
3950
style={{
@@ -44,17 +55,43 @@ export function TermsPopup() {
4455
background: 'rgba(0,0,0,.8)',
4556
color: '#fff',
4657
padding: '1em',
47-
paddingTop: '0.4em',
58+
paddingTop: '0.8em',
4859
fontSize: '0.8em',
60+
paddingRight: '2.5em',
61+
borderRadius: '3px',
62+
zIndex: 99999999,
4963
}}
5064
>
65+
<div>
66+
<button
67+
style={{
68+
position: 'absolute',
69+
top: '0.5em',
70+
right: '0.5em',
71+
background: 'none',
72+
border: 'none',
73+
color: '#fff',
74+
fontSize: '1.2em',
75+
cursor: 'pointer',
76+
}}
77+
onClick={() => setClosed(true)}
78+
>
79+
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
80+
<path
81+
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
82+
fill="currentColor"
83+
/>
84+
<path d="M0 0h24v24H0z" fill="none" />
85+
</svg>
86+
</button>
87+
</div>
5188
<div>
5289
{newTerms ? (
5390
<p>{t('You have not yet accepted the terms of use for this site.')}</p>
5491
) : (
5592
<p>{t('The terms of use for this site have changed since you last accepted them.')}</p>
5693
)}
57-
<HrefLink style={{ color: '#fff' }} href={`/terms`}>
94+
<HrefLink style={{ color: '#fff', marginTop: '1em', display: 'block' }} href={`/terms`}>
5895
{termsMessage}
5996
</HrefLink>
6097
</div>

services/madoc-ts/src/frontend/shared/navigation/Button.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ export const Button = styled.button<{
4444
background: linear-gradient(180deg, #fafbfc 0%, #eff3f6 90%);
4545
border: 1px solid rgba(27, 31, 35, 0.15);
4646
color: #333;
47+
48+
&[type="submit"] {
49+
background: linear-gradient(180deg, #fafbfc 0%, #eff3f6 90%);
50+
}
4751
4852
4953
${props =>
@@ -97,6 +101,10 @@ export const Button = styled.button<{
97101
background: #4265e9;
98102
color: #fff;
99103
border: 1px solid #4265e9;
104+
105+
&[type='submit'] {
106+
background: #4265e9;
107+
}
100108
&:active {
101109
box-shadow: inset 0 2px 8px 0 rgba(39, 75, 155, 0.8);
102110
}

services/madoc-ts/src/frontend/site/blocks/ProjectStatistics.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const ProjectStatistics: React.FC = () => {
4646

4747
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
4848
// @ts-ignore
49-
const total = Object.values(project?.statistics).reduce((a, b) => Math.max(a, 0) + Math.max(b, 0));
49+
const total = Object.values(project?.statistics || {}).reduce((a, b) => Math.max(a, 0) + Math.max(b, 0), 0);
5050

5151
if (hideStatistics || !project) {
5252
return null;

services/madoc-ts/src/frontend/site/pages/user/login-page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ export const LoginPage: React.FC = () => {
4949
<div dangerouslySetInnerHTML={{ __html: system.loginFooter }} style={{ marginBottom: '1em' }} />
5050
) : null}
5151
<LoginActions>
52-
<FlexSpacer>
52+
<div style={{ flex: 1 }}>
5353
<HrefLink href={`/forgot-password`}>{t('Forgot password?')}</HrefLink>
54-
</FlexSpacer>
54+
</div>
5555
<Button $primary>{t('Login')}</Button>
5656
</LoginActions>
5757
</InputContainer>

services/madoc-ts/src/frontend/site/pages/user/register.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const Register: React.FC = () => {
6969
}
7070

7171
const acceptTerms = site.latestTerms ? (
72-
<div>
72+
<div style={{ marginBottom: '1em', fontSize: '0.875em', color: '#444' }}>
7373
<p>
7474
{t('By registering you agree to the ')}
7575
<a target="_blank" href={`/s/${site.slug}/terms`} rel="noreferrer">
@@ -139,9 +139,9 @@ export const Register: React.FC = () => {
139139
) : null}
140140
<InputContainer>
141141
<LoginActions>
142-
<FlexSpacer>
142+
<div style={{ flex: 1 }}>
143143
{t('Already have an account?')} <HrefLink href="/login">{t('Login')}</HrefLink>
144-
</FlexSpacer>
144+
</div>
145145
<Button type="submit" $primary>
146146
{t('Register')}
147147
</Button>

services/madoc-ts/src/frontend/site/pages/view-project.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { useProject } from '../hooks/use-project';
2828
export const ViewProject: React.FC = () => {
2929
const { t } = useTranslation();
3030
const user = useUser();
31+
const isAdmin = (user?.scope || []).includes('site.admin');
3132
const { data: project } = useProject();
3233
const available = (
3334
<AvailableBlocks>
@@ -56,24 +57,24 @@ export const ViewProject: React.FC = () => {
5657
{available}
5758
</Slot>
5859

59-
<SlotTabs initial={project?.isProjectMember ? 'project-my-work' : 'project-content'}>
60+
<SlotTabs initial={project?.isProjectMember ? 'project-my-work' : undefined}>
6061
<Slot name="project-navigation" label={t('Overview')} />
61-
<Slot name="project-my-work" label={t('My work')} hidden={!user}>
62-
<ProjectContinueSubmissions />
63-
<ProjectMyWork />
64-
<ProjectPersonalNotes />
65-
</Slot>
6662
<Slot name="project-content" label={t('Manifests and Collections')}>
6763
<ProjectCollections />
6864
<ProjectManifestList />
6965
{available}
7066
</Slot>
67+
<Slot name="project-my-work" label={t('My work')} hidden={!user}>
68+
<ProjectContinueSubmissions />
69+
<ProjectMyWork />
70+
<ProjectPersonalNotes />
71+
</Slot>
7172
<Slot name="project-contributors" label={t('Contributors')} />
72-
<Slot name="project-updates" label={t('Updates')}>
73+
<Slot name="project-updates" label={t('Updates')} hidden={!project?.latestUpdate && !isAdmin}>
7374
<MostRecentProjectUpdate />
7475
<PostNewProjectUpdate />
7576
</Slot>
76-
<Slot name="project-feedback" label={t('Feedback')} hidden={project?.isProjectMember !== true}>
77+
<Slot name="project-feedback" label={t('Feedback')} hidden={project?.isProjectMember !== true && !isAdmin}>
7778
<ProjectFeedbackListing />
7879
<ProjectFeedback />
7980
</Slot>

services/madoc-ts/src/frontend/tailwind/components/slot-tabs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function SlotTabs(props: SlotTabProps) {
2222

2323
const slot = slots[name];
2424

25-
const empty = slot?.blocks.length === 0 && !(child as any).props.children;
25+
const empty = slot ? slot?.blocks.length === 0 : !(child as any).props.children;
2626

2727
const customLabel = slot?.props?.surface?.label;
2828

services/madoc-ts/src/repository/site-user-repository.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,8 @@ export class SiteUserRepository extends BaseRepository {
12561256
}
12571257

12581258
async invalidateSiteCache(siteId: number) {
1259-
cache.del(`public-site-id:${siteId}`);
1259+
const slug = await this.connection.oneFirst(sql<{ slug: string }>`select slug from site where id = ${siteId}`);
1260+
cache.del(`public-site-id:${slug}`);
12601261
}
12611262

12621263
async updateInvitation(invitationId: string, siteId: number, req: UpdateInvitation) {

0 commit comments

Comments
 (0)