in src/app/devices/module/moduleIndentityDetail/components/moduleIdentityDetail.tsx [86:208]
name: t(ResourceKeys.moduleIdentity.detail.command.delete),
onClick: deleteConfirmation
}
]}
/>
);
};
const showModuleId = () => {
return (
<MaskedCopyableTextField
ariaLabel={t(ResourceKeys.moduleIdentity.moduleId)}
label={t(ResourceKeys.moduleIdentity.moduleId)}
value={moduleId}
allowMask={false}
labelCallout={t(ResourceKeys.moduleIdentity.moduleIdTooltip)}
/>
);
};
// tslint:disable-next-line:cyclomatic-complexity
const showModuleIdentity = () => {
const authType = (moduleIdentity && moduleIdentity.authentication && moduleIdentity.authentication.type || DeviceAuthenticationType.None).toLowerCase();
switch (authType) {
case DeviceAuthenticationType.SymmetricKey.toLowerCase():
return renderSymmetricKeySection();
case DeviceAuthenticationType.CACertificate.toLowerCase():
return renderCaSection();
case DeviceAuthenticationType.SelfSigned.toLowerCase():
return renderSelfSignedSection();
default:
return (<></>);
}
};
const renderSymmetricKeySection = () => {
return (
<>
<MaskedCopyableTextField
ariaLabel={t(ResourceKeys.moduleIdentity.authenticationType.symmetricKey.primaryKey)}
label={t(ResourceKeys.moduleIdentity.authenticationType.symmetricKey.primaryKey)}
value={moduleIdentity.authentication.symmetricKey.primaryKey}
allowMask={true}
labelCallout={t(ResourceKeys.moduleIdentity.authenticationType.symmetricKey.primaryKeyTooltip)}
/>
<MaskedCopyableTextField
ariaLabel={t(ResourceKeys.moduleIdentity.authenticationType.symmetricKey.secondaryKey)}
label={t(ResourceKeys.moduleIdentity.authenticationType.symmetricKey.secondaryKey)}
value={moduleIdentity.authentication.symmetricKey.secondaryKey}
allowMask={true}
labelCallout={t(ResourceKeys.moduleIdentity.authenticationType.symmetricKey.secondaryKeyTooltip)}
/>
<MaskedCopyableTextField
ariaLabel={t(ResourceKeys.moduleIdentity.authenticationType.symmetricKey.primaryConnectionString)}
label={t(ResourceKeys.moduleIdentity.authenticationType.symmetricKey.primaryConnectionString)}
value={generateConnectionString(moduleIdentity.authentication.symmetricKey.primaryKey)}
allowMask={true}
/>
<MaskedCopyableTextField
ariaLabel={t(ResourceKeys.moduleIdentity.authenticationType.symmetricKey.secondaryConnectionString)}
label={t(ResourceKeys.moduleIdentity.authenticationType.symmetricKey.secondaryConnectionString)}
value={generateConnectionString(moduleIdentity.authentication.symmetricKey.secondaryKey)}
allowMask={true}
/>
{renderSasTokenSection()}
</>
);
};
const renderCaSection = () => <Label>{t(ResourceKeys.moduleIdentity.authenticationType.ca.text)}</Label>;
const renderSelfSignedSection = () => {
return (
<>
<Label>{t(ResourceKeys.moduleIdentity.authenticationType.selfSigned.text)}</Label>
<MaskedCopyableTextField
ariaLabel={t(ResourceKeys.moduleIdentity.authenticationType.selfSigned.primaryThumbprint)}
label={t(ResourceKeys.moduleIdentity.authenticationType.selfSigned.primaryThumbprint)}
value={moduleIdentity.authentication.x509Thumbprint.primaryThumbprint}
allowMask={true}
labelCallout={t(ResourceKeys.moduleIdentity.authenticationType.selfSigned.primaryThumbprintTooltip)}
/>
<MaskedCopyableTextField
ariaLabel={t(ResourceKeys.moduleIdentity.authenticationType.selfSigned.secondaryThumbprint)}
label={t(ResourceKeys.moduleIdentity.authenticationType.selfSigned.secondaryThumbprint)}
value={moduleIdentity.authentication.x509Thumbprint.secondaryThumbprint}
allowMask={true}
labelCallout={t(ResourceKeys.moduleIdentity.authenticationType.selfSigned.secondaryThumbprintTooltip)}
/>
</>
);
};
const renderSasTokenSection = () => {
return (
<SasTokenGenerationView
activeAzureResourceHostName={hostName}
moduleIdentity={moduleIdentity}
/>
);
};
const navigateToModuleList = () => {
const path = pathname.replace(/\/moduleIdentity\/moduleDetail\/.*/, `/${ROUTE_PARTS.MODULE_IDENTITY}`);
history.push(`${path}/?${ROUTE_PARAMS.DEVICE_ID}=${encodeURIComponent(deviceId)}`);
};
const generateConnectionString = (key: string): string => {
return `HostName=${hostName};DeviceId=${deviceId};ModuleId=${moduleId};SharedAccessKey=${key}`;
};
const deleteConfirmationDialog = () => {
return (
<div role="dialog">
<Dialog
hidden={!showDeleteConfirmation}
onDismiss={closeDeleteDialog}
dialogContentProps={{