Skip to content

feat: Add new options deleteOptions, exportOptions to manage delete and export permissions #2850

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

Closed
Closed
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
13 changes: 12 additions & 1 deletion Parse-Dashboard/parse-dashboard-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@
"appName": "",
"iconName": "",
"primaryBackgroundColor": "",
"secondaryBackgroundColor": ""
"secondaryBackgroundColor": "",
"deleteOptions": {
"class": true,
"columns": true,
"selectedRows": true,
"allData": true
},
"exportOptions": {
"schema": true,
"selectedRows": true,
"allData": true
}
Comment on lines +11 to +21
Copy link
Member

Choose a reason for hiding this comment

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

The names should be less ambiguous and follow the syntax of existing options:

Suggested change
"deleteOptions": {
"class": true,
"columns": true,
"selectedRows": true,
"allData": true
},
"exportOptions": {
"schema": true,
"selectedRows": true,
"allData": true
}
"deletePreference": {
"enableDeleteClass": true,
"enableDeleteColumns": true,
"enableDeleteSelectedRows": true,
"enableDeleteAllRows": true,
},
"exportPreference": {
"enableExportSchema": true,
"enableExportSelectedRows": true,
"enableExportAllRows": true,
}

}
],
"iconsFolder": "icons"
Expand Down
44 changes: 31 additions & 13 deletions src/dashboard/Data/Browser/BrowserToolbar.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ const BrowserToolbar = ({
onCancelPendingEditRows,
order,

enableDeleteClass,
enableDeleteColumns,
enableDeleteSelectedRows,
enableDeleteAllRows,
enableExportSchema,
enableExportSelectedRows,
enableExportClass,
enableSecurityDialog,

Expand All @@ -84,6 +89,7 @@ const BrowserToolbar = ({
appName,
}) => {
const selectionLength = Object.keys(selection).length;
const hasSomeExportEnabled = enableExportSchema || enableExportSelectedRows || enableExportClass;
const isPendingEditCloneRows = editCloneRows && editCloneRows.length > 0;
const details = [];
if (count !== undefined) {
Expand Down Expand Up @@ -166,14 +172,18 @@ const BrowserToolbar = ({
text={`Clone ${selectionLength <= 1 ? 'this row' : 'these rows'}`}
onClick={onCloneSelectedRows}
/>
{enableDeleteSelectedRows ? <Separator /> : <noscript />}
{enableDeleteSelectedRows ? (
<MenuItem
disabled={selectionLength === 0}
text={selectionLength === 1 && !selection['*'] ? 'Delete this row' : 'Delete these rows'}
onClick={() => onDeleteRows(selection)}
/>
) : (
<noscript />
)}
<Separator />
<MenuItem
disabled={selectionLength === 0}
text={selectionLength === 1 && !selection['*'] ? 'Delete this row' : 'Delete these rows'}
onClick={() => onDeleteRows(selection)}
/>
<Separator />
{enableColumnManipulation ? (
{enableColumnManipulation && enableDeleteColumns ? (
<MenuItem text="Delete a column" onClick={onRemoveColumn} />
) : (
<noscript />
Expand All @@ -183,7 +193,7 @@ const BrowserToolbar = ({
) : (
<noscript />
)}
{enableClassManipulation ? (
{enableClassManipulation && enableDeleteClass ? (
<MenuItem text="Delete this class" onClick={onDropClass} />
) : (
<noscript />
Expand Down Expand Up @@ -346,21 +356,29 @@ const BrowserToolbar = ({
)}
</BrowserMenu>
)}
{onAddRow && <div className={styles.toolbarSeparator} />}
{onAddRow && (
{onAddRow && hasSomeExportEnabled && <div className={styles.toolbarSeparator} />}
{onAddRow && hasSomeExportEnabled && (
<BrowserMenu
title="Export"
icon="down-solid"
disabled={isUnique || isPendingEditCloneRows}
setCurrent={setCurrent}
>
<MenuItem
disabled={!selectionLength}
disabled={!selectionLength || !enableExportSelectedRows}
text={`Export ${selectionLength} selected ${selectionLength <= 1 ? 'row' : 'rows'}`}
onClick={() => onExportSelectedRows(selection)}
/>
<MenuItem text={'Export all rows'} onClick={() => onExportSelectedRows({ '*': true })} />
<MenuItem text={'Export schema'} onClick={() => onExportSchema()} />
<MenuItem
disabled={!enableExportClass}
text={'Export all rows'}
onClick={() => onExportSelectedRows({ '*': true })}
/>
<MenuItem
disabled={!enableExportSchema}
text={'Export schema'}
onClick={() => onExportSchema()}
/>
</BrowserMenu>
)}
{onAddRow && <div className={styles.toolbarSeparator} />}
Expand Down
17 changes: 14 additions & 3 deletions src/dashboard/Data/Browser/DataBrowser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ export default class DataBrowser extends React.Component {
app,
...other
} = this.props;
const { preventSchemaEdits, applicationId } = app;
const { preventSchemaEdits, applicationId, deleteOptions, exportOptions } = app;
return (
<div>
<div>
Expand Down Expand Up @@ -690,10 +690,21 @@ export default class DataBrowser extends React.Component {
className={className}
classNameForEditors={className}
setCurrent={this.setCurrent}
enableDeleteClass={deleteOptions.class && !preventSchemaEdits}
enableDeleteColumns={deleteOptions.columns && !preventSchemaEdits}
enableDeleteSelectedRows={deleteOptions.selectedRows && !preventSchemaEdits}
enableDeleteAllRows={
app.serverInfo.features.schemas.clearAllDataFromClass && !preventSchemaEdits
deleteOptions.allData &&
app.serverInfo.features.schemas.clearAllDataFromClass &&
!preventSchemaEdits
}
enableExportSchema={exportOptions.schema && !preventSchemaEdits}
enableExportSelectedRows={exportOptions.selectedRows && !preventSchemaEdits}
enableExportClass={
exportOptions.allData &&
app.serverInfo.features.schemas.exportClass &&
!preventSchemaEdits
}
enableExportClass={app.serverInfo.features.schemas.exportClass && !preventSchemaEdits}
enableSecurityDialog={
app.serverInfo.features.schemas.editClassLevelPermissions &&
!disableSecurityDialog &&
Expand Down
13 changes: 13 additions & 0 deletions src/lib/ParseApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export default class ParseApp {
secondaryBackgroundColor,
supportedPushLocales,
preventSchemaEdits,
deleteOptions,
exportOptions,
graphQLServerURL,
columnPreference,
scripts,
Expand Down Expand Up @@ -74,6 +76,17 @@ export default class ParseApp {
this.secondaryBackgroundColor = secondaryBackgroundColor;
this.supportedPushLocales = supportedPushLocales ? supportedPushLocales : [];
this.preventSchemaEdits = preventSchemaEdits || false;
this.deleteOptions = deleteOptions || {
class: true,
columns: true,
selectedRows: true,
allData: true,
};
this.exportOptions = exportOptions || {
schema: true,
selectedRows: true,
allData: true,
};
this.graphQLServerURL = graphQLServerURL;
this.columnPreference = columnPreference;
this.scripts = scripts;
Expand Down
Loading