This repository was archived by the owner on Feb 15, 2024. It is now read-only.
forked from parse-community/parse-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointerKeyDialog.react.js
More file actions
73 lines (70 loc) · 2.47 KB
/
PointerKeyDialog.react.js
File metadata and controls
73 lines (70 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Copyright (c) 2016-present, Parse, LLC
* All rights reserved.
*
* This source code is licensed under the license found in the LICENSE file in
* the root directory of this source tree.
*/
import Button from 'components/Button/Button.react';
import Dropdown from 'components/Dropdown/Dropdown.react';
import Field from 'components/Field/Field.react';
import modalStyles from 'components/Modal/Modal.scss';
import Label from 'components/Label/Label.react';
import Modal from 'components/Modal/Modal.react';
import Option from 'components/Dropdown/Option.react';
import React from 'react';
import * as ColumnPreferences from 'lib/ColumnPreferences';
export default class PointerKeyDialog extends React.Component {
constructor() {
super();
this.state = {
name: null
};
}
componentDidMount() {
const pointerKey = ColumnPreferences.getPointerDefaultKey(this.props.app.applicationId, this.props.className);
this.setState({ name: pointerKey });
}
render() {
let content = null;
let hasColumns = this.props.currentColumns.length > 0;
let currentColumns = [...this.props.currentColumns, 'objectId'];
if (hasColumns) {
content = (
<Field
label={
<Label
text='PointerKey' />
}
input={
<Dropdown
placeHolder='Select a column'
value={this.state.name}
onChange={(name) => this.setState({ name: name })}>
{currentColumns.map((t) => <Option key={t} value={t}>{t}</Option>)}
</Dropdown>
} />
)
}
return (
<Modal
type={Modal.Types.INFO}
title={'Change pointer key'}
subtitle={hasColumns ? `The selected column will be used to represent a pointer for class "${this.props.className}"` : `There are no columns that can be set to represent a pointer for class "${this.props.className}"`}
confirmText='Set pointer key'
cancelText='Cancel'
onCancel={this.props.onCancel}
disabled={!this.state.name}
onConfirm={() => {
this.props.onConfirm(this.state.name);
}}
customFooter={hasColumns ? null :
<div className={modalStyles.footer}>
<Button value='Okay, go back.' onClick={this.props.onCancel} />
</div>
}>
{content}
</Modal>
);
}
}