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

fix close dialog box editor notification #1228 #1249

Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,21 @@ function hasEditingAccess(user, project) {
}

const EditorNotification = ({ project }) => {

const [isClosed, setIsClosed] = React.useState(false)
const user = useUserDataContext().userData;

if (!hasEditingAccess(user, project)) {
if (!hasEditingAccess(user, project) || isClosed) {
return (<></>);
}

function closeEditor() {
setIsClosed(true)
}

return (
<div style={{paddingTop: "1rem"}}>
<ThemeProvider theme={theme}>
<Alert signal="notify">
<Alert handleClose={closeEditor} signal="notify">
<h3>It looks like you have editing permissions for this page!</h3>
<p>
Head to the dashboard in Strapi to make changes to the content of this page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React, { useRef } from "react";
// import Link from "next/link";
// import Image from "next/image";
import { DateTime } from "luxon";
import { withTheme } from "styled-components";
import { useRouter } from "next/router";
import Button from "../../../common/Button";
Expand Down Expand Up @@ -30,6 +31,15 @@ function isOnTeam(id, team) {
return leadersIds.includes(id) || membersIds.includes(id);
}

function hasPassedOneMonth(dateString) {
const currentDate = DateTime.local();
const completionDate = DateTime.fromISO(dateString);

const oneMonthLater = completionDate.plus({ months: 1 });

return currentDate >= oneMonthLater;
}

const Project = ({ project, theme }) => {
const router = useRouter();
const roleRef = useRef();
Expand All @@ -46,6 +56,7 @@ const Project = ({ project, theme }) => {

const checkIfIsOnTeam = isOnTeam(userData.userData.id, project.team);
const isLogged = userData.userData.id === 0 ? false : true
const milestoneIsOutdated = hasPassedOneMonth(project.board.ProjectMilestone[0].task[0].completionDate)

return (
<Wrapper>
Expand All @@ -69,7 +80,7 @@ const Project = ({ project, theme }) => {
images={project?.Images}
/>
{/*}<Role ref={roleRef} data={project?.opportunities} projectSlug={project.slug} />{*/}
{isLogged && checkIfIsOnTeam ? <Milestones data={project?.board?.ProjectMilestone} /> : null}
{isLogged && checkIfIsOnTeam && !milestoneIsOutdated ? <Milestones data={project?.board?.ProjectMilestone} /> : null}
{<Sessions calendarId={project.calendarId} />}
<Team data={project.team} />
<JoinSupport
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,4 @@ export const MemberImage = styled.img`
width: 8.75rem;
height: 8.75rem;
flex-shrink: 0;
&:hover {
opacity: 0.5;
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ const Team = ({ data }) => (
key={leader.id}
>
<span>
<a href="#">
<MemberImage
src={leader.profile?.profilePictureUrl}
// src="https://pbs.twimg.com/profile_images/1157313327867092993/a09TxL_1_400x400.jpg"
alt="Image of Team member"
></MemberImage>
</a>
<MemberImage
src={leader.profile?.profilePictureUrl}
// src="https://pbs.twimg.com/profile_images/1157313327867092993/a09TxL_1_400x400.jpg"
alt="Image of Team member"
></MemberImage>
</span>
<div
style={{
Expand Down Expand Up @@ -63,13 +61,11 @@ const Team = ({ data }) => (
key={member.id}
>
<span>
<a href="#">
<MemberImage
src={member.profile?.profilePictureUrl}
// src="https://pbs.twimg.com/profile_images/1157313327867092993/a09TxL_1_400x400.jpg"
alt="Image of Team member"
></MemberImage>
</a>
<MemberImage
src={member.profile?.profilePictureUrl}
// src="https://pbs.twimg.com/profile_images/1157313327867092993/a09TxL_1_400x400.jpg"
alt="Image of Team member"
></MemberImage>
</span>
<div
style={{
Expand Down
5 changes: 4 additions & 1 deletion packages/UI/src/components/molecules/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { AlertProps } from '.';

const Alert: React.FC<React.PropsWithChildren<AlertProps>> = ({
signal = 'notify',
handleClose,
children,
...rest
}) => {
Expand All @@ -21,7 +22,9 @@ const Alert: React.FC<React.PropsWithChildren<AlertProps>> = ({
<></>
)}
<Typography css={{ flex: 1 }}>{children}</Typography>
<Icons.Close />
<button>
<Icons.Close onClick={handleClose} />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@helioLJ this is a great addition! thanks for adding handleClose prop.
can you please make the onClick on the button rather than the Icon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I it will be more concise this way, ty

</button>
</Container>
);
};
Expand Down
6 changes: 6 additions & 0 deletions packages/UI/src/components/molecules/Alert/StyledAlert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,10 @@ export const Container = styled.div<Styles>`
`;
}}
}

> button {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's recommended to write it this way: & > button {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

border: none;
background: none;
cursor: pointer;
}
`;
1 change: 1 addition & 0 deletions packages/UI/src/components/molecules/Alert/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface AlertProps {
signal?: 'notify' | 'success' | 'error';
handleClose?: () => void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the type here is not so accurate handleClose?: (e?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void; is more explicit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback, Mohammed! I'll make these changes soon as possible

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@helioLJ I made a PR to fix those and also add animation to the alert #1253

}
export { default } from './Alert';
Loading