2022-02-13 23:39:27 +08:00
// Copyright 2021 The Casdoor Authors. All Rights Reserved.
2021-02-13 13:30:51 +08:00
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
2021-02-13 12:15:19 +08:00
import React from "react" ;
2022-09-10 00:56:37 +08:00
import { Button , Card , Col , Input , Popover , Radio , Row , Select , Switch , Upload } from "antd" ;
2022-06-16 22:00:34 +08:00
import { CopyOutlined , LinkOutlined , UploadOutlined } from "@ant-design/icons" ;
2021-02-13 12:15:19 +08:00
import * as ApplicationBackend from "./backend/ApplicationBackend" ;
2022-02-08 20:59:20 +08:00
import * as CertBackend from "./backend/CertBackend" ;
2021-02-13 12:15:19 +08:00
import * as Setting from "./Setting" ;
import * as ProviderBackend from "./backend/ProviderBackend" ;
import * as OrganizationBackend from "./backend/OrganizationBackend" ;
2021-08-15 00:17:53 +08:00
import * as ResourceBackend from "./backend/ResourceBackend" ;
2021-06-14 13:13:39 +08:00
import SignupPage from "./auth/SignupPage" ;
2021-03-26 21:56:51 +08:00
import LoginPage from "./auth/LoginPage" ;
2021-02-19 23:23:59 +08:00
import i18next from "i18next" ;
2021-03-06 21:41:24 +08:00
import UrlTable from "./UrlTable" ;
2021-06-14 19:09:04 +08:00
import ProviderTable from "./ProviderTable" ;
2021-06-16 14:06:41 +08:00
import SignupTable from "./SignupTable" ;
2021-06-18 02:05:19 +08:00
import PromptPage from "./auth/PromptPage" ;
2022-06-16 22:00:34 +08:00
import copy from "copy-to-clipboard" ;
2021-10-26 13:11:21 +08:00
2022-07-10 15:45:55 +08:00
import { Controlled as CodeMirror } from "react-codemirror2" ;
2021-10-26 13:11:21 +08:00
import "codemirror/lib/codemirror.css" ;
2022-10-22 21:43:41 +08:00
2022-07-10 15:45:55 +08:00
require ( "codemirror/theme/material-darker.css" ) ;
2021-10-26 13:11:21 +08:00
require ( "codemirror/mode/htmlmixed/htmlmixed" ) ;
2022-06-16 23:59:18 +08:00
require ( "codemirror/mode/xml/xml" ) ;
2022-09-10 00:56:37 +08:00
require ( "codemirror/mode/css/css" ) ;
2021-10-26 13:11:21 +08:00
2022-07-10 15:45:55 +08:00
const { Option } = Select ;
2021-02-13 12:15:19 +08:00
2022-10-23 01:27:01 +08:00
const template = ` <style>
. login - panel {
padding : 40 px 70 px 0 70 px ;
2022-10-22 21:43:41 +08:00
border - radius : 10 px ;
background - color : # ffffff ;
2022-10-23 01:27:01 +08:00
box - shadow : 0 0 30 px 20 px rgba ( 0 , 0 , 0 , 0.20 ) ;
2022-10-22 21:43:41 +08:00
}
2022-10-23 01:27:01 +08:00
< / s t y l e > ` ;
const sideTemplate = ` <style>
2022-10-22 21:43:41 +08:00
. left - model {
text - align : center ;
padding : 30 px ;
background - color : # 8 ca0ed ;
position : absolute ;
transform : none ;
width : 100 % ;
height : 100 % ;
}
. side - logo {
display : flex ;
align - items : center ;
}
. side - logo span {
font - family : Montserrat , sans - serif ;
font - weight : 900 ;
font - size : 2.4 rem ;
line - height : 1.3 ;
margin - left : 16 px ;
color : # 404040 ;
}
. img {
max - width : none ;
margin : 41 px 0 13 px ;
}
< / s t y l e >
< div class = "left-model" >
< span class = "side-logo" > < img src = "https://cdn.casbin.org/img/casdoor-logo_1185x256.png" alt = "Casdoor" style = "width: 120px" >
< span > SSO < / s p a n >
< / s p a n >
< div class = "img" >
< img src = "https://cdn.casbin.org/img/casbin.svg" alt = "Casdoor" / >
< / d i v >
< / d i v >
` ;
2022-09-10 00:56:37 +08:00
2021-02-13 12:15:19 +08:00
class ApplicationEditPage extends React . Component {
constructor ( props ) {
super ( props ) ;
this . state = {
classes : props ,
2022-11-04 21:31:08 +08:00
owner : props . account . owner ,
2021-02-13 12:15:19 +08:00
applicationName : props . match . params . applicationName ,
application : null ,
organizations : [ ] ,
2022-02-08 20:59:20 +08:00
certs : [ ] ,
2021-02-13 12:15:19 +08:00
providers : [ ] ,
2021-08-10 10:43:33 +08:00
uploading : false ,
2022-02-25 18:16:02 +08:00
mode : props . location . mode !== undefined ? props . location . mode : "edit" ,
2022-05-11 20:23:36 +08:00
samlMetadata : null ,
2021-02-13 12:15:19 +08:00
} ;
}
2021-03-27 11:38:15 +08:00
UNSAFE _componentWillMount ( ) {
2021-02-13 12:15:19 +08:00
this . getApplication ( ) ;
this . getOrganizations ( ) ;
2022-02-08 20:59:20 +08:00
this . getCerts ( ) ;
2021-02-13 12:15:19 +08:00
this . getProviders ( ) ;
2022-05-11 20:23:36 +08:00
this . getSamlMetadata ( ) ;
2021-02-13 12:15:19 +08:00
}
getApplication ( ) {
ApplicationBackend . getApplication ( "admin" , this . state . applicationName )
. then ( ( application ) => {
2022-04-08 21:54:48 +08:00
if ( application . grantTypes === null || application . grantTypes === undefined || application . grantTypes . length === 0 ) {
2022-02-27 14:05:07 +08:00
application . grantTypes = [ "authorization_code" ] ;
}
2021-02-13 12:15:19 +08:00
this . setState ( {
application : application ,
} ) ;
} ) ;
}
getOrganizations ( ) {
OrganizationBackend . getOrganizations ( "admin" )
. then ( ( res ) => {
this . setState ( {
2021-03-28 00:48:34 +08:00
organizations : ( res . msg === undefined ) ? res : [ ] ,
2021-02-13 12:15:19 +08:00
} ) ;
} ) ;
}
2022-02-08 20:59:20 +08:00
getCerts ( ) {
CertBackend . getCerts ( "admin" )
. then ( ( res ) => {
this . setState ( {
certs : ( res . msg === undefined ) ? res : [ ] ,
} ) ;
} ) ;
}
2021-02-13 12:15:19 +08:00
getProviders ( ) {
2022-11-04 21:31:08 +08:00
if ( Setting . isAdminUser ( this . props . account ) ) {
ProviderBackend . getGlobalProviders ( )
. then ( ( res ) => {
this . setState ( {
providers : res ,
} ) ;
2021-02-13 12:15:19 +08:00
} ) ;
2022-11-04 21:31:08 +08:00
} else {
ProviderBackend . getProviders ( this . state . owner )
. then ( ( res ) => {
this . setState ( {
providers : res ,
} ) ;
} ) ;
}
2021-02-13 12:15:19 +08:00
}
2022-05-11 20:23:36 +08:00
getSamlMetadata ( ) {
ApplicationBackend . getSamlMetadata ( "admin" , this . state . applicationName )
. then ( ( res ) => {
this . setState ( {
samlMetadata : res ,
2022-07-10 15:45:55 +08:00
} ) ;
2022-05-11 20:23:36 +08:00
} ) ;
}
2021-02-13 12:15:19 +08:00
parseApplicationField ( key , value ) {
2022-09-10 00:56:37 +08:00
if ( [ "expireInHours" , "refreshExpireInHours" , "offset" ] . includes ( key ) ) {
2021-03-14 22:48:09 +08:00
value = Setting . myParseInt ( value ) ;
}
2021-02-13 12:15:19 +08:00
return value ;
}
updateApplicationField ( key , value ) {
value = this . parseApplicationField ( key , value ) ;
2022-08-08 23:35:24 +08:00
const application = this . state . application ;
2021-02-13 12:15:19 +08:00
application [ key ] = value ;
this . setState ( {
application : application ,
} ) ;
}
2021-08-10 10:43:33 +08:00
handleUpload ( info ) {
if ( info . file . type !== "text/html" ) {
2021-08-14 15:58:12 +08:00
Setting . showMessage ( "error" , i18next . t ( "application:Please select a HTML file" ) ) ;
return ;
2021-08-10 10:43:33 +08:00
}
2021-08-14 15:58:12 +08:00
this . setState ( { uploading : true } ) ;
const fullFilePath = ` termsOfUse/ ${ this . state . application . owner } / ${ this . state . application . name } .html ` ;
2021-09-06 00:08:16 +08:00
ResourceBackend . uploadResource ( this . props . account . owner , this . props . account . name , "termsOfUse" , "ApplicationEditPage" , fullFilePath , info . file )
2021-08-10 10:43:33 +08:00
. then ( res => {
if ( res . status === "ok" ) {
2021-08-14 15:58:12 +08:00
Setting . showMessage ( "success" , i18next . t ( "application:File uploaded successfully" ) ) ;
this . updateApplicationField ( "termsOfUse" , res . data ) ;
2021-08-10 10:43:33 +08:00
} else {
2021-08-14 15:58:12 +08:00
Setting . showMessage ( "error" , res . msg ) ;
2021-08-10 10:43:33 +08:00
}
} ) . finally ( ( ) => {
2021-08-14 15:58:12 +08:00
this . setState ( { uploading : false } ) ;
2022-07-10 15:45:55 +08:00
} ) ;
2021-08-10 10:43:33 +08:00
}
2021-02-13 12:15:19 +08:00
renderApplication ( ) {
return (
< Card size = "small" title = {
< div >
2022-02-25 18:16:02 +08:00
{ this . state . mode === "add" ? i18next . t ( "application:New Application" ) : i18next . t ( "application:Edit Application" ) } & nbsp ; & nbsp ; & nbsp ; & nbsp ;
2021-12-12 18:51:12 +08:00
< Button onClick = { ( ) => this . submitApplicationEdit ( false ) } > { i18next . t ( "general:Save" ) } < / B u t t o n >
2022-07-10 15:45:55 +08:00
< Button style = { { marginLeft : "20px" } } type = "primary" onClick = { ( ) => this . submitApplicationEdit ( true ) } > { i18next . t ( "general:Save & Exit" ) } < / B u t t o n >
{ this . state . mode === "add" ? < Button style = { { marginLeft : "20px" } } onClick = { ( ) => this . deleteApplication ( ) } > { i18next . t ( "general:Cancel" ) } < / B u t t o n > : n u l l }
2021-02-13 12:15:19 +08:00
< / d i v >
2022-08-06 23:43:09 +08:00
} style = { ( Setting . isMobile ( ) ) ? { margin : "5px" } : { } } type = "inner" >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "10px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-25 00:13:43 +08:00
{ Setting . getLabel ( i18next . t ( "general:Name" ) , i18next . t ( "general:Name - Tooltip" ) ) } :
2021-02-13 12:15:19 +08:00
< / C o l >
< Col span = { 22 } >
2021-12-23 00:40:07 +08:00
< Input value = { this . state . application . name } disabled = { this . state . application . name === "app-built-in" } onChange = { e => {
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "name" , e . target . value ) ;
2021-02-13 12:15:19 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "general:Display name" ) , i18next . t ( "general:Display name - Tooltip" ) ) } :
2021-02-13 12:15:19 +08:00
< / C o l >
< Col span = { 22 } >
< Input value = { this . state . application . displayName } onChange = { e => {
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "displayName" , e . target . value ) ;
2021-02-13 12:15:19 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2022-03-05 00:53:59 +08:00
{ Setting . getLabel ( i18next . t ( "general:Logo" ) , i18next . t ( "general:Logo - Tooltip" ) ) } :
2021-02-13 12:15:19 +08:00
< / C o l >
2022-08-06 23:43:09 +08:00
< Col span = { 22 } style = { ( Setting . isMobile ( ) ) ? { maxWidth : "100%" } : { } } >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 1 } >
2022-02-27 18:20:58 +08:00
{ Setting . getLabel ( i18next . t ( "general:URL" ) , i18next . t ( "general:URL - Tooltip" ) ) } :
2021-02-13 12:15:19 +08:00
< / C o l >
< Col span = { 23 } >
2022-07-10 15:45:55 +08:00
< Input prefix = { < LinkOutlined / > } value = { this . state . application . logo } onChange = { e => {
this . updateApplicationField ( "logo" , e . target . value ) ;
2021-02-13 12:15:19 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 1 } >
2021-02-19 23:23:59 +08:00
{ i18next . t ( "general:Preview" ) } :
2021-02-13 12:15:19 +08:00
< / C o l >
< Col span = { 23 } >
2021-03-27 11:38:15 +08:00
< a target = "_blank" rel = "noreferrer" href = { this . state . application . logo } >
2022-07-10 15:45:55 +08:00
< img src = { this . state . application . logo } alt = { this . state . application . logo } height = { 90 } style = { { marginBottom : "20px" } } / >
2021-02-13 12:15:19 +08:00
< / a >
< / C o l >
< / R o w >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "general:Home" ) , i18next . t ( "general:Home - Tooltip" ) ) } :
2021-03-06 21:50:48 +08:00
< / C o l >
< Col span = { 22 } >
2022-07-10 15:45:55 +08:00
< Input prefix = { < LinkOutlined / > } value = { this . state . application . homepageUrl } onChange = { e => {
this . updateApplicationField ( "homepageUrl" , e . target . value ) ;
2021-03-06 21:50:48 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "general:Description" ) , i18next . t ( "general:Description - Tooltip" ) ) } :
2021-03-06 21:50:48 +08:00
< / C o l >
< Col span = { 22 } >
< Input value = { this . state . application . description } onChange = { e => {
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "description" , e . target . value ) ;
2021-03-06 21:50:48 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "general:Organization" ) , i18next . t ( "general:Organization - Tooltip" ) ) } :
2021-02-13 12:15:19 +08:00
< / C o l >
< Col span = { 22 } >
2022-07-10 15:45:55 +08:00
< Select virtual = { false } style = { { width : "100%" } } value = { this . state . application . organization } onChange = { ( value => { this . updateApplicationField ( "organization" , value ) ; } ) } >
2021-02-13 12:15:19 +08:00
{
this . state . organizations . map ( ( organization , index ) => < Option key = { index } value = { organization . name } > { organization . name } < / O p t i o n > )
}
< / S e l e c t >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "provider:Client ID" ) , i18next . t ( "provider:Client ID - Tooltip" ) ) } :
2021-03-06 16:39:17 +08:00
< / C o l >
< Col span = { 22 } >
< Input value = { this . state . application . clientId } onChange = { e => {
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "clientId" , e . target . value ) ;
2021-03-06 16:39:17 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "provider:Client secret" ) , i18next . t ( "provider:Client secret - Tooltip" ) ) } :
2021-03-06 16:39:17 +08:00
< / C o l >
< Col span = { 22 } >
< Input value = { this . state . application . clientSecret } onChange = { e => {
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "clientSecret" , e . target . value ) ;
2021-03-06 16:39:17 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2022-02-08 20:59:20 +08:00
{ Setting . getLabel ( i18next . t ( "general:Cert" ) , i18next . t ( "general:Cert - Tooltip" ) ) } :
< / C o l >
< Col span = { 22 } >
2022-07-10 15:45:55 +08:00
< Select virtual = { false } style = { { width : "100%" } } value = { this . state . application . cert } onChange = { ( value => { this . updateApplicationField ( "cert" , value ) ; } ) } >
2022-02-08 20:59:20 +08:00
{
this . state . certs . map ( ( cert , index ) => < Option key = { index } value = { cert . name } > { cert . name } < / O p t i o n > )
}
< / S e l e c t >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "application:Redirect URLs" ) , i18next . t ( "application:Redirect URLs - Tooltip" ) ) } :
2021-03-06 21:41:24 +08:00
< / C o l >
< Col span = { 22 } >
< UrlTable
2021-06-14 17:18:40 +08:00
title = { i18next . t ( "application:Redirect URLs" ) }
2021-03-15 00:01:21 +08:00
table = { this . state . application . redirectUris }
2022-07-10 15:45:55 +08:00
onUpdateTable = { ( value ) => { this . updateApplicationField ( "redirectUris" , value ) ; } }
2021-03-06 21:41:24 +08:00
/ >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-12-19 01:08:02 +08:00
{ Setting . getLabel ( i18next . t ( "application:Token format" ) , i18next . t ( "application:Token format - Tooltip" ) ) } :
2021-12-18 16:16:34 +08:00
< / C o l >
< Col span = { 22 } >
2022-07-10 15:45:55 +08:00
< Select virtual = { false } style = { { width : "100%" } } value = { this . state . application . tokenFormat } onChange = { ( value => { this . updateApplicationField ( "tokenFormat" , value ) ; } ) } >
2021-12-18 16:16:34 +08:00
{
2022-07-10 15:45:55 +08:00
[ "JWT" , "JWT-Empty" ]
2021-12-18 16:16:34 +08:00
. map ( ( item , index ) => < Option key = { index } value = { item } > { item } < / O p t i o n > )
}
< / S e l e c t >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-12-19 01:08:02 +08:00
{ Setting . getLabel ( i18next . t ( "application:Token expire" ) , i18next . t ( "application:Token expire - Tooltip" ) ) } :
2021-03-14 22:48:09 +08:00
< / C o l >
< Col span = { 22 } >
2021-06-14 13:13:39 +08:00
< Input style = { { width : "150px" } } value = { this . state . application . expireInHours } suffix = "Hours" onChange = { e => {
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "expireInHours" , e . target . value ) ;
2021-03-14 22:48:09 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-12-19 01:08:02 +08:00
{ Setting . getLabel ( i18next . t ( "application:Refresh token expire" ) , i18next . t ( "application:Refresh token expire - Tooltip" ) ) } :
2021-12-18 18:49:38 +08:00
< / C o l >
< Col span = { 22 } >
< Input style = { { width : "150px" } } value = { this . state . application . refreshExpireInHours } suffix = "Hours" onChange = { e => {
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "refreshExpireInHours" , e . target . value ) ;
2021-12-18 18:49:38 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 19 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "application:Password ON" ) , i18next . t ( "application:Password ON - Tooltip" ) ) } :
2021-02-14 10:56:37 +08:00
< / C o l >
< Col span = { 1 } >
2021-02-14 13:43:55 +08:00
< Switch checked = { this . state . application . enablePassword } onChange = { checked => {
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "enablePassword" , checked ) ;
2021-02-14 13:43:55 +08:00
} } / >
2021-02-14 10:56:37 +08:00
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 19 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "application:Enable signup" ) , i18next . t ( "application:Enable signup - Tooltip" ) ) } :
2021-03-26 21:55:39 +08:00
< / C o l >
< Col span = { 1 } >
< Switch checked = { this . state . application . enableSignUp } onChange = { checked => {
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "enableSignUp" , checked ) ;
2021-03-26 21:55:39 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 19 : 2 } >
2021-12-28 17:13:45 +08:00
{ Setting . getLabel ( i18next . t ( "application:Signin session" ) , i18next . t ( "application:Enable signin session - Tooltip" ) ) } :
< / C o l >
< Col span = { 1 } >
< Switch checked = { this . state . application . enableSigninSession } onChange = { checked => {
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "enableSigninSession" , checked ) ;
2021-12-28 17:13:45 +08:00
} } / >
< / C o l >
< / R o w >
2022-09-27 20:06:46 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 19 : 2 } >
{ Setting . getLabel ( i18next . t ( "application:Auto signin" ) , i18next . t ( "application:Auto signin - Tooltip" ) ) } :
< / C o l >
< Col span = { 1 } >
< Switch checked = { this . state . application . enableAutoSignin } onChange = { checked => {
this . updateApplicationField ( "enableAutoSignin" , checked ) ;
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 19 : 2 } >
2021-12-19 00:34:37 +08:00
{ Setting . getLabel ( i18next . t ( "application:Enable code signin" ) , i18next . t ( "application:Enable code signin - Tooltip" ) ) } :
2021-11-28 21:10:21 +08:00
< / C o l >
< Col span = { 1 } >
< Switch checked = { this . state . application . enableCodeSignin } onChange = { checked => {
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "enableCodeSignin" , checked ) ;
2021-11-28 21:10:21 +08:00
} } / >
< / C o l >
2022-07-12 20:06:01 +08:00
< / R o w >
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 19 : 2 } >
{ Setting . getLabel ( i18next . t ( "application:Enable WebAuthn signin" ) , i18next . t ( "application:Enable WebAuthn signin - Tooltip" ) ) } :
< / C o l >
< Col span = { 1 } >
< Switch checked = { this . state . application . enableWebAuthn } onChange = { checked => {
this . updateApplicationField ( "enableWebAuthn" , checked ) ;
} } / >
< / C o l >
2021-11-28 21:10:21 +08:00
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "general:Signup URL" ) , i18next . t ( "general:Signup URL - Tooltip" ) ) } :
2021-05-03 00:48:02 +08:00
< / C o l >
< Col span = { 22 } >
2022-07-10 15:45:55 +08:00
< Input prefix = { < LinkOutlined / > } value = { this . state . application . signupUrl } onChange = { e => {
this . updateApplicationField ( "signupUrl" , e . target . value ) ;
2021-05-03 00:48:02 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "general:Signin URL" ) , i18next . t ( "general:Signin URL - Tooltip" ) ) } :
2021-06-14 22:55:08 +08:00
< / C o l >
< Col span = { 22 } >
2022-07-10 15:45:55 +08:00
< Input prefix = { < LinkOutlined / > } value = { this . state . application . signinUrl } onChange = { e => {
this . updateApplicationField ( "signinUrl" , e . target . value ) ;
2021-06-14 22:55:08 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "general:Forget URL" ) , i18next . t ( "general:Forget URL - Tooltip" ) ) } :
2021-05-03 00:48:02 +08:00
< / C o l >
< Col span = { 22 } >
2022-07-10 15:45:55 +08:00
< Input prefix = { < LinkOutlined / > } value = { this . state . application . forgetUrl } onChange = { e => {
this . updateApplicationField ( "forgetUrl" , e . target . value ) ;
2021-05-03 00:48:02 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "general:Affiliation URL" ) , i18next . t ( "general:Affiliation URL - Tooltip" ) ) } :
2021-05-24 21:27:00 +08:00
< / C o l >
< Col span = { 22 } >
2022-07-10 15:45:55 +08:00
< Input prefix = { < LinkOutlined / > } value = { this . state . application . affiliationUrl } onChange = { e => {
this . updateApplicationField ( "affiliationUrl" , e . target . value ) ;
2021-05-24 21:27:00 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-08-03 21:00:07 +08:00
{ Setting . getLabel ( i18next . t ( "provider:Terms of Use" ) , i18next . t ( "provider:Terms of Use - Tooltip" ) ) } :
< / C o l >
< Col span = { 22 } >
2021-08-10 10:43:33 +08:00
< Input value = { this . state . application . termsOfUse } style = { { marginBottom : "10px" } } onChange = { e => {
2021-10-26 13:11:21 +08:00
this . updateApplicationField ( "termsOfUse" , e . target . value ) ;
2022-07-10 15:45:55 +08:00
} } / >
2021-08-10 10:43:33 +08:00
< Upload maxCount = { 1 } accept = ".html" showUploadList = { false }
2022-07-10 15:45:55 +08:00
beforeUpload = { file => { return false ; } } onChange = { info => { this . handleUpload ( info ) ; } } >
2022-06-16 21:21:03 +08:00
< Button icon = { < UploadOutlined / > } loading = { this . state . uploading } > { i18next . t ( "general:Click to Upload" ) } < / B u t t o n >
2021-08-10 10:43:33 +08:00
< / U p l o a d >
2021-08-03 21:00:07 +08:00
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-10-26 13:11:21 +08:00
{ Setting . getLabel ( i18next . t ( "provider:Signup HTML" ) , i18next . t ( "provider:Signup HTML - Tooltip" ) ) } :
< / C o l >
< Col span = { 22 } >
< Popover placement = "right" content = {
< div style = { { width : "900px" , height : "300px" } } >
< CodeMirror
value = { this . state . application . signupHtml }
2022-07-10 15:45:55 +08:00
options = { { mode : "htmlmixed" , theme : "material-darker" } }
2021-10-26 13:11:21 +08:00
onBeforeChange = { ( editor , data , value ) => {
this . updateApplicationField ( "signupHtml" , value ) ;
} }
/ >
< / d i v >
} title = { i18next . t ( "provider:Signup HTML - Edit" ) } trigger = "click" >
< Input value = { this . state . application . signupHtml } style = { { marginBottom : "10px" } } onChange = { e => {
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "signupHtml" , e . target . value ) ;
} } / >
2021-10-26 13:11:21 +08:00
< / P o p o v e r >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-10-26 13:11:21 +08:00
{ Setting . getLabel ( i18next . t ( "provider:Signin HTML" ) , i18next . t ( "provider:Signin HTML - Tooltip" ) ) } :
< / C o l >
< Col span = { 22 } >
< Popover placement = "right" content = {
< div style = { { width : "900px" , height : "300px" } } >
< CodeMirror
value = { this . state . application . signinHtml }
2022-07-10 15:45:55 +08:00
options = { { mode : "htmlmixed" , theme : "material-darker" } }
2021-10-26 13:11:21 +08:00
onBeforeChange = { ( editor , data , value ) => {
this . updateApplicationField ( "signinHtml" , value ) ;
} }
/ >
< / d i v >
} title = { i18next . t ( "provider:Signin HTML - Edit" ) } trigger = "click" >
< Input value = { this . state . application . signinHtml } style = { { marginBottom : "10px" } } onChange = { e => {
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "signinHtml" , e . target . value ) ;
} } / >
2021-10-26 13:11:21 +08:00
< / P o p o v e r >
< / C o l >
2022-02-27 14:05:07 +08:00
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2022-02-27 18:20:58 +08:00
{ Setting . getLabel ( i18next . t ( "application:Grant types" ) , i18next . t ( "application:Grant types - Tooltip" ) ) } :
2022-02-27 14:05:07 +08:00
< / C o l >
< Col span = { 22 } >
2022-07-10 15:45:55 +08:00
< Select virtual = { false } mode = "tags" style = { { width : "100%" } }
value = { this . state . application . grantTypes }
onChange = { ( value => {
this . updateApplicationField ( "grantTypes" , value ) ;
} ) } >
{
[
{ id : "authorization_code" , name : "Authorization Code" } ,
{ id : "password" , name : "Password" } ,
{ id : "client_credentials" , name : "Client Credentials" } ,
{ id : "token" , name : "Token" } ,
{ id : "id_token" , name : "ID Token" } ,
{ id : "refresh_token" , name : "Refresh Token" } ,
] . map ( ( item , index ) => < Option key = { index } value = { item . id } > { item . name } < / O p t i o n > )
}
2022-02-27 14:05:07 +08:00
< / S e l e c t >
< / C o l >
2021-10-26 13:11:21 +08:00
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 19 : 2 } >
2022-06-28 22:05:02 +08:00
{ Setting . getLabel ( i18next . t ( "application:Enable SAML compress" ) , i18next . t ( "application:Enable SAML compress - Tooltip" ) ) } :
< / C o l >
< Col span = { 1 } >
< Switch checked = { this . state . application . enableSamlCompress } onChange = { checked => {
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "enableSamlCompress" , checked ) ;
2022-06-28 22:05:02 +08:00
} } / >
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2022-05-11 20:23:36 +08:00
{ Setting . getLabel ( i18next . t ( "application:SAML metadata" ) , i18next . t ( "application:SAML metadata - Tooltip" ) ) } :
< / C o l >
< Col span = { 22 } >
2022-06-16 23:59:18 +08:00
< CodeMirror
value = { this . state . samlMetadata }
2022-07-10 15:45:55 +08:00
options = { { mode : "xml" , theme : "default" } }
2022-06-16 23:59:18 +08:00
onBeforeChange = { ( editor , data , value ) => { } }
/ >
2022-07-10 15:45:55 +08:00
< br / >
2022-06-28 22:05:02 +08:00
< Button style = { { marginBottom : "10px" } } type = "primary" shape = "round" icon = { < CopyOutlined / > } onClick = { ( ) => {
copy ( ` ${ window . location . origin } /api/saml/metadata?application=admin/ ${ encodeURIComponent ( this . state . applicationName ) } ` ) ;
Setting . showMessage ( "success" , i18next . t ( "application:SAML metadata URL copied to clipboard successfully" ) ) ;
} }
>
{ i18next . t ( "application:Copy SAML metadata URL" ) }
< / B u t t o n >
2022-05-11 20:23:36 +08:00
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "general:Providers" ) , i18next . t ( "general:Providers - Tooltip" ) ) } :
2021-02-13 12:15:19 +08:00
< / C o l >
< Col span = { 22 } >
2021-06-14 19:09:04 +08:00
< ProviderTable
title = { i18next . t ( "general:Providers" ) }
table = { this . state . application . providers }
providers = { this . state . providers }
2021-07-10 01:19:31 +08:00
application = { this . state . application }
2022-07-10 15:45:55 +08:00
onUpdateTable = { ( value ) => { this . updateApplicationField ( "providers" , value ) ; } }
2021-06-14 19:09:04 +08:00
/ >
2021-02-13 12:15:19 +08:00
< / C o l >
< / R o w >
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "general:Preview" ) , i18next . t ( "general:Preview - Tooltip" ) ) } :
2021-02-13 12:15:19 +08:00
< / C o l >
2021-06-14 22:42:58 +08:00
{
2022-06-16 22:00:34 +08:00
this . renderSignupSigninPreview ( )
2021-06-14 22:42:58 +08:00
}
2021-02-13 12:15:19 +08:00
< / R o w >
2022-09-10 00:56:37 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
{ Setting . getLabel ( i18next . t ( "application:Background URL" ) , i18next . t ( "application:Background URL - Tooltip" ) ) } :
< / C o l >
< Col span = { 22 } style = { ( Setting . isMobile ( ) ) ? { maxWidth : "100%" } : { } } >
< Row style = { { marginTop : "20px" } } >
2022-10-22 21:43:41 +08:00
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2022-09-10 00:56:37 +08:00
{ Setting . getLabel ( i18next . t ( "general:URL" ) , i18next . t ( "general:URL - Tooltip" ) ) } :
< / C o l >
2022-10-22 21:43:41 +08:00
< Col span = { 22 } >
2022-09-10 01:33:44 +08:00
< Input prefix = { < LinkOutlined / > } value = { this . state . application . formBackgroundUrl } onChange = { e => {
this . updateApplicationField ( "formBackgroundUrl" , e . target . value ) ;
2022-09-10 00:56:37 +08:00
} } / >
< / C o l >
< / R o w >
< Row style = { { marginTop : "20px" } } >
2022-09-12 00:01:18 +08:00
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2022-09-10 00:56:37 +08:00
{ i18next . t ( "general:Preview" ) } :
< / C o l >
2022-09-12 00:01:18 +08:00
< Col span = { 22 } >
2022-09-10 01:33:44 +08:00
< a target = "_blank" rel = "noreferrer" href = { this . state . application . formBackgroundUrl } >
< img src = { this . state . application . formBackgroundUrl } alt = { this . state . application . formBackgroundUrl } height = { 90 } style = { { marginBottom : "20px" } } / >
2022-09-10 00:56:37 +08:00
< / a >
< / C o l >
< / R o w >
< / C o l >
< / R o w >
< Row >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
{ Setting . getLabel ( i18next . t ( "application:Form CSS" ) , i18next . t ( "application:Form CSS - Tooltip" ) ) } :
< / C o l >
< Col span = { 22 } >
< Popover placement = "right" content = {
< div style = { { width : "900px" , height : "300px" } } >
2022-10-22 21:43:41 +08:00
< CodeMirror value = { this . state . application . formCss === "" ? template : this . state . application . formCss }
2022-10-23 01:27:01 +08:00
options = { { mode : "css" , theme : "material-darker" } }
2022-09-10 00:56:37 +08:00
onBeforeChange = { ( editor , data , value ) => {
this . updateApplicationField ( "formCss" , value ) ;
} }
/ >
< / d i v >
} title = { i18next . t ( "application:Form CSS - Edit" ) } trigger = "click" >
< Input value = { this . state . application . formCss } style = { { marginBottom : "10px" } } onChange = { e => {
this . updateApplicationField ( "formCss" , e . target . value ) ;
} } / >
< / P o p o v e r >
< / C o l >
< / R o w >
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2022-10-23 02:26:50 +08:00
{ Setting . getLabel ( i18next . t ( "application:Form position" ) , i18next . t ( "application:Form position - Tooltip" ) ) } :
2022-09-10 00:56:37 +08:00
< / C o l >
< Col span = { 22 } >
2022-10-22 21:43:41 +08:00
< Row style = { { marginTop : "20px" } } >
< Radio . Group onChange = { e => { this . updateApplicationField ( "formOffset" , e . target . value ) ; } } value = { this . state . application . formOffset } >
< Radio . Button value = { 1 } > { i18next . t ( "application:Left" ) } < / R a d i o . B u t t o n >
< Radio . Button value = { 2 } > { i18next . t ( "application:Center" ) } < / R a d i o . B u t t o n >
< Radio . Button value = { 3 } > { i18next . t ( "application:Right" ) } < / R a d i o . B u t t o n >
< Radio . Button value = { 4 } >
{ i18next . t ( "application:Enable side panel" ) }
< / R a d i o . B u t t o n >
< / R a d i o . G r o u p >
< / R o w >
{ this . state . application . formOffset === 4 ?
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 3 } >
{ Setting . getLabel ( i18next . t ( "application:Side panel HTML" ) , i18next . t ( "application:Side panel HTML - Tooltip" ) ) } :
< / C o l >
< Col span = { 21 } >
< Popover placement = "right" content = {
< div style = { { width : "900px" , height : "300px" } } >
< CodeMirror value = { this . state . application . formSideHtml === "" ? sideTemplate : this . state . application . formSideHtml }
options = { { mode : "htmlmixed" , theme : "material-darker" } }
onBeforeChange = { ( editor , data , value ) => {
this . updateApplicationField ( "formSideHtml" , value ) ;
} }
/ >
< / d i v >
} title = { i18next . t ( "application:Side panel HTML - Edit" ) } trigger = "click" >
< Input value = { this . state . application . formSideHtml } style = { { marginBottom : "10px" } } onChange = { e => {
this . updateApplicationField ( "formSideHtml" , e . target . value ) ;
} } / >
< / P o p o v e r >
< / C o l >
< / R o w >
: null }
2022-09-10 00:56:37 +08:00
< / C o l >
< / R o w >
2021-07-10 01:19:31 +08:00
{
! this . state . application . enableSignUp ? null : (
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-07-10 01:19:31 +08:00
{ Setting . getLabel ( i18next . t ( "application:Signup items" ) , i18next . t ( "application:Signup items - Tooltip" ) ) } :
< / C o l >
< Col span = { 22 } >
< SignupTable
title = { i18next . t ( "application:Signup items" ) }
table = { this . state . application . signupItems }
2022-07-10 15:45:55 +08:00
onUpdateTable = { ( value ) => { this . updateApplicationField ( "signupItems" , value ) ; } }
2021-07-10 01:19:31 +08:00
/ >
< / C o l >
< / R o w >
)
}
2022-07-10 15:45:55 +08:00
< Row style = { { marginTop : "20px" } } >
< Col style = { { marginTop : "5px" } } span = { ( Setting . isMobile ( ) ) ? 22 : 2 } >
2021-06-30 00:58:25 +08:00
{ Setting . getLabel ( i18next . t ( "general:Preview" ) , i18next . t ( "general:Preview - Tooltip" ) ) } :
2021-06-18 02:05:19 +08:00
< / C o l >
{
2022-06-16 22:00:34 +08:00
this . renderPromptPreview ( )
2021-06-18 02:05:19 +08:00
}
< / R o w >
2021-02-13 12:15:19 +08:00
< / C a r d >
2022-07-10 15:45:55 +08:00
) ;
2021-02-13 12:15:19 +08:00
}
2022-06-16 22:00:34 +08:00
renderSignupSigninPreview ( ) {
2021-06-14 22:42:58 +08:00
let signUpUrl = ` /signup/ ${ this . state . application . name } ` ;
2022-08-08 23:35:24 +08:00
const signInUrl = ` /login/oauth/authorize?client_id= ${ this . state . application . clientId } &response_type=code&redirect_uri= ${ this . state . application . redirectUris [ 0 ] } &scope=read&state=casdoor ` ;
const maskStyle = { position : "absolute" , top : "0px" , left : "0px" , zIndex : 10 , height : "100%" , width : "100%" , background : "rgba(0,0,0,0.4)" } ;
2021-06-14 22:42:58 +08:00
if ( ! this . state . application . enablePassword ) {
signUpUrl = signInUrl . replace ( "/login/oauth/authorize" , "/signup/oauth/authorize" ) ;
}
2022-06-16 22:00:34 +08:00
2021-06-14 22:42:58 +08:00
return (
< React . Fragment >
2022-06-16 22:00:34 +08:00
< Col span = { 11 } >
< Button style = { { marginBottom : "10px" } } type = "primary" shape = "round" icon = { < CopyOutlined / > } onClick = { ( ) => {
copy ( ` ${ window . location . origin } ${ signUpUrl } ` ) ;
Setting . showMessage ( "success" , i18next . t ( "application:Signup page URL copied to clipboard successfully, please paste it into the incognito window or another browser" ) ) ;
} }
>
{ i18next . t ( "application:Copy signup page URL" ) }
< / B u t t o n >
2022-07-10 15:45:55 +08:00
< br / >
2022-08-06 23:47:28 +08:00
< div style = { { position : "relative" , width : "90%" , border : "1px solid rgb(217,217,217)" , boxShadow : "10px 10px 5px #888888" , alignItems : "center" , overflow : "auto" , flexDirection : "column" , flex : "auto" } } >
2021-06-14 22:42:58 +08:00
{
this . state . application . enablePassword ? (
< SignupPage application = { this . state . application } / >
) : (
< LoginPage type = { "login" } mode = { "signup" } application = { this . state . application } / >
)
}
2022-09-10 00:56:37 +08:00
< div style = { maskStyle } / >
2021-06-14 22:42:58 +08:00
< / d i v >
< / C o l >
2022-06-16 22:00:34 +08:00
< Col span = { 11 } >
< Button style = { { marginBottom : "10px" } } type = "primary" shape = "round" icon = { < CopyOutlined / > } onClick = { ( ) => {
copy ( ` ${ window . location . origin } ${ signInUrl } ` ) ;
Setting . showMessage ( "success" , i18next . t ( "application:Signin page URL copied to clipboard successfully, please paste it into the incognito window or another browser" ) ) ;
} }
>
{ i18next . t ( "application:Copy signin page URL" ) }
< / B u t t o n >
2022-07-10 15:45:55 +08:00
< br / >
2022-08-06 23:47:28 +08:00
< div style = { { position : "relative" , width : "90%" , border : "1px solid rgb(217,217,217)" , boxShadow : "10px 10px 5px #888888" , alignItems : "center" , overflow : "auto" , flexDirection : "column" , flex : "auto" } } >
2021-06-14 22:42:58 +08:00
< LoginPage type = { "login" } mode = { "signin" } application = { this . state . application } / >
2022-09-10 00:56:37 +08:00
< div style = { maskStyle } / >
2021-06-14 22:42:58 +08:00
< / d i v >
< / C o l >
< / R e a c t . F r a g m e n t >
2022-07-10 15:45:55 +08:00
) ;
2021-06-14 22:42:58 +08:00
}
2022-06-16 22:00:34 +08:00
renderPromptPreview ( ) {
2022-08-08 23:35:24 +08:00
const promptUrl = ` /prompt/ ${ this . state . application . name } ` ;
const maskStyle = { position : "absolute" , top : "0px" , left : "0px" , zIndex : 10 , height : "100%" , width : "100%" , background : "rgba(0,0,0,0.4)" } ;
2021-06-18 02:05:19 +08:00
return (
2022-06-16 22:00:34 +08:00
< Col span = { 11 } >
< Button style = { { marginBottom : "10px" } } type = "primary" shape = "round" icon = { < CopyOutlined / > } onClick = { ( ) => {
copy ( ` ${ window . location . origin } ${ promptUrl } ` ) ;
Setting . showMessage ( "success" , i18next . t ( "application:Prompt page URL copied to clipboard successfully, please paste it into the incognito window or another browser" ) ) ;
} }
>
{ i18next . t ( "application:Copy prompt page URL" ) }
< / B u t t o n >
2022-07-10 15:45:55 +08:00
< br / >
2022-06-16 22:00:34 +08:00
< div style = { { position : "relative" , width : "90%" , border : "1px solid rgb(217,217,217)" , boxShadow : "10px 10px 5px #888888" , flexDirection : "column" , flex : "auto" } } >
< PromptPage application = { this . state . application } account = { this . props . account } / >
2022-10-22 21:43:41 +08:00
< div style = { maskStyle } / >
2022-06-16 22:00:34 +08:00
< / d i v >
< / C o l >
2022-07-10 15:45:55 +08:00
) ;
2021-06-18 02:05:19 +08:00
}
2021-12-12 18:51:12 +08:00
submitApplicationEdit ( willExist ) {
2022-08-08 23:35:24 +08:00
const application = Setting . deepCopy ( this . state . application ) ;
2021-02-13 12:15:19 +08:00
ApplicationBackend . updateApplication ( this . state . application . owner , this . state . applicationName , application )
. then ( ( res ) => {
2021-03-28 00:48:34 +08:00
if ( res . msg === "" ) {
2022-07-10 15:45:55 +08:00
Setting . showMessage ( "success" , "Successfully saved" ) ;
2021-02-13 12:15:19 +08:00
this . setState ( {
applicationName : this . state . application . name ,
} ) ;
2021-12-12 18:51:12 +08:00
if ( willExist ) {
2022-07-10 15:45:55 +08:00
this . props . history . push ( "/applications" ) ;
2021-12-12 18:51:12 +08:00
} else {
this . props . history . push ( ` /applications/ ${ this . state . application . name } ` ) ;
}
2021-02-13 12:15:19 +08:00
} else {
2021-03-28 00:48:34 +08:00
Setting . showMessage ( "error" , res . msg ) ;
2022-07-10 15:45:55 +08:00
this . updateApplicationField ( "name" , this . state . applicationName ) ;
2021-02-13 12:15:19 +08:00
}
} )
. catch ( error => {
2021-03-28 08:59:12 +08:00
Setting . showMessage ( "error" , ` Failed to connect to server: ${ error } ` ) ;
2021-02-13 12:15:19 +08:00
} ) ;
}
2022-02-25 18:16:02 +08:00
deleteApplication ( ) {
ApplicationBackend . deleteApplication ( this . state . application )
. then ( ( ) => {
2022-07-10 15:45:55 +08:00
this . props . history . push ( "/applications" ) ;
2022-02-25 18:16:02 +08:00
} )
. catch ( error => {
Setting . showMessage ( "error" , ` Application failed to delete: ${ error } ` ) ;
} ) ;
}
2021-02-13 12:15:19 +08:00
render ( ) {
return (
< div >
2022-07-10 15:45:55 +08:00
{
this . state . application !== null ? this . renderApplication ( ) : null
}
< div style = { { marginTop : "20px" , marginLeft : "40px" } } >
< Button size = "large" onClick = { ( ) => this . submitApplicationEdit ( false ) } > { i18next . t ( "general:Save" ) } < / B u t t o n >
< Button style = { { marginLeft : "20px" } } type = "primary" size = "large" onClick = { ( ) => this . submitApplicationEdit ( true ) } > { i18next . t ( "general:Save & Exit" ) } < / B u t t o n >
{ this . state . mode === "add" ? < Button style = { { marginLeft : "20px" } } size = "large" onClick = { ( ) => this . deleteApplication ( ) } > { i18next . t ( "general:Cancel" ) } < / B u t t o n > : n u l l }
< / d i v >
2021-02-13 12:15:19 +08:00
< / d i v >
) ;
}
}
export default ApplicationEditPage ;