mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-05-18 06:14:48 +01:00
Merge branch 'master' of https://github.com/Azure/cosmos-explorer into accessibility-2278267
This commit is contained in:
commit
b8f5c8842b
@ -16,10 +16,20 @@ export const ConnectTab: React.FC = (): JSX.Element => {
|
|||||||
const [primaryReadonlyMasterKey, setPrimaryReadonlyMasterKey] = useState<string>("");
|
const [primaryReadonlyMasterKey, setPrimaryReadonlyMasterKey] = useState<string>("");
|
||||||
const [secondaryReadonlyMasterKey, setSecondaryReadonlyMasterKey] = useState<string>("");
|
const [secondaryReadonlyMasterKey, setSecondaryReadonlyMasterKey] = useState<string>("");
|
||||||
const uri: string = userContext.databaseAccount.properties?.documentEndpoint;
|
const uri: string = userContext.databaseAccount.properties?.documentEndpoint;
|
||||||
const primaryConnectionStr = `AccountEndpoint=${uri};AccountKey=${primaryMasterKey}`;
|
const primaryConnectionStr = `AccountEndpoint=${uri};AccountKey=${primaryMasterKey};`;
|
||||||
const secondaryConnectionStr = `AccountEndpoint=${uri};AccountKey=${secondaryMasterKey}`;
|
const secondaryConnectionStr = `AccountEndpoint=${uri};AccountKey=${secondaryMasterKey};`;
|
||||||
const primaryReadonlyConnectionStr = `AccountEndpoint=${uri};AccountKey=${primaryReadonlyMasterKey}`;
|
const primaryReadonlyConnectionStr = `AccountEndpoint=${uri};AccountKey=${primaryReadonlyMasterKey};`;
|
||||||
const secondaryReadonlyConnectionStr = `AccountEndpoint=${uri};AccountKey=${secondaryReadonlyMasterKey}`;
|
const secondaryReadonlyConnectionStr = `AccountEndpoint=${uri};AccountKey=${secondaryReadonlyMasterKey};`;
|
||||||
|
const maskedValue: string =
|
||||||
|
"*********************************************************************************************************************************";
|
||||||
|
const [showPrimaryMasterKey, setShowPrimaryMasterKey] = useState<boolean>(false);
|
||||||
|
const [showSecondaryMasterKey, setShowSecondaryMasterKey] = useState<boolean>(false);
|
||||||
|
const [showPrimaryReadonlyMasterKey, setShowPrimaryReadonlyMasterKey] = useState<boolean>(false);
|
||||||
|
const [showSecondaryReadonlyMasterKey, setShowSecondaryReadonlyMasterKey] = useState<boolean>(false);
|
||||||
|
const [showPrimaryConnectionStr, setShowPrimaryConnectionStr] = useState<boolean>(false);
|
||||||
|
const [showSecondaryConnectionStr, setShowSecondaryConnectionStr] = useState<boolean>(false);
|
||||||
|
const [showPrimaryReadonlyConnectionStr, setShowPrimaryReadonlyConnectionStr] = useState<boolean>(false);
|
||||||
|
const [showSecondaryReadonlyConnectionStr, setShowSecondaryReadonlyConnectionStr] = useState<boolean>(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchKeys();
|
fetchKeys();
|
||||||
@ -62,55 +72,97 @@ export const ConnectTab: React.FC = (): JSX.Element => {
|
|||||||
root: { width: "100%" },
|
root: { width: "100%" },
|
||||||
field: { backgroundColor: "rgb(230, 230, 230)" },
|
field: { backgroundColor: "rgb(230, 230, 230)" },
|
||||||
fieldGroup: { borderColor: "rgb(138, 136, 134)" },
|
fieldGroup: { borderColor: "rgb(138, 136, 134)" },
|
||||||
|
suffix: {
|
||||||
|
backgroundColor: "rgb(230, 230, 230)",
|
||||||
|
margin: 0,
|
||||||
|
padding: 0,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const renderCopyButton = (selector: string) => (
|
||||||
|
<IconButton
|
||||||
|
iconProps={{ iconName: "Copy" }}
|
||||||
|
onClick={() => 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 (
|
return (
|
||||||
<div style={{ width: "100%", padding: 16 }}>
|
<div style={{ width: "100%", padding: 16 }}>
|
||||||
|
<Stack horizontal verticalAlign="end" style={{ marginBottom: 16, margin: 10 }}>
|
||||||
|
<TextField
|
||||||
|
label="URI"
|
||||||
|
id="uriTextfield"
|
||||||
|
readOnly
|
||||||
|
value={uri}
|
||||||
|
styles={textfieldStyles}
|
||||||
|
onRenderSuffix={() => renderCopyButton("#uriTextfield")}
|
||||||
|
/>
|
||||||
|
<div style={{ width: 32 }}></div>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
<Pivot>
|
<Pivot>
|
||||||
{userContext.hasWriteAccess && (
|
{userContext.hasWriteAccess && (
|
||||||
<PivotItem headerText="Read-write Keys">
|
<PivotItem headerText="Read-write Keys">
|
||||||
<Stack style={{ margin: 10 }}>
|
<Stack style={{ margin: 10, overflow: "auto", maxHeight: "calc(100vh - 300px)" }}>
|
||||||
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
|
||||||
<TextField label="URI" id="uriTextfield" readOnly value={uri} styles={textfieldStyles} />
|
|
||||||
<IconButton iconProps={{ iconName: "Copy" }} onClick={() => onCopyBtnClicked("#uriTextfield")} />
|
|
||||||
</Stack>
|
|
||||||
|
|
||||||
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
||||||
<TextField
|
<TextField
|
||||||
label="PRIMARY KEY"
|
label="PRIMARY KEY"
|
||||||
id="primaryKeyTextfield"
|
id="primaryKeyTextfield"
|
||||||
readOnly
|
readOnly
|
||||||
value={primaryMasterKey}
|
value={showPrimaryMasterKey ? primaryMasterKey : maskedValue}
|
||||||
styles={textfieldStyles}
|
styles={textfieldStyles}
|
||||||
|
{...(showPrimaryMasterKey && {
|
||||||
|
onRenderSuffix: () => renderCopyButton("#primaryKeyTextfield"),
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
<IconButton
|
||||||
|
iconProps={{ iconName: showPrimaryMasterKey ? "Hide3" : "View" }}
|
||||||
|
onClick={() => setShowPrimaryMasterKey(!showPrimaryMasterKey)}
|
||||||
/>
|
/>
|
||||||
<IconButton iconProps={{ iconName: "Copy" }} onClick={() => onCopyBtnClicked("#primaryKeyTextfield")} />
|
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
||||||
<TextField
|
<TextField
|
||||||
label="SECONDARY KEY"
|
label="SECONDARY KEY"
|
||||||
id="secondaryKeyTextfield"
|
id="secondaryKeyTextfield"
|
||||||
readOnly
|
readOnly
|
||||||
value={secondaryMasterKey}
|
value={showSecondaryMasterKey ? secondaryMasterKey : maskedValue}
|
||||||
styles={textfieldStyles}
|
styles={textfieldStyles}
|
||||||
|
{...(showSecondaryMasterKey && {
|
||||||
|
onRenderSuffix: () => renderCopyButton("#secondaryKeyTextfield"),
|
||||||
|
})}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
iconProps={{ iconName: "Copy" }}
|
iconProps={{ iconName: showSecondaryMasterKey ? "Hide3" : "View" }}
|
||||||
onClick={() => onCopyBtnClicked("#secondaryKeyTextfield")}
|
onClick={() => setShowSecondaryMasterKey(!showSecondaryMasterKey)}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
||||||
<TextField
|
<TextField
|
||||||
label="PRIMARY CONNECTION STRING"
|
label="PRIMARY CONNECTION STRING"
|
||||||
id="primaryConStrTextfield"
|
id="primaryConStrTextfield"
|
||||||
readOnly
|
readOnly
|
||||||
value={primaryConnectionStr}
|
value={showPrimaryConnectionStr ? primaryConnectionStr : maskedValue}
|
||||||
styles={textfieldStyles}
|
styles={textfieldStyles}
|
||||||
|
{...(showPrimaryConnectionStr && {
|
||||||
|
onRenderSuffix: () => renderCopyButton("#primaryConStrTextfield"),
|
||||||
|
})}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
iconProps={{ iconName: "Copy" }}
|
iconProps={{ iconName: showPrimaryConnectionStr ? "Hide3" : "View" }}
|
||||||
onClick={() => onCopyBtnClicked("#primaryConStrTextfield")}
|
onClick={() => setShowPrimaryConnectionStr(!showPrimaryConnectionStr)}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
||||||
@ -118,34 +170,36 @@ export const ConnectTab: React.FC = (): JSX.Element => {
|
|||||||
label="SECONDARY CONNECTION STRING"
|
label="SECONDARY CONNECTION STRING"
|
||||||
id="secondaryConStrTextfield"
|
id="secondaryConStrTextfield"
|
||||||
readOnly
|
readOnly
|
||||||
value={secondaryConnectionStr}
|
value={showSecondaryConnectionStr ? secondaryConnectionStr : maskedValue}
|
||||||
styles={textfieldStyles}
|
styles={textfieldStyles}
|
||||||
|
{...(showSecondaryConnectionStr && {
|
||||||
|
onRenderSuffix: () => renderCopyButton("#secondaryConStrTextfield"),
|
||||||
|
})}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
iconProps={{ iconName: "Copy" }}
|
iconProps={{ iconName: showSecondaryConnectionStr ? "Hide3" : "View" }}
|
||||||
onClick={() => onCopyBtnClicked("#secondaryConStrTextfield")}
|
onClick={() => setShowSecondaryConnectionStr(!showSecondaryConnectionStr)}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
</PivotItem>
|
</PivotItem>
|
||||||
)}
|
)}
|
||||||
<PivotItem headerText="Read-only Keys">
|
<PivotItem headerText="Read-only Keys">
|
||||||
<Stack style={{ margin: 10 }}>
|
<Stack style={{ margin: 10, overflow: "auto", maxHeight: "calc(100vh - 300px)" }}>
|
||||||
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
|
||||||
<TextField label="URI" id="uriReadOnlyTextfield" readOnly value={uri} styles={textfieldStyles} />
|
|
||||||
<IconButton iconProps={{ iconName: "Copy" }} onClick={() => onCopyBtnClicked("#uriReadOnlyTextfield")} />
|
|
||||||
</Stack>
|
|
||||||
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
||||||
<TextField
|
<TextField
|
||||||
label="PRIMARY READ-ONLY KEY"
|
label="PRIMARY READ-ONLY KEY"
|
||||||
id="primaryReadonlyKeyTextfield"
|
id="primaryReadonlyKeyTextfield"
|
||||||
readOnly
|
readOnly
|
||||||
value={primaryReadonlyMasterKey}
|
value={showPrimaryReadonlyMasterKey ? primaryReadonlyMasterKey : maskedValue}
|
||||||
styles={textfieldStyles}
|
styles={textfieldStyles}
|
||||||
|
{...(showPrimaryReadonlyMasterKey && {
|
||||||
|
onRenderSuffix: () => renderCopyButton("#primaryReadonlyKeyTextfield"),
|
||||||
|
})}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
iconProps={{ iconName: "Copy" }}
|
iconProps={{ iconName: showPrimaryReadonlyMasterKey ? "Hide3" : "View" }}
|
||||||
onClick={() => onCopyBtnClicked("#primaryReadonlyKeyTextfield")}
|
onClick={() => setShowPrimaryReadonlyMasterKey(!showPrimaryReadonlyMasterKey)}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
||||||
@ -153,12 +207,15 @@ export const ConnectTab: React.FC = (): JSX.Element => {
|
|||||||
label="SECONDARY READ-ONLY KEY"
|
label="SECONDARY READ-ONLY KEY"
|
||||||
id="secondaryReadonlyKeyTextfield"
|
id="secondaryReadonlyKeyTextfield"
|
||||||
readOnly
|
readOnly
|
||||||
value={secondaryReadonlyMasterKey}
|
value={showSecondaryReadonlyMasterKey ? secondaryReadonlyMasterKey : maskedValue}
|
||||||
styles={textfieldStyles}
|
styles={textfieldStyles}
|
||||||
|
{...(showSecondaryReadonlyMasterKey && {
|
||||||
|
onRenderSuffix: () => renderCopyButton("#secondaryReadonlyKeyTextfield"),
|
||||||
|
})}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
iconProps={{ iconName: "Copy" }}
|
iconProps={{ iconName: showSecondaryReadonlyMasterKey ? "Hide3" : "View" }}
|
||||||
onClick={() => onCopyBtnClicked("#secondaryReadonlyKeyTextfield")}
|
onClick={() => setShowSecondaryReadonlyMasterKey(!showSecondaryReadonlyMasterKey)}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
||||||
@ -166,25 +223,31 @@ export const ConnectTab: React.FC = (): JSX.Element => {
|
|||||||
label="PRIMARY READ-ONLY CONNECTION STRING"
|
label="PRIMARY READ-ONLY CONNECTION STRING"
|
||||||
id="primaryReadonlyConStrTextfield"
|
id="primaryReadonlyConStrTextfield"
|
||||||
readOnly
|
readOnly
|
||||||
value={primaryReadonlyConnectionStr}
|
value={showPrimaryReadonlyConnectionStr ? primaryReadonlyConnectionStr : maskedValue}
|
||||||
styles={textfieldStyles}
|
styles={textfieldStyles}
|
||||||
|
{...(showPrimaryReadonlyConnectionStr && {
|
||||||
|
onRenderSuffix: () => renderCopyButton("#primaryReadonlyConStrTextfield"),
|
||||||
|
})}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
iconProps={{ iconName: "Copy" }}
|
iconProps={{ iconName: showPrimaryReadonlyConnectionStr ? "Hide3" : "View" }}
|
||||||
onClick={() => onCopyBtnClicked("#primaryReadonlyConStrTextfield")}
|
onClick={() => setShowPrimaryReadonlyConnectionStr(!showPrimaryReadonlyConnectionStr)}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
<Stack horizontal verticalAlign="end" style={{ marginBottom: 8 }}>
|
||||||
<TextField
|
<TextField
|
||||||
label="SECONDARY READ-ONLY CONNECTION STRING"
|
label="SECONDARY READ-ONLY CONNECTION STRING"
|
||||||
id="secondaryReadonlyConStrTextfield"
|
id="secondaryReadonlyConStrTextfield"
|
||||||
value={secondaryReadonlyConnectionStr}
|
value={showSecondaryReadonlyConnectionStr ? secondaryReadonlyConnectionStr : maskedValue}
|
||||||
readOnly
|
readOnly
|
||||||
styles={textfieldStyles}
|
styles={textfieldStyles}
|
||||||
|
{...(showSecondaryReadonlyConnectionStr && {
|
||||||
|
onRenderSuffix: () => renderCopyButton("#secondaryReadonlyConStrTextfield"),
|
||||||
|
})}
|
||||||
/>
|
/>
|
||||||
<IconButton
|
<IconButton
|
||||||
iconProps={{ iconName: "Copy" }}
|
iconProps={{ iconName: showSecondaryReadonlyConnectionStr ? "Hide3" : "View" }}
|
||||||
onClick={() => onCopyBtnClicked("#secondaryReadonlyConStrTextfield")}
|
onClick={() => setShowSecondaryReadonlyConnectionStr(!showSecondaryReadonlyConnectionStr)}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
@ -20,6 +20,10 @@ async function main() {
|
|||||||
const client = new CosmosDBManagementClient(credentials, subscriptionId);
|
const client = new CosmosDBManagementClient(credentials, subscriptionId);
|
||||||
const accounts = await client.databaseAccounts.list(resourceGroupName);
|
const accounts = await client.databaseAccounts.list(resourceGroupName);
|
||||||
for (const account of accounts) {
|
for (const account of accounts) {
|
||||||
|
if (account.name.endsWith("-readonly")) {
|
||||||
|
console.log(`SKIPPED: ${account.name}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (account.kind === "MongoDB") {
|
if (account.kind === "MongoDB") {
|
||||||
const mongoDatabases = await client.mongoDBResources.listMongoDBDatabases(resourceGroupName, account.name);
|
const mongoDatabases = await client.mongoDBResources.listMongoDBDatabases(resourceGroupName, account.name);
|
||||||
for (const database of mongoDatabases) {
|
for (const database of mongoDatabases) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user