Skip to content

Commit 7aaa7eb

Browse files
committed
changed showCredentialsForm logic
It now properly resets activeApiTokenRawName, which was not being reset to the default when the credentials form was opened.
1 parent 2436463 commit 7aaa7eb

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_logic.test.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,9 @@ describe('CredentialsLogic', () => {
896896

897897
describe('activeApiTokenRawName', () => {
898898
it('should set `activeApiTokenRawName` to the name of the provided token', () => {
899-
mount();
899+
mount({
900+
activeApiTokenRawName: 'Some Name',
901+
});
900902

901903
CredentialsLogic.actions.showCredentialsForm(newToken);
902904
expect(CredentialsLogic.values).toEqual({
@@ -906,26 +908,16 @@ describe('CredentialsLogic', () => {
906908
});
907909

908910
it('should set `activeApiTokenRawName` to the default value if no token is provided', () => {
909-
mount();
911+
mount({
912+
activeApiTokenRawName: 'Some Name',
913+
});
910914

911915
CredentialsLogic.actions.showCredentialsForm();
912916
expect(CredentialsLogic.values).toEqual({
913917
...values,
914918
activeApiTokenRawName: DEFAULT_VALUES.activeApiTokenRawName,
915919
});
916920
});
917-
918-
// TODO: This fails, is this an issue? Instead of reseting back to the default value, it sets it to the previously
919-
// used value... to be honest, this should probably just be a selector
920-
// it('should set `activeApiTokenRawName` back to the default value if no token is provided', () => {
921-
// mount();
922-
// CredentialsLogic.actions.showCredentialsForm(newToken);
923-
// CredentialsLogic.actions.showCredentialsForm();
924-
// expect(CredentialsLogic.values).toEqual({
925-
// ...values,
926-
// activeApiTokenRawName: DEFAULT_VALUES.activeApiTokenRawName,
927-
// });
928-
// });
929921
});
930922

931923
describe('activeApiToken', () => {

x-pack/plugins/enterprise_search/public/applications/app_search/components/credentials/credentials_logic.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ export const CredentialsLogic = kea<
182182
'',
183183
{
184184
setTokenName: (_, activeApiTokenRawName) => activeApiTokenRawName,
185-
showCredentialsForm: (activeApiTokenRawName, activeApiToken) =>
186-
activeApiToken.name || activeApiTokenRawName,
185+
showCredentialsForm: (_, activeApiToken) => activeApiToken.name,
187186
hideCredentialsForm: () => '',
188187
onApiTokenCreateSuccess: () => '',
189188
onApiTokenUpdateSuccess: () => '',

0 commit comments

Comments
 (0)