Skip to content

Commit

Permalink
Finalizes changes for Permissions tab dataSource picker
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
  • Loading branch information
DarshitChanpura committed Mar 27, 2024
1 parent dc84da4 commit 00989ba
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ interface PermissionEditModalDeps {
groupName: string;
action: Action;
allowedActions: string[];
dataSourceId: string;
optionUniverse: ComboBoxOptions;
handleClose: () => void;
handleSave: (groupName: string, allowedActions: string[]) => Promise<void>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ export function PermissionList(props: AppDependencies) {
const handleDelete = async () => {
const groupsToDelete: string[] = selection.map((r) => r.name);
try {
await requestDeleteActionGroups(props.coreStart.http, groupsToDelete);
await requestDeleteActionGroups(
props.coreStart.http,
groupsToDelete,
createDataSourceQuery(dataSource.id)
);
setPermissionList(difference(permissionList, selection));
setSelection([]);
} catch (e) {
Expand Down Expand Up @@ -287,13 +291,17 @@ export function PermissionList(props: AppDependencies) {
groupName={initialGroupName}
action={action}
allowedActions={initialAllowedAction}
dataSourceId={dataSource.id}
optionUniverse={permissionList.map((group) => stringToComboBoxOption(group.name))}
handleClose={() => setEditModal(null)}
handleSave={async (groupName, allowedAction) => {
try {
await updateActionGroup(props.coreStart.http, groupName, {
allowed_actions: allowedAction,
});
await updateActionGroup(
props.coreStart.http,
groupName,
{ allowed_actions: allowedAction },
createDataSourceQuery(dataSource.id)
);
setEditModal(null);
fetchData();
addToast({
Expand Down Expand Up @@ -345,7 +353,7 @@ export function PermissionList(props: AppDependencies) {
<>
<SecurityPluginTopNavMenu
{...props}
dataSourcePickerReadOnly={true}
dataSourcePickerReadOnly={false}
setDataSource={setDataSource}
selectedDataSource={dataSource}
/>
Expand Down
12 changes: 9 additions & 3 deletions public/apps/configuration/utils/action-groups-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,23 @@ export async function mergeAllPermissions(
export async function updateActionGroup(
http: HttpStart,
groupName: string,
updateObject: ActionGroupUpdate
updateObject: ActionGroupUpdate,
query: HttpFetchQuery
): Promise<ActionGroupUpdate> {
return await httpPost({
http,
url: getResourceUrl(API_ENDPOINT_ACTIONGROUPS, groupName),
body: updateObject,
query,
});
}

export async function requestDeleteActionGroups(http: HttpStart, groups: string[]) {
export async function requestDeleteActionGroups(
http: HttpStart,
groups: string[],
query: HttpFetchQuery
) {
for (const group of groups) {
await httpDelete({ http, url: getResourceUrl(API_ENDPOINT_ACTIONGROUPS, group) });
await httpDelete({ http, url: getResourceUrl(API_ENDPOINT_ACTIONGROUPS, group), query });
}
}

0 comments on commit 00989ba

Please sign in to comment.