Restrict app edit page values.

This commit is contained in:
Yang Luo
2021-07-10 01:19:31 +08:00
parent 59ac7d6317
commit 89b9f73b32
3 changed files with 67 additions and 34 deletions

View File

@ -289,6 +289,7 @@ class ApplicationEditPage extends React.Component {
title={i18next.t("general:Providers")}
table={this.state.application.providers}
providers={this.state.providers}
application={this.state.application}
onUpdateTable={(value) => { this.updateApplicationField('providers', value)}}
/>
</Col>
@ -301,18 +302,22 @@ class ApplicationEditPage extends React.Component {
this.renderPreview()
}
</Row>
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}>
{Setting.getLabel(i18next.t("application:Signup items"), i18next.t("application:Signup items - Tooltip"))} :
</Col>
<Col span={22} >
<SignupTable
title={i18next.t("application:Signup items")}
table={this.state.application.signupItems}
onUpdateTable={(value) => { this.updateApplicationField('signupItems', value)}}
/>
</Col>
</Row>
{
!this.state.application.enableSignUp ? null : (
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}>
{Setting.getLabel(i18next.t("application:Signup items"), i18next.t("application:Signup items - Tooltip"))} :
</Col>
<Col span={22} >
<SignupTable
title={i18next.t("application:Signup items")}
table={this.state.application.signupItems}
onUpdateTable={(value) => { this.updateApplicationField('signupItems', value)}}
/>
</Col>
</Row>
)
}
<Row style={{marginTop: '20px'}} >
<Col style={{marginTop: '5px'}} span={2}>
{Setting.getLabel(i18next.t("general:Preview"), i18next.t("general:Preview - Tooltip"))} :

View File

@ -62,7 +62,7 @@ class ProviderTable extends React.Component {
}
renderTable(table) {
const columns = [
let columns = [
{
title: i18next.t("provider:Name"),
dataIndex: 'name',
@ -89,6 +89,10 @@ class ProviderTable extends React.Component {
key: 'canSignUp',
width: '120px',
render: (text, record, index) => {
if (record.provider.category !== "OAuth") {
return null;
}
return (
<Switch checked={text} onChange={checked => {
this.updateField(table, index, 'canSignUp', checked);
@ -102,6 +106,10 @@ class ProviderTable extends React.Component {
key: 'canSignIn',
width: '120px',
render: (text, record, index) => {
if (record.provider.category !== "OAuth") {
return null;
}
return (
<Switch checked={text} onChange={checked => {
this.updateField(table, index, 'canSignIn', checked);
@ -115,6 +123,10 @@ class ProviderTable extends React.Component {
key: 'canUnlink',
width: '120px',
render: (text, record, index) => {
if (record.provider.category !== "OAuth") {
return null;
}
return (
<Switch checked={text} onChange={checked => {
this.updateField(table, index, 'canUnlink', checked);
@ -128,6 +140,10 @@ class ProviderTable extends React.Component {
key: 'prompted',
width: '120px',
render: (text, record, index) => {
if (record.provider.category !== "OAuth") {
return null;
}
return (
<Switch checked={text} onChange={checked => {
this.updateField(table, index, 'prompted', checked);
@ -135,27 +151,27 @@ class ProviderTable extends React.Component {
)
}
},
{
title: i18next.t("provider:alertType"),
dataIndex: 'alertType',
key: 'alertType',
width: '120px',
render: (text, record, index) => {
return (
<Select virtual={false} style={{width: '100%'}} value={text} onChange={(value => {
this.updateField(table, index, 'alertType', value);
})}>
{
[
{id: 'None', name: 'None'},
{id: 'Once', name: 'Once'},
{id: 'Always', name: 'Always'},
].map((item, index) => <Option key={index} value={item.id}>{item.name}</Option>)
}
</Select>
)
}
},
// {
// title: i18next.t("provider:alertType"),
// dataIndex: 'alertType',
// key: 'alertType',
// width: '120px',
// render: (text, record, index) => {
// return (
// <Select virtual={false} style={{width: '100%'}} value={text} onChange={(value => {
// this.updateField(table, index, 'alertType', value);
// })}>
// {
// [
// {id: 'None', name: 'None'},
// {id: 'Once', name: 'Once'},
// {id: 'Always', name: 'Always'},
// ].map((item, index) => <Option key={index} value={item.id}>{item.name}</Option>)
// }
// </Select>
// )
// }
// },
{
title: i18next.t("general:Action"),
key: 'action',
@ -178,6 +194,10 @@ class ProviderTable extends React.Component {
},
];
if (!this.props.application.enableSignUp || this.props.application.enablePassword) {
columns = columns.filter(column => column.key !== "canSignUp");
}
return (
<Table rowKey="index" columns={columns} dataSource={table} size="middle" bordered pagination={false}
title={() => (

View File

@ -99,6 +99,10 @@ class SignupTable extends React.Component {
key: 'visible',
width: '120px',
render: (text, record, index) => {
if (record.name === "ID") {
return null;
}
return (
<Switch checked={text} onChange={checked => {
this.updateField(table, index, 'visible', checked);
@ -134,6 +138,10 @@ class SignupTable extends React.Component {
key: 'prompted',
width: '120px',
render: (text, record, index) => {
if (record.name === "ID") {
return null;
}
if (record.visible) {
return null;
}