Skip to content

Commit

Permalink
[PR feedback] Reuse fullEngineAccessChecked, fix fullEngineAccessChec…
Browse files Browse the repository at this point in the history
…ked being undefined vs a bool
  • Loading branch information
cee-chen committed Oct 22, 2020
1 parent b34d730 commit 2b200a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe('CredentialsLogic', () => {
meta: {},
nameInputBlurred: false,
shouldShowCredentialsForm: false,
fullEngineAccessChecked: false,
};

const mount = (defaults?: object) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ export const CredentialsLogic = kea<
selectors: ({ selectors }) => ({
fullEngineAccessChecked: [
() => [AppLogic.selectors.myRole, selectors.activeApiToken],
(myRole, activeApiToken) => myRole.canAccessAllEngines && !!activeApiToken.access_all_engines,
(myRole, activeApiToken) =>
!!(myRole.canAccessAllEngines && activeApiToken.access_all_engines),
],
dataLoading: [
() => [selectors.isCredentialsDetailsComplete, selectors.isCredentialsDataComplete],
Expand Down Expand Up @@ -264,16 +265,7 @@ export const CredentialsLogic = kea<
}
},
onApiTokenChange: async () => {
const { myRole } = AppLogic.values;
const {
id,
name,
engines,
type,
read,
write,
access_all_engines: accessAllEngines,
} = values.activeApiToken;
const { id, name, engines, type, read, write } = values.activeApiToken;

const data: IApiToken = {
name,
Expand All @@ -284,7 +276,7 @@ export const CredentialsLogic = kea<
data.write = write;
}
if (type !== ApiTokenTypes.Admin) {
data.access_all_engines = !!(accessAllEngines && myRole.canAccessAllEngines);
data.access_all_engines = values.fullEngineAccessChecked;
data.engines = engines;
}

Expand Down

0 comments on commit 2b200a0

Please sign in to comment.