Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dashboard): show correct roles for dashboard access dropdown #21549

Merged
merged 5 commits into from
Sep 26, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,23 +123,35 @@ const PropertiesModal = ({
};

const loadAccessOptions = useCallback(
(accessType = 'owners', input = '', page: number, pageSize: number) => {
(
accessType = 'owners',
input = '',
checkActive: boolean = true,
page: number,
pageSize: number,
) => {
const query = rison.encode({
filter: input,
page,
page_size: pageSize,
});
return SupersetClient.get({
endpoint: `/api/v1/dashboard/related/${accessType}?q=${query}`,
}).then(response => ({
data: response.json.result
.filter((item: { extra: { active: boolean } }) => item.extra.active)
mayurnewase marked this conversation as resolved.
Show resolved Hide resolved
.map((item: { value: number; text: string }) => ({
}).then(response => {
let data = response.json.result;
if (checkActive) {
data = data.filter(
(item: { extra: { active: boolean } }) => item.extra.active,
);
}
return {
data: data.map((item: { value: number; text: string }) => ({
value: item.value,
label: item.text,
})),
totalCount: response.json.count,
}));
totalCount: response.json.count,
};
});
},
[],
);
Expand Down Expand Up @@ -407,7 +419,7 @@ const PropertiesModal = ({
mode="multiple"
onChange={handleOnChangeOwners}
options={(input, page, pageSize) =>
loadAccessOptions('owners', input, page, pageSize)
loadAccessOptions('owners', input, true, page, pageSize)
}
value={handleOwnersSelectValue()}
/>
Expand Down Expand Up @@ -454,7 +466,7 @@ const PropertiesModal = ({
mode="multiple"
onChange={handleOnChangeOwners}
options={(input, page, pageSize) =>
loadAccessOptions('owners', input, page, pageSize)
loadAccessOptions('owners', input, true, page, pageSize)
}
value={handleOwnersSelectValue()}
/>
Expand All @@ -472,9 +484,10 @@ const PropertiesModal = ({
ariaLabel={t('Roles')}
disabled={isLoading}
mode="multiple"
labelInValue={true}
onChange={handleOnChangeRoles}
options={(input, page, pageSize) =>
loadAccessOptions('roles', input, page, pageSize)
loadAccessOptions('roles', input, false, page, pageSize)
}
value={handleRolesSelectValue()}
/>
Expand Down