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

Open pointer in new browser tab with [Cmd] click #1757

Merged
merged 6 commits into from
Aug 23, 2021
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
33 changes: 26 additions & 7 deletions src/components/BrowserCell/BrowserCell.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ export default class BrowserCell extends Component {
}
});

if ( this.props.type === 'Pointer' ) {
onEditSelectedRow && contextMenuOptions.push({
text: 'Open pointer in new tab',
callback: () => {
let { value, onPointerCmdClick } = this.props;
onPointerCmdClick(value);
}
});
}

return contextMenuOptions;
}

Expand Down Expand Up @@ -214,7 +224,7 @@ export default class BrowserCell extends Component {
//#endregion

render() {
let { type, value, hidden, width, current, onSelect, onEditChange, setCopyableValue, setRelation, onPointerClick, row, col, field, onEditSelectedRow, readonly, isRequired, markRequiredFieldRow } = this.props;
let { type, value, hidden, width, current, onSelect, onEditChange, setCopyableValue, setRelation, onPointerClick, onPointerCmdClick, row, col, field, onEditSelectedRow, readonly, isRequired, markRequiredFieldRow } = this.props;
let content = value;
let isNewRow = row < 0;
this.copyableValue = content;
Expand Down Expand Up @@ -343,9 +353,13 @@ export default class BrowserCell extends Component {
ref={this.cellRef}
className={classes.join(' ')}
style={{ width }}
onClick={() => {
onSelect({ row, col });
setCopyableValue(hidden ? undefined : this.copyableValue);
onClick={(e) => {
if ( e.metaKey === true && type === 'Pointer') {
onPointerCmdClick(value);
} else {
onSelect({ row, col });
setCopyableValue(hidden ? undefined : this.copyableValue);
}
}}
onDoubleClick={() => {
if (field === 'objectId' && onEditSelectedRow) {
Expand All @@ -366,9 +380,14 @@ export default class BrowserCell extends Component {
ref={this.cellRef}
className={classes.join(' ')}
style={{ width }}
onClick={() => {
onSelect({ row, col });
setCopyableValue(hidden ? undefined : this.copyableValue);
onClick={(e) => {
if ( e.metaKey === true && type === 'Pointer' ) {
onPointerCmdClick(value);
}
else {
onSelect({ row, col });
setCopyableValue(hidden ? undefined : this.copyableValue);
}
}}
onDoubleClick={() => {
// Since objectId can't be edited, double click event opens edit row dialog
Expand Down
5 changes: 3 additions & 2 deletions src/components/BrowserRow/BrowserRow.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class BrowserRow extends Component {
}

render() {
const { className, columns, currentCol, isUnique, obj, onPointerClick, order, readOnlyFields, row, rowWidth, selection, selectRow, setCopyableValue, setCurrent, setEditing, setRelation, onEditSelectedRow, setContextMenu, onFilterChange, markRequiredFieldRow } = this.props;
const { className, columns, currentCol, isUnique, obj, onPointerClick, onPointerCmdClick, order, readOnlyFields, row, rowWidth, selection, selectRow, setCopyableValue, setCurrent, setEditing, setRelation, onEditSelectedRow, setContextMenu, onFilterChange, markRequiredFieldRow } = this.props;
let attributes = obj.attributes;
let requiredCols = [];
Object.entries(columns).reduce((acc, cur) => {
Expand Down Expand Up @@ -89,6 +89,7 @@ export default class BrowserRow extends Component {
onSelect={setCurrent}
onEditChange={setEditing}
onPointerClick={onPointerClick}
onPointerCmdClick={onPointerCmdClick}
onFilterChange={onFilterChange}
setRelation={setRelation}
objectId={obj.id}
Expand All @@ -104,4 +105,4 @@ export default class BrowserRow extends Component {
</div>
);
}
}
}
2 changes: 1 addition & 1 deletion src/components/Pill/Pill.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let Pill = ({ value, onClick, fileDownloadLink, followClick = false }) => (
>
<span className={!followClick && fileDownloadLink ? styles.content : ''}>{value}</span>
{followClick && (
<a onClick={onClick}>
<a onClick={e => !e.metaKey && onClick()}>
<Icon name="right-outline" width={20} height={20} fill="#1669a1" />
</a>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Toolbar/Toolbar.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const goBack = () => history.goBack();

let Toolbar = (props) => {
let backButton;
if (props.relation || (props.filters && props.filters.size)) {
if ((props.relation || (props.filters && props.filters.size)) && history.action !== 'POP') {
backButton = (
<a
className={styles.iconButton}
Expand Down
11 changes: 11 additions & 0 deletions src/dashboard/Data/Browser/Browser.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class Browser extends DashboardView {
this.updateRow = this.updateRow.bind(this);
this.updateOrdering = this.updateOrdering.bind(this);
this.handlePointerClick = this.handlePointerClick.bind(this);
this.handlePointerCmdClick = this.handlePointerCmdClick.bind(this);
this.handleCLPChange = this.handleCLPChange.bind(this);
this.setRelation = this.setRelation.bind(this);
this.showAddColumn = this.showAddColumn.bind(this);
Expand Down Expand Up @@ -834,6 +835,15 @@ class Browser extends DashboardView {
history.push(this.context.generatePath(`browser/${className}?filters=${encodeURIComponent(filters)}`));
}

handlePointerCmdClick({ className, id, field = 'objectId' }) {
let filters = JSON.stringify([{
field,
constraint: 'eq',
compareTo: id
}]);
window.open(this.context.generatePath(`browser/${className}?filters=${encodeURIComponent(filters)}`),'_blank');
}

handleCLPChange(clp) {
let p = this.props.schema.dispatch(ActionTypes.SET_CLP, {
className: this.props.params.className,
Expand Down Expand Up @@ -1529,6 +1539,7 @@ class Browser extends DashboardView {
updateRow={this.updateRow}
updateOrdering={this.updateOrdering}
onPointerClick={this.handlePointerClick}
onPointerCmdClick={this.handlePointerCmdClick}
setRelation={this.setRelation}
onAddColumn={this.showAddColumn}
onAddRow={this.addRow}
Expand Down
5 changes: 4 additions & 1 deletion src/dashboard/Data/Browser/BrowserTable.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export default class BrowserTable extends React.Component {
isUnique={this.props.isUnique}
obj={cloneRow}
onPointerClick={this.props.onPointerClick}
onPointerCmdClick={this.props.onPointerCmdClick}
onFilterChange={this.props.onFilterChange}
order={this.props.order}
readOnlyFields={READ_ONLY}
Expand Down Expand Up @@ -189,6 +190,7 @@ export default class BrowserTable extends React.Component {
isUnique={this.props.isUnique}
obj={this.props.newObject}
onPointerClick={this.props.onPointerClick}
onPointerCmdClick={this.props.onPointerCmdClick}
onFilterChange={this.props.onFilterChange}
order={this.props.order}
readOnlyFields={READ_ONLY}
Expand Down Expand Up @@ -246,6 +248,7 @@ export default class BrowserTable extends React.Component {
isUnique={this.props.isUnique}
obj={obj}
onPointerClick={this.props.onPointerClick}
onPointerCmdClick={this.props.onPointerCmdClick}
onFilterChange={this.props.onFilterChange}
order={this.props.order}
readOnlyFields={READ_ONLY}
Expand Down Expand Up @@ -319,7 +322,7 @@ export default class BrowserTable extends React.Component {
if (this.props.current.row >= -1 && this.props.editCloneRows) {
//for data rows & new row when there are edit clone rows
wrapTop += (2 * ROW_HEIGHT) * (this.props.editCloneRows.length);
}
}
let wrapLeft = 30;
for (let i = 0; i < this.props.current.col; i++) {
const column = this.props.order[i];
Expand Down