Skip to content
Merged
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
26 changes: 26 additions & 0 deletions src/dashboard/Data/Views/ViewValueDialog.react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Field from 'components/Field/Field.react';
import Label from 'components/Label/Label.react';
import Modal from 'components/Modal/Modal.react';
import React from 'react';
import TextInput from 'components/TextInput/TextInput.react';

export default function ViewValueDialog({ value, onClose }) {
let stringValue;
if (typeof value === 'object' && value !== null) {
stringValue = JSON.stringify(value, null, 2);
} else {
stringValue = String(value);
}
return (
<Modal
type={Modal.Types.INFO}
icon="visibility"
title="Value"
confirmText="Close"
showCancel={false}
onConfirm={onClose}
>
<Field label={<Label text="Value" />} input={<TextInput value={stringValue} multiline monospace disabled />} />
</Modal>
);
}
35 changes: 31 additions & 4 deletions src/dashboard/Data/Views/Views.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import DragHandle from 'components/DragHandle/DragHandle.react';
import CreateViewDialog from './CreateViewDialog.react';
import EditViewDialog from './EditViewDialog.react';
import DeleteViewDialog from './DeleteViewDialog.react';
import ViewValueDialog from './ViewValueDialog.react';
import BrowserMenu from 'components/BrowserMenu/BrowserMenu.react';
import MenuItem from 'components/BrowserMenu/MenuItem.react';
import Separator from 'components/BrowserMenu/Separator.react';
Expand Down Expand Up @@ -48,6 +49,7 @@ class Views extends TableView {
lastError: null,
lastNote: null,
loading: false,
viewValue: null,
};
this.headersRef = React.createRef();
this.noteTimeout = null;
Expand Down Expand Up @@ -149,7 +151,11 @@ class Views extends TableView {
if (val.__type === 'Date') {
type = 'Date';
} else if (val.__type === 'Pointer') {
type = 'Pointer';
if (val.className && val.objectId) {
type = 'Pointer';
} else {
type = 'Object';
}
} else if (val.__type === 'File') {
type = 'File';
} else if (val.__type === 'GeoPoint') {
Expand Down Expand Up @@ -264,7 +270,11 @@ class Views extends TableView {
if (value.__type === 'Date') {
type = 'Date';
} else if (value.__type === 'Pointer') {
type = 'Pointer';
if (value.className && value.objectId) {
type = 'Pointer';
} else {
type = 'Object';
}
} else if (value.__type === 'File') {
type = 'File';
} else if (value.__type === 'GeoPoint') {
Expand All @@ -290,8 +300,14 @@ class Views extends TableView {
} else {
content = String(value);
}
const isViewable = ['String', 'Number', 'Object'].includes(type);
const cellProps = {};
if (isViewable) {
cellProps.onClick = () => this.handleValueClick(value);
cellProps.style = { cursor: 'pointer' };
}
return (
<td key={name} className={styles.cell}>
<td key={name} className={styles.cell} {...cellProps}>
{content}
</td>
);
Expand Down Expand Up @@ -435,7 +451,14 @@ class Views extends TableView {

renderExtras() {
let extras = null;
if (this.state.showCreate) {
if (this.state.viewValue !== null) {
extras = (
<ViewValueDialog
value={this.state.viewValue}
onClose={() => this.setState({ viewValue: null })}
/>
);
} else if (this.state.showCreate) {
let classNames = [];
if (this.props.schema?.data) {
const classes = this.props.schema.data.get('classes');
Expand Down Expand Up @@ -534,6 +557,10 @@ class Views extends TableView {
this.props.navigate(path);
}

handleValueClick(value) {
this.setState({ viewValue: value });
}

showNote(message, isError) {
if (!message) {
return;
Expand Down
Loading