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

Renderer plateless to task fixes #221

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use access to determine todo and preview note readonly
  • Loading branch information
xypnox committed Oct 25, 2022
commit 45b2a21a5cc8cbceff62b5c1768f1b70fb7616b5
5 changes: 5 additions & 0 deletions apps/webapp/src/Components/PreviewNoteModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Editor from '../Editor/Editor'
import { TagsRelatedTiny } from '../Editor/TagsRelated'
import NamespaceTag from '../NamespaceTag'
import { PreviewNoteContainer } from './styled'
import { isReadonly, usePermissions } from '../../Hooks/usePermissions'

const PreviewNoteModal = () => {
const isOpen = useModalStore((store) => store.open === ModalsType.previewNote)
Expand Down Expand Up @@ -55,6 +56,9 @@ const PreviewNoteModal = () => {
}
}, [modalData?.noteId])

const { accessWhenShared } = usePermissions()
const readOnly = useMemo(() => isReadonly(accessWhenShared(modalData?.noteId)), [modalData?.noteId])

if (!isOpen) return <></>

const onRequestClose = () => {
Expand Down Expand Up @@ -121,6 +125,7 @@ const PreviewNoteModal = () => {
content={content}
onChange={onChange}
options={{ focusOptions: false }}
readOnly={readOnly}
autoFocus
nodeUID={modalData?.noteId}
/>
Expand Down
8 changes: 5 additions & 3 deletions apps/webapp/src/Views/Tasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { useLayoutStore } from '../Stores/useLayoutStore'
import useModalStore, { ModalsType } from '../Stores/useModalStore'
import { useTodoStore } from '../Stores/useTodoStore'
import SearchFilters from './SearchFilters'
import { isReadonly, usePermissions } from '../Hooks/usePermissions'

interface RenderTaskProps {
id: string
Expand All @@ -44,8 +45,9 @@ const RenderTask = React.memo<RenderTaskProps>(
const { changeStatus, changePriority, getPureContent } = useTodoKanban()

const sidebar = useLayoutStore((store) => store.sidebar)
const todos = useTodoStore((store) => store.todos)
const pC = useMemo(() => getPureContent(todo), [id, todos])
const pC = useMemo(() => getPureContent(todo), [id, todo])
const { accessWhenShared } = usePermissions()
const readOnly = useMemo(() => isReadonly(accessWhenShared(todo?.nodeid)), [todo])

const controls = useMemo(
() => ({
Expand Down Expand Up @@ -80,7 +82,7 @@ const RenderTask = React.memo<RenderTaskProps>(
showDelete={false}
key={`TODO_PREVIEW_${todo.nodeid}_${todo.id}`}
todoid={todo.id}
readOnly
readOnly={readOnly}
controls={controls}
parentNodeId={todo.nodeid}
>
Expand Down
4 changes: 2 additions & 2 deletions libs/shared/src/Style/Todo.style.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled, { css } from 'styled-components'
import { transparentize } from 'polished'
import { transparentize, mix } from 'polished'
import { TodoStatus } from '@mexit/core'
import { CompleteWave, WaterWave } from './Welcome'

Expand Down Expand Up @@ -34,7 +34,7 @@ export const TodoActionButton = styled.button`
align-items: center;
border-radius: 1rem;
border: none;
background-color: transparent;
background-color: ${({ theme }) => mix(0.8, theme.colors.gray[8], theme.colors.secondary)};
color: ${({ theme }) => theme.colors.secondary};
:hover {
background-color: ${({ theme }) => theme.colors.background.card};
Expand Down