Skip to content

Commit

Permalink
Apply refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Ho <dxho@amazon.com>
  • Loading branch information
derek-ho committed Oct 27, 2023
1 parent 7cccfeb commit fff83f1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
EuiText,
EuiHorizontalRule,
EuiButton,
EuiFieldText,
} from '@elastic/eui';
import React, { useEffect, useState } from 'react';
import { EuiPanel } from '@elastic/eui';
Expand Down Expand Up @@ -99,7 +98,6 @@ export const AccessControlTab = (props: AccessControlTabProps) => {
<EuiButton
data-test-subj="createButton"
onClick={() => setMode(mode === 'view' ? 'edit' : 'view')}
fill={false}
>
{mode === 'view' ? 'Edit' : 'Cancel'}
</EuiButton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export const DataSourcePermissionsConfiguration = (props: {
];

const automaticallyCreateBackendRoleAndMapping = async () => {
await http!
.post(`/api/v1/configuration/roles/${backendRole}`, {
try {
await http!.post(`/api/v1/configuration/roles/${backendRole}`, {
body: JSON.stringify({
cluster_permissions: [],
index_permissions: [
Expand Down Expand Up @@ -71,29 +71,25 @@ export const DataSourcePermissionsConfiguration = (props: {
],
tenant_permissions: [],
}),
})
.then(() => {
setToast(`${backendRole} successfully created`);
})
.catch(() => {
setToast(
`Error in automatically creating ${backendRole}. Please proceed to security plugin to manually create this role.`
);
});
await http!
.post(`/api/v1/configuration/rolesmapping/${backendRole}`, {
setToast(`${backendRole} successfully created`);
} catch (err) {
setToast(
`Error in automatically creating ${backendRole}. Please proceed to security plugin to manually create this role.`
);
}
try {
await http!.post(`/api/v1/configuration/rolesmapping/${backendRole}`, {
body: JSON.stringify({
backend_roles: [`${props.properties['glue.auth.role_arn']}`],
}),
})
.then(() => {
setToast(`${backendRole} successfully mapped to ${props.properties['glue.auth.role_arn']}`);
})
.catch(() => {
setToast(
`Error in automatically mapping role_arn to ${backendRole}. Please proceed to security plugin to manually map the role_arn to the ${backendRole} role.`
);
});
setToast(`${backendRole} successfully mapped to ${props.properties['glue.auth.role_arn']}`);
} catch (err) {
setToast(
`Error in automatically mapping role_arn to ${backendRole}. Please proceed to security plugin to manually map the role_arn to the ${backendRole} role.`
);
}
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export const ReadPermissionsConfiguration = (props: { DataSourceName: string })
];

const automaticallyCreateReadRole = async () => {
await http!
.post(`/api/v1/configuration/roles/${readRole}`, {
try {
await http!.post(`/api/v1/configuration/roles/${readRole}`, {
body: JSON.stringify({
cluster_permissions: [],
index_permissions: [
Expand All @@ -50,15 +50,13 @@ export const ReadPermissionsConfiguration = (props: { DataSourceName: string })
],
tenant_permissions: [],
}),
})
.then(() => {
setToast(`${readRole} successfully created`);
})
.catch(() => {
setToast(
`Error in automatically creating ${readRole}. Please proceed to security plugin to manually create this role.`
);
});
setToast(`${readRole} successfully created`);
} catch (err) {
setToast(
`Error in automatically creating ${readRole}. Please proceed to security plugin to manually create this role.`
);
}
};

return (
Expand Down

0 comments on commit fff83f1

Please sign in to comment.