diff --git a/src/Explorer/Tabs/ConnectTab.tsx b/src/Explorer/Tabs/ConnectTab.tsx index 3c334fbc1..62f190996 100644 --- a/src/Explorer/Tabs/ConnectTab.tsx +++ b/src/Explorer/Tabs/ConnectTab.tsx @@ -16,10 +16,20 @@ export const ConnectTab: React.FC = (): JSX.Element => { const [primaryReadonlyMasterKey, setPrimaryReadonlyMasterKey] = useState(""); const [secondaryReadonlyMasterKey, setSecondaryReadonlyMasterKey] = useState(""); const uri: string = userContext.databaseAccount.properties?.documentEndpoint; - const primaryConnectionStr = `AccountEndpoint=${uri};AccountKey=${primaryMasterKey}`; - const secondaryConnectionStr = `AccountEndpoint=${uri};AccountKey=${secondaryMasterKey}`; - const primaryReadonlyConnectionStr = `AccountEndpoint=${uri};AccountKey=${primaryReadonlyMasterKey}`; - const secondaryReadonlyConnectionStr = `AccountEndpoint=${uri};AccountKey=${secondaryReadonlyMasterKey}`; + const primaryConnectionStr = `AccountEndpoint=${uri};AccountKey=${primaryMasterKey};`; + const secondaryConnectionStr = `AccountEndpoint=${uri};AccountKey=${secondaryMasterKey};`; + const primaryReadonlyConnectionStr = `AccountEndpoint=${uri};AccountKey=${primaryReadonlyMasterKey};`; + const secondaryReadonlyConnectionStr = `AccountEndpoint=${uri};AccountKey=${secondaryReadonlyMasterKey};`; + const maskedValue: string = + "*********************************************************************************************************************************"; + const [showPrimaryMasterKey, setShowPrimaryMasterKey] = useState(false); + const [showSecondaryMasterKey, setShowSecondaryMasterKey] = useState(false); + const [showPrimaryReadonlyMasterKey, setShowPrimaryReadonlyMasterKey] = useState(false); + const [showSecondaryReadonlyMasterKey, setShowSecondaryReadonlyMasterKey] = useState(false); + const [showPrimaryConnectionStr, setShowPrimaryConnectionStr] = useState(false); + const [showSecondaryConnectionStr, setShowSecondaryConnectionStr] = useState(false); + const [showPrimaryReadonlyConnectionStr, setShowPrimaryReadonlyConnectionStr] = useState(false); + const [showSecondaryReadonlyConnectionStr, setShowSecondaryReadonlyConnectionStr] = useState(false); useEffect(() => { fetchKeys(); @@ -62,55 +72,97 @@ export const ConnectTab: React.FC = (): JSX.Element => { root: { width: "100%" }, field: { backgroundColor: "rgb(230, 230, 230)" }, fieldGroup: { borderColor: "rgb(138, 136, 134)" }, + suffix: { + backgroundColor: "rgb(230, 230, 230)", + margin: 0, + padding: 0, + }, }; + const renderCopyButton = (selector: string) => ( + onCopyBtnClicked(selector)} + styles={{ + root: { + height: "100%", + backgroundColor: "rgb(230, 230, 230)", + border: "none", + }, + rootHovered: { + backgroundColor: "rgb(220, 220, 220)", + }, + rootPressed: { + backgroundColor: "rgb(210, 210, 210)", + }, + }} + /> + ); + return (
+ + renderCopyButton("#uriTextfield")} + /> +
+
+ {userContext.hasWriteAccess && ( - - - - onCopyBtnClicked("#uriTextfield")} /> - - + renderCopyButton("#primaryKeyTextfield"), + })} + /> + setShowPrimaryMasterKey(!showPrimaryMasterKey)} /> - onCopyBtnClicked("#primaryKeyTextfield")} /> - renderCopyButton("#secondaryKeyTextfield"), + })} /> onCopyBtnClicked("#secondaryKeyTextfield")} + iconProps={{ iconName: showSecondaryMasterKey ? "Hide3" : "View" }} + onClick={() => setShowSecondaryMasterKey(!showSecondaryMasterKey)} /> - renderCopyButton("#primaryConStrTextfield"), + })} /> onCopyBtnClicked("#primaryConStrTextfield")} + iconProps={{ iconName: showPrimaryConnectionStr ? "Hide3" : "View" }} + onClick={() => setShowPrimaryConnectionStr(!showPrimaryConnectionStr)} /> @@ -118,34 +170,36 @@ export const ConnectTab: React.FC = (): JSX.Element => { label="SECONDARY CONNECTION STRING" id="secondaryConStrTextfield" readOnly - value={secondaryConnectionStr} + value={showSecondaryConnectionStr ? secondaryConnectionStr : maskedValue} styles={textfieldStyles} + {...(showSecondaryConnectionStr && { + onRenderSuffix: () => renderCopyButton("#secondaryConStrTextfield"), + })} /> onCopyBtnClicked("#secondaryConStrTextfield")} + iconProps={{ iconName: showSecondaryConnectionStr ? "Hide3" : "View" }} + onClick={() => setShowSecondaryConnectionStr(!showSecondaryConnectionStr)} /> )} - - - - onCopyBtnClicked("#uriReadOnlyTextfield")} /> - + renderCopyButton("#primaryReadonlyKeyTextfield"), + })} /> onCopyBtnClicked("#primaryReadonlyKeyTextfield")} + iconProps={{ iconName: showPrimaryReadonlyMasterKey ? "Hide3" : "View" }} + onClick={() => setShowPrimaryReadonlyMasterKey(!showPrimaryReadonlyMasterKey)} /> @@ -153,12 +207,15 @@ export const ConnectTab: React.FC = (): JSX.Element => { label="SECONDARY READ-ONLY KEY" id="secondaryReadonlyKeyTextfield" readOnly - value={secondaryReadonlyMasterKey} + value={showSecondaryReadonlyMasterKey ? secondaryReadonlyMasterKey : maskedValue} styles={textfieldStyles} + {...(showSecondaryReadonlyMasterKey && { + onRenderSuffix: () => renderCopyButton("#secondaryReadonlyKeyTextfield"), + })} /> onCopyBtnClicked("#secondaryReadonlyKeyTextfield")} + iconProps={{ iconName: showSecondaryReadonlyMasterKey ? "Hide3" : "View" }} + onClick={() => setShowSecondaryReadonlyMasterKey(!showSecondaryReadonlyMasterKey)} /> @@ -166,25 +223,31 @@ export const ConnectTab: React.FC = (): JSX.Element => { label="PRIMARY READ-ONLY CONNECTION STRING" id="primaryReadonlyConStrTextfield" readOnly - value={primaryReadonlyConnectionStr} + value={showPrimaryReadonlyConnectionStr ? primaryReadonlyConnectionStr : maskedValue} styles={textfieldStyles} + {...(showPrimaryReadonlyConnectionStr && { + onRenderSuffix: () => renderCopyButton("#primaryReadonlyConStrTextfield"), + })} /> onCopyBtnClicked("#primaryReadonlyConStrTextfield")} + iconProps={{ iconName: showPrimaryReadonlyConnectionStr ? "Hide3" : "View" }} + onClick={() => setShowPrimaryReadonlyConnectionStr(!showPrimaryReadonlyConnectionStr)} /> renderCopyButton("#secondaryReadonlyConStrTextfield"), + })} /> onCopyBtnClicked("#secondaryReadonlyConStrTextfield")} + iconProps={{ iconName: showSecondaryReadonlyConnectionStr ? "Hide3" : "View" }} + onClick={() => setShowSecondaryReadonlyConnectionStr(!showSecondaryReadonlyConnectionStr)} />