Skip to content

Commit

Permalink
Simplify FE views
Browse files Browse the repository at this point in the history
  • Loading branch information
dlpzx committed Dec 5, 2024
1 parent af21526 commit 4b675f3
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 53 deletions.
6 changes: 4 additions & 2 deletions frontend/src/modules/Folders/components/FolderOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ export const FolderOverview = (props) => {
}
/>
</Box>
<FolderS3Properties folder={folder} isAdmin={isAdmin} />
{folder.restricted && (
<FolderS3Properties folder={folder} isAdmin={isAdmin} />
)}
</Grid>
<Grid item lg={4} xl={3} xs={12}>
<ObjectMetadata
environment={folder.dataset.environment}
region={folder.restricted?.region || 'UNAUTHORIZED_INFO'}
region={folder.restricted?.region}
organization={folder.dataset.environment.organization}
owner={folder.owner}
admins={folder.dataset.SamlAdminGroupName || '-'}
Expand Down
12 changes: 4 additions & 8 deletions frontend/src/modules/Folders/components/FolderS3Properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,31 @@ export const FolderS3Properties = (props) => {
S3 URI
</Typography>
<Typography color="textPrimary" variant="body2">
{`s3://${folder.restricted?.S3BucketName || 'UNAUTHORIZED_INFO'}/${
folder.S3Prefix
}/`}
{`s3://${folder.restricted.S3BucketName}/${folder.S3Prefix}/`}
</Typography>
</CardContent>
<CardContent>
<Typography color="textSecondary" variant="subtitle2">
S3 ARN
</Typography>
<Typography color="textPrimary" variant="body2">
{`arn:aws:s3:::${
folder.restricted?.S3BucketName || 'UNAUTHORIZED_INFO'
}/${folder.S3Prefix}/`}
{`arn:aws:s3:::${folder.restricted.S3BucketName}/${folder.S3Prefix}/`}
</Typography>
</CardContent>
<CardContent>
<Typography color="textSecondary" variant="subtitle2">
Region
</Typography>
<Typography color="textPrimary" variant="body2">
{folder.restricted?.region || 'UNAUTHORIZED_INFO'}
{folder.restricted.region}
</Typography>
</CardContent>
<CardContent>
<Typography color="textSecondary" variant="subtitle2">
Account
</Typography>
<Typography color="textPrimary" variant="body2">
{folder.restricted?.AwsAccountId || 'UNAUTHORIZED_INFO'}
{folder.restricted.AwsAccountId}
</Typography>
</CardContent>
</Card>
Expand Down
55 changes: 24 additions & 31 deletions frontend/src/modules/S3_Datasets/components/DatasetConsoleAccess.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const DatasetConsoleAccess = (props) => {
Account
</Typography>
<Typography color="textPrimary" variant="body2">
{dataset.restricted?.AwsAccountId || 'UNAUTHORIZED_INFO'}
{dataset.restricted.AwsAccountId}
</Typography>
</CardContent>
<CardContent>
Expand All @@ -28,52 +28,45 @@ export const DatasetConsoleAccess = (props) => {
</Typography>
<Typography color="textPrimary" variant="body2">
arn:aws:s3:::
{dataset.restricted?.S3BucketName || 'UNAUTHORIZED_INFO'}
{dataset.restricted.S3BucketName}
</Typography>
</CardContent>
<CardContent>
<Typography color="textSecondary" variant="subtitle2">
Glue database
</Typography>
<Typography color="textPrimary" variant="body2">
{`arn:aws:glue:${dataset.restricted?.region || 'UNAUTHORIZED_INFO'}:${
dataset.restricted?.AwsAccountId || 'UNAUTHORIZED_INFO'
}/database:${
dataset.restricted?.GlueDatabaseName || 'UNAUTHORIZED_INFO'
}`}
{`arn:aws:glue:${dataset.restricted.region}:${dataset.restricted.AwsAccountId}/database:${dataset.restricted.GlueDatabaseName}`}
</Typography>
</CardContent>
<CardContent>
<Typography color="textSecondary" variant="subtitle2">
IAM role
</Typography>
<Typography color="textPrimary" variant="body2">
{dataset.restricted?.IAMDatasetAdminRoleArn || 'UNAUTHORIZED_INFO'}
{dataset.restricted.IAMDatasetAdminRoleArn}
</Typography>
</CardContent>
{dataset.restricted &&
(dataset.restricted?.KmsAlias === 'SSE-S3' ||
dataset.restricted?.KmsAlias === 'Undefined' ? (
<CardContent>
<Typography color="textSecondary" variant="subtitle2">
S3 Encryption
</Typography>
<Typography color="textPrimary" variant="body2">
{`${dataset.restricted?.KmsAlias || 'UNAUTHORIZED_INFO'}`}
</Typography>
</CardContent>
) : dataset.restricted?.KmsAlias !== '' ? (
<CardContent>
<Typography color="textSecondary" variant="subtitle2">
S3 Encryption SSE-KMS
</Typography>
<Typography color="textPrimary" variant="body2">
{`arn:aws:kms:${dataset.restricted.region}:${dataset.restricted.AwsAccountId}/alias:${dataset.restricted.KmsAlias}`}
</Typography>
</CardContent>
) : (
''
))}
{dataset.restricted.KmsAlias === 'SSE-S3' ||
dataset.restricted.KmsAlias === 'Undefined' ? (
<CardContent>
<Typography color="textSecondary" variant="subtitle2">
S3 Encryption
</Typography>
<Typography color="textPrimary" variant="body2">
{`${dataset.restricted.KmsAlias}`}
</Typography>
</CardContent>
) : (
<CardContent>
<Typography color="textSecondary" variant="subtitle2">
S3 Encryption SSE-KMS
</Typography>
<Typography color="textPrimary" variant="body2">
{`arn:aws:kms:${dataset.restricted.region}:${dataset.restricted.AwsAccountId}/alias:${dataset.restricted.KmsAlias}`}
</Typography>
</CardContent>
)}
</Card>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export const DatasetOverview = (props) => {
objectType="dataset"
/>
<Box sx={{ mt: 2 }}>
{isAdmin && <DatasetConsoleAccess dataset={dataset} />}
{isAdmin && dataset.restricted && (
<DatasetConsoleAccess dataset={dataset} />
)}
</Box>
</Grid>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ export const DatasetStartCrawlerModal = (props) => {
error={Boolean(touched.prefix && errors.prefix)}
fullWidth
helperText={touched.prefix && errors.prefix}
label={`s3://${
dataset.restricted?.S3BucketName ||
'UNAUTHORIZED_INFO'
}/`}
label={`s3://${dataset.restricted.S3BucketName}/`}
name="prefix"
onBlur={handleBlur}
onChange={handleChange}
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/modules/S3_Datasets/components/DatasetUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ export const DatasetUpload = (props) => {
<TextField
fullWidth
helperText="Prefix without trailing slash at the end (e.g raw not raw/)"
label={`s3://${
dataset.restricted?.S3BucketName || 'UNAUTHORIZED_INFO'
}/`}
label={`s3://${dataset.restricted.S3BucketName}/`}
name="label"
variant="outlined"
value={prefix}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/modules/S3_Datasets/views/DatasetEditForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ const DatasetEditForm = (props) => {
terms: dataset.terms || [],
stewards: dataset.stewards,
confidentiality: dataset.confidentiality,
KmsAlias: dataset.restricted?.KmsAlias || 'UNAUTHORIZED_INFO',
KmsAlias: dataset.restricted.KmsAlias,
autoApprovalEnabled: dataset.autoApprovalEnabled,
expirationSetting: dataset.expirySetting,
minValidity: dataset.expiryMinDuration,
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/modules/Worksheets/views/WorksheetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const WorksheetView = () => {
(d) => ({
...d,
value: d.datasetUri,
label: d.restricted?.GlueDatabaseName || 'UNAUTHORIZED_INFO'
label: d.restricted.GlueDatabaseName
})
);
}
Expand Down Expand Up @@ -198,7 +198,7 @@ const WorksheetView = () => {
response.data.getDataset.tables.nodes.map((t) => ({
...t,
value: t.tableUri,
label: t.restricted?.GlueTableName || 'UNAUTHORIZED_INFO'
label: t.restricted.GlueTableName
}))
);
} else {
Expand Down Expand Up @@ -381,7 +381,7 @@ const WorksheetView = () => {
setSqlBody(
`SELECT * FROM "${selectedDatabase.label}"."${
event.target.value.restricted
? event.target.value.restricted?.GlueTableName || 'UNAUTHORIZED_INFO'
? event.target.value.restricted.GlueTableName
: event.target.value.GlueTableName
}" limit 10;`
);
Expand Down

0 comments on commit 4b675f3

Please sign in to comment.