From 89b9f73b32cb4fc15e28cbd0d0b4f7f2a6a103b8 Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Sat, 10 Jul 2021 01:19:31 +0800 Subject: [PATCH] Restrict app edit page values. --- web/src/ApplicationEditPage.js | 29 ++++++++------- web/src/ProviderTable.js | 64 ++++++++++++++++++++++------------ web/src/SignupTable.js | 8 +++++ 3 files changed, 67 insertions(+), 34 deletions(-) diff --git a/web/src/ApplicationEditPage.js b/web/src/ApplicationEditPage.js index c1955a96..e86d27ac 100644 --- a/web/src/ApplicationEditPage.js +++ b/web/src/ApplicationEditPage.js @@ -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)}} /> @@ -301,18 +302,22 @@ class ApplicationEditPage extends React.Component { this.renderPreview() } - - - {Setting.getLabel(i18next.t("application:Signup items"), i18next.t("application:Signup items - Tooltip"))} : - - - { this.updateApplicationField('signupItems', value)}} - /> - - + { + !this.state.application.enableSignUp ? null : ( + + + {Setting.getLabel(i18next.t("application:Signup items"), i18next.t("application:Signup items - Tooltip"))} : + + + { this.updateApplicationField('signupItems', value)}} + /> + + + ) + } {Setting.getLabel(i18next.t("general:Preview"), i18next.t("general:Preview - Tooltip"))} : diff --git a/web/src/ProviderTable.js b/web/src/ProviderTable.js index 808a6c9a..c38cb7c9 100644 --- a/web/src/ProviderTable.js +++ b/web/src/ProviderTable.js @@ -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 ( { 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 ( { 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 ( { 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 ( { 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 ( - - ) - } - }, + // { + // title: i18next.t("provider:alertType"), + // dataIndex: 'alertType', + // key: 'alertType', + // width: '120px', + // render: (text, record, index) => { + // return ( + // + // ) + // } + // }, { 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 ( ( diff --git a/web/src/SignupTable.js b/web/src/SignupTable.js index c59d8a0d..eaede9da 100644 --- a/web/src/SignupTable.js +++ b/web/src/SignupTable.js @@ -99,6 +99,10 @@ class SignupTable extends React.Component { key: 'visible', width: '120px', render: (text, record, index) => { + if (record.name === "ID") { + return null; + } + return ( { 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; }