Skip to content

Commit 0757704

Browse files
committed
prevent users from editing views and doc props
1 parent b7cd3bb commit 0757704

File tree

7 files changed

+187
-158
lines changed

7 files changed

+187
-158
lines changed

src/cloud/components/Views/Calendar/CalendarNoDateContext.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ const CalendarNoDateContext = ({
8484
content: (
8585
<Flexbox
8686
draggable={true}
87-
className={calendarDroppableClassName}
87+
className={
88+
currentUserIsCoreMember
89+
? calendarDroppableClassName
90+
: undefined
91+
}
8892
data={JSON.stringify({ title, extendedProps: { doc } })}
8993
>
9094
{currentUserIsCoreMember && (

src/cloud/components/Views/Calendar/CalendarView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ const CalendarView = ({
228228
teamId={team.id}
229229
watchedProp={watchedProp}
230230
updateWatchedProp={actionsRef.current.updateWatchedProp}
231+
currentUserIsCoreMember={currentUserIsCoreMember}
231232
/>,
232233
{
233234
width: 250,

src/cloud/components/Views/Calendar/CalendarWatchedPropContext.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { filterIter } from '../../../lib/utils/iterator'
2626
interface CalendarWatchedPropContextProps {
2727
view: SerializedView
2828
teamId: string
29+
currentUserIsCoreMember?: boolean
2930
watchedProp: {
3031
type: PropType
3132
name: string
@@ -45,6 +46,7 @@ interface PropertySuggestions {
4546
const CalendarWatchedPropContext = ({
4647
view,
4748
watchedProp,
49+
currentUserIsCoreMember,
4850
teamId,
4951
updateWatchedProp,
5052
}: CalendarWatchedPropContextProps) => {
@@ -160,7 +162,8 @@ const CalendarWatchedPropContext = ({
160162
</Flexbox>
161163
),
162164
iconPath: getIconPathOfPropType(propSuggestion.type),
163-
disabled: sending != null || isSelected,
165+
disabled:
166+
!currentUserIsCoreMember || sending != null || isSelected,
164167
spinning: sending === propSuggestion.name,
165168
id: id,
166169
onClick: () => setNewWatchedProp(propSuggestion),
@@ -195,7 +198,8 @@ const CalendarWatchedPropContext = ({
195198
</Flexbox>
196199
),
197200
iconPath: getIconPathOfPropType(propSuggestion.type),
198-
disabled: sending != null || isSelected,
201+
disabled:
202+
!currentUserIsCoreMember || sending != null || isSelected,
199203
spinning: sending === propSuggestion.name,
200204
id: id,
201205
onClick: () => setNewWatchedProp(propSuggestion),

src/cloud/components/Views/Kanban/index.tsx

Lines changed: 64 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -122,74 +122,76 @@ const KanbanView = ({
122122
name={status?.name || 'No Status'}
123123
backgroundColor={status?.backgroundColor}
124124
/>
125-
<div className={'kanban__item--action-buttons'}>
126-
{currentWorkspaceId != null && (
125+
{currentUserIsCoreMember && (
126+
<div className={'kanban__item--action-buttons'}>
127+
{currentWorkspaceId != null && (
128+
<Button
129+
className={'kanban__item--action-button'}
130+
variant={'icon'}
131+
iconPath={mdiPlus}
132+
onClick={() => {
133+
openNewDocForm(
134+
{
135+
team,
136+
workspaceId: currentWorkspaceId,
137+
parentFolderId: currentFolderId,
138+
props:
139+
statusProp != null
140+
? {
141+
[prop]: {
142+
type: 'status',
143+
data: statusProp.id,
144+
},
145+
}
146+
: undefined,
147+
},
148+
{
149+
precedingRows: [],
150+
skipRedirect: true,
151+
}
152+
)
153+
}}
154+
/>
155+
)}
127156
<Button
128157
className={'kanban__item--action-button'}
129-
variant={'icon'}
130-
iconPath={mdiPlus}
131-
onClick={() => {
132-
openNewDocForm(
158+
onClick={(event) => {
159+
openContextModal(
160+
event,
161+
<ListSettings
162+
list={list}
163+
remove={(list) => {
164+
removeListRef.current(list)
165+
closeLastModal()
166+
}}
167+
move={(list, move) => {
168+
onListMoveRef.current(list, move)
169+
closeLastModal()
170+
}}
171+
>
172+
{status != null && (
173+
<>
174+
<StatusEditor
175+
type='status'
176+
label={status}
177+
onSave={(status) => editStatus(status)}
178+
/>
179+
<hr />
180+
</>
181+
)}
182+
</ListSettings>,
133183
{
134-
team,
135-
workspaceId: currentWorkspaceId,
136-
parentFolderId: currentFolderId,
137-
props:
138-
statusProp != null
139-
? {
140-
[prop]: {
141-
type: 'status',
142-
data: statusProp.id,
143-
},
144-
}
145-
: undefined,
146-
},
147-
{
148-
precedingRows: [],
149-
skipRedirect: true,
184+
width: 250,
185+
removePadding: true,
186+
keepAll: true,
150187
}
151188
)
152189
}}
190+
iconPath={mdiDotsHorizontal}
191+
variant='icon'
153192
/>
154-
)}
155-
<Button
156-
className={'kanban__item--action-button'}
157-
onClick={(event) => {
158-
openContextModal(
159-
event,
160-
<ListSettings
161-
list={list}
162-
remove={(list) => {
163-
removeListRef.current(list)
164-
closeLastModal()
165-
}}
166-
move={(list, move) => {
167-
onListMoveRef.current(list, move)
168-
closeLastModal()
169-
}}
170-
>
171-
{status != null && (
172-
<>
173-
<StatusEditor
174-
type='status'
175-
label={status}
176-
onSave={(status) => editStatus(status)}
177-
/>
178-
<hr />
179-
</>
180-
)}
181-
</ListSettings>,
182-
{
183-
width: 250,
184-
removePadding: true,
185-
keepAll: true,
186-
}
187-
)
188-
}}
189-
iconPath={mdiDotsHorizontal}
190-
variant='icon'
191-
/>
192-
</div>
193+
</div>
194+
)}
193195
</Flexbox>
194196
)
195197
},
@@ -203,6 +205,7 @@ const KanbanView = ({
203205
prop,
204206
closeLastModal,
205207
openNewDocForm,
208+
currentUserIsCoreMember,
206209
]
207210
)
208211

src/cloud/components/Views/Table/TableView.tsx

Lines changed: 71 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -198,24 +198,28 @@ const TableView = ({
198198
id: 'doc-title',
199199
children: <Flexbox style={{ height: '100%' }}>Title</Flexbox>,
200200
width: view.data.titleColumnWidth ?? 300,
201-
onWidthChange: (newWidth) => {
202-
actionsRef.current.updateTitleColumnWidth(newWidth)
203-
},
204-
onClick: (ev: any) =>
205-
openContextModal(
206-
ev,
207-
<TitleColumnSettingsContext
208-
updateTableSort={actionsRef.current.updateTableSort}
209-
close={closeLastModal}
210-
/>,
211-
{
212-
width: 250,
213-
hideBackground: true,
214-
removePadding: true,
215-
alignment: 'bottom-left',
216-
keepAll: true,
217-
}
218-
),
201+
onWidthChange: !currentUserIsCoreMember
202+
? undefined
203+
: (newWidth) => {
204+
actionsRef.current.updateTitleColumnWidth(newWidth)
205+
},
206+
onClick: !currentUserIsCoreMember
207+
? undefined
208+
: (ev: any) =>
209+
openContextModal(
210+
ev,
211+
<TitleColumnSettingsContext
212+
updateTableSort={actionsRef.current.updateTableSort}
213+
close={closeLastModal}
214+
/>,
215+
{
216+
width: 250,
217+
hideBackground: true,
218+
removePadding: true,
219+
alignment: 'bottom-left',
220+
keepAll: true,
221+
}
222+
),
219223
},
220224
...orderedColumns.map((col) => {
221225
const icon = getIconPathOfPropType(col.id.split(':').pop() as any)
@@ -230,29 +234,33 @@ const TableView = ({
230234
</Flexbox>
231235
),
232236
width: col.width ?? 200,
233-
onWidthChange: (newWidth: number) => {
234-
actionsRef.current.updateColumnWidth(col, newWidth)
235-
},
236-
onClick: (ev: any) =>
237-
openContextModal(
238-
ev,
239-
<ColumnSettingsContext
240-
column={col}
241-
updateTableSort={actionsRef.current.updateTableSort}
242-
removeColumn={actionsRef.current.removeColumn}
243-
moveColumn={(type) =>
244-
actionsRef.current.moveColumn(col, type)
245-
}
246-
close={closeLastModal}
247-
/>,
248-
{
249-
width: 250,
250-
hideBackground: true,
251-
removePadding: true,
252-
alignment: 'bottom-left',
253-
keepAll: true,
254-
}
255-
),
237+
onWidthChange: !currentUserIsCoreMember
238+
? undefined
239+
: (newWidth: number) => {
240+
actionsRef.current.updateColumnWidth(col, newWidth)
241+
},
242+
onClick: !currentUserIsCoreMember
243+
? undefined
244+
: (ev: any) =>
245+
openContextModal(
246+
ev,
247+
<ColumnSettingsContext
248+
column={col}
249+
updateTableSort={actionsRef.current.updateTableSort}
250+
removeColumn={actionsRef.current.removeColumn}
251+
moveColumn={(type) =>
252+
actionsRef.current.moveColumn(col, type)
253+
}
254+
close={closeLastModal}
255+
/>,
256+
{
257+
width: 250,
258+
hideBackground: true,
259+
removePadding: true,
260+
alignment: 'bottom-left',
261+
keepAll: true,
262+
}
263+
),
256264
}
257265
}),
258266
]}
@@ -342,24 +350,28 @@ const TableView = ({
342350
],
343351
}
344352
})}
345-
onAddColButtonClick={(ev) =>
346-
openContextModal(
347-
ev,
348-
<TableAddPropertyContext
349-
teamId={team.id}
350-
view={view}
351-
columns={columns}
352-
addColumn={actionsRef.current.addColumn}
353-
close={closeLastModal}
354-
/>,
355-
{
356-
width: 250,
357-
hideBackground: true,
358-
removePadding: true,
359-
alignment: 'bottom-left',
360-
keepAll: true,
361-
}
362-
)
353+
disabledAddColumn={!currentUserIsCoreMember}
354+
onAddColButtonClick={
355+
!currentUserIsCoreMember
356+
? undefined
357+
: (ev) =>
358+
openContextModal(
359+
ev,
360+
<TableAddPropertyContext
361+
teamId={team.id}
362+
view={view}
363+
columns={columns}
364+
addColumn={actionsRef.current.addColumn}
365+
close={closeLastModal}
366+
/>,
367+
{
368+
width: 250,
369+
hideBackground: true,
370+
removePadding: true,
371+
alignment: 'bottom-left',
372+
keepAll: true,
373+
}
374+
)
363375
}
364376
disabledAddRow={true}
365377
/>

0 commit comments

Comments
 (0)