import React, { useEffect } from "react"; import { makeStyles } from "@material-ui/styles"; import { useTheme } from "@material-ui/core/styles"; import { useAlert } from "react-alert"; import { FormControl, InputLabel, Paper, OutlinedInput, Checkbox, Card, Tooltip, FormControlLabel, Typography, Switch, Select, MenuItem, Divider, TextField, Button, Tabs, Tab, Grid, } from "@material-ui/core"; import IconButton from "@material-ui/core/IconButton"; import ExpandLessIcon from "@material-ui/icons/ExpandLess"; import ExpandMoreIcon from "@material-ui/icons/ExpandMore"; import SaveIcon from "@material-ui/icons/Save"; const useStyles = makeStyles({ notchedOutline: { borderColor: "#f85a3e !important", }, }); const OrgHeaderexpanded = (props) => { const { userdata, selectedOrganization, setSelectedOrganization, globalUrl, isCloud, adminTab, } = props; const theme = useTheme(); const alert = useAlert(); const classes = useStyles(); const defaultBranch = "master"; const [orgName, setOrgName] = React.useState(selectedOrganization.name); const [orgDescription, setOrgDescription] = React.useState( selectedOrganization.description ); const [appDownloadUrl, setAppDownloadUrl] = React.useState( selectedOrganization.defaults === undefined ? "https://github.com/frikky/shuffle-apps" : selectedOrganization.defaults.app_download_repo === undefined || selectedOrganization.defaults.app_download_repo.length === 0 ? "https://github.com/frikky/shuffle-apps" : selectedOrganization.defaults.app_download_repo ); const [appDownloadBranch, setAppDownloadBranch] = React.useState( selectedOrganization.defaults === undefined ? defaultBranch : selectedOrganization.defaults.app_download_branch === undefined || selectedOrganization.defaults.app_download_branch.length === 0 ? defaultBranch : selectedOrganization.defaults.app_download_branch ); const [workflowDownloadUrl, setWorkflowDownloadUrl] = React.useState( selectedOrganization.defaults === undefined ? "https://github.com/frikky/shuffle-apps" : selectedOrganization.defaults.workflow_download_repo === undefined || selectedOrganization.defaults.workflow_download_repo.length === 0 ? "https://github.com/frikky/shuffle-workflows" : selectedOrganization.defaults.workflow_download_repo ); const [workflowDownloadBranch, setWorkflowDownloadBranch] = React.useState( selectedOrganization.defaults === undefined ? defaultBranch : selectedOrganization.defaults.workflow_download_branch === undefined || selectedOrganization.defaults.workflow_download_branch.length === 0 ? defaultBranch : selectedOrganization.defaults.workflow_download_branch ); const [ssoEntrypoint, setSsoEntrypoint] = React.useState( selectedOrganization.sso_config === undefined ? "" : selectedOrganization.sso_config.sso_entrypoint === undefined || selectedOrganization.sso_config.sso_entrypoint.length === 0 ? "" : selectedOrganization.sso_config.sso_entrypoint ); const [ssoCertificate, setSsoCertificate] = React.useState( selectedOrganization.sso_config === undefined ? "" : selectedOrganization.sso_config.sso_certificate === undefined || selectedOrganization.sso_config.sso_certificate.length === 0 ? "" : selectedOrganization.sso_config.sso_certificate ); const [notificationWorkflow, setNotificationWorkflow] = React.useState( selectedOrganization.defaults === undefined ? "" : selectedOrganization.defaults.notification_workflow === undefined || selectedOrganization.defaults.notification_workflow.length === 0 ? "" : selectedOrganization.defaults.notification_workflow ); const [documentationReference, setDocumentationReference] = React.useState( selectedOrganization.defaults === undefined ? "" : selectedOrganization.defaults.documentation_reference === undefined || selectedOrganization.defaults.documentation_reference.length === 0 ? "" : selectedOrganization.defaults.documentation_reference ); const [openidClientId, setOpenidClientId] = React.useState( selectedOrganization.sso_config === undefined ? "" : selectedOrganization.sso_config.client_id === undefined || selectedOrganization.sso_config.client_id.length === 0 ? "" : selectedOrganization.sso_config.client_id ); const [openidClientSecret, setOpenidClientSecret] = React.useState( selectedOrganization.sso_config === undefined ? "" : selectedOrganization.sso_config.client_secret === undefined || selectedOrganization.sso_config.client_secret.length === 0 ? "" : selectedOrganization.sso_config.client_secret ); const [openidAuthorization, setOpenidAuthorization] = React.useState( selectedOrganization.sso_config === undefined ? "" : selectedOrganization.sso_config.openid_authorization === undefined || selectedOrganization.sso_config.openid_authorization.length === 0 ? "" : selectedOrganization.sso_config.openid_authorization ); const [openidToken, setOpenidToken] = React.useState( selectedOrganization.sso_config === undefined ? "" : selectedOrganization.sso_config.openid_token === undefined || selectedOrganization.sso_config.openid_token.length === 0 ? "" : selectedOrganization.sso_config.openid_token ) const handleEditOrg = ( name, description, orgId, image, defaults, sso_config ) => { const data = { name: name, description: description, org_id: orgId, image: image, defaults: defaults, sso_config: sso_config, }; const url = globalUrl + `/api/v1/orgs/${selectedOrganization.id}`; fetch(url, { mode: "cors", method: "POST", body: JSON.stringify(data), credentials: "include", crossDomain: true, withCredentials: true, headers: { "Content-Type": "application/json; charset=utf-8", }, }) .then((response) => response.json().then((responseJson) => { if (responseJson["success"] === false) { alert.error("Failed updating org: ", responseJson.reason); } else { alert.success("Successfully edited org!"); } }) ) .catch((error) => { alert.error("Err: " + error.toString()); }); }; const orgSaveButton = ( ); return (
Notification Workflow ID { setNotificationWorkflow(e.target.value); }} InputProps={{ classes: { notchedOutline: classes.notchedOutline, }, style: { color: "white", }, }} /> Org Documentation reference { setDocumentationReference(e.target.value); }} InputProps={{ classes: { notchedOutline: classes.notchedOutline, }, style: { color: "white", }, }} /> {isCloud ? null : OpenID connect Client ID 0 } id="outlined-with-placeholder" margin="normal" variant="outlined" placeholder="The OpenID client ID from the identity provider" value={openidClientId} onChange={(e) => { setOpenidClientId(e.target.value); }} InputProps={{ classes: { notchedOutline: classes.notchedOutline, }, style: { color: "white", }, }} /> Client Secret (optional) 0 } id="outlined-with-placeholder" margin="normal" variant="outlined" placeholder="The OpenID client secret - DONT use this if dealing with implicit auth / PKCE" value={openidClientSecret} onChange={(e) => { setOpenidClientSecret(e.target.value); }} InputProps={{ classes: { notchedOutline: classes.notchedOutline, }, style: { color: "white", }, }} /> Authorization URL { setOpenidAuthorization(e.target.value) }} InputProps={{ classes: { notchedOutline: classes.notchedOutline, }, style: { color: "white", }, }} /> Token URL { setOpenidToken(e.target.value) }} InputProps={{ classes: { notchedOutline: classes.notchedOutline, }, style: { color: "white", }, }} /> } {/*isCloud ? null : */} SAML SSO (v1.1) SSO Entrypoint (IdP) 0 } id="outlined-with-placeholder" margin="normal" variant="outlined" placeholder="The entrypoint URL from your provider" value={ssoEntrypoint} onChange={(e) => { setSsoEntrypoint(e.target.value); }} InputProps={{ classes: { notchedOutline: classes.notchedOutline, }, style: { color: "white", }, }} /> SSO Certificate (X509) { setSsoCertificate(e.target.value); }} InputProps={{ classes: { notchedOutline: classes.notchedOutline, }, style: { color: "white", }, }} /> {isCloud ? IdP URL for Shuffle: https://shuffler.io/api/v1/login_sso : null} {isCloud ? null : ( App Download URL { setAppDownloadUrl(e.target.value); }} InputProps={{ classes: { notchedOutline: classes.notchedOutline, }, style: { color: "white", }, }} /> )} {isCloud ? null : ( App Download Branch { setAppDownloadBranch(e.target.value); }} InputProps={{ classes: { notchedOutline: classes.notchedOutline, }, style: { color: "white", }, }} /> )} {isCloud ? null : ( Workflow Download URL { setWorkflowDownloadUrl(e.target.value); }} InputProps={{ classes: { notchedOutline: classes.notchedOutline, }, style: { color: "white", }, }} /> )} {isCloud ? null : ( Workflow Download Branch { setWorkflowDownloadBranch(e.target.value); }} InputProps={{ classes: { notchedOutline: classes.notchedOutline, }, style: { color: "white", }, }} /> )}
{orgSaveButton}
{/* {expanded ? : } */}
) } export default OrgHeaderexpanded;