mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
This reverts commit 22a427f934.
This commit is contained in:
@@ -7,7 +7,6 @@ import * as azdata from 'azdata';
|
||||
import { AccountAdditionResult } from 'sql/platform/accounts/common/eventTypes';
|
||||
import { IAccountStore } from 'sql/platform/accounts/common/interfaces';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
export default class AccountStore implements IAccountStore {
|
||||
// CONSTANTS ///////////////////////////////////////////////////////////
|
||||
@@ -24,7 +23,7 @@ export default class AccountStore implements IAccountStore {
|
||||
return this.readFromMemento()
|
||||
.then(accounts => {
|
||||
// Determine if account exists and proceed accordingly
|
||||
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, newAccount.key));
|
||||
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, newAccount.key));
|
||||
return match < 0
|
||||
? this.addToAccountList(accounts, newAccount)
|
||||
: this.updateAccountList(accounts, newAccount.key, matchAccount => AccountStore.mergeAccounts(newAccount, matchAccount));
|
||||
@@ -101,7 +100,7 @@ export default class AccountStore implements IAccountStore {
|
||||
|
||||
private addToAccountList(accounts: azdata.Account[], accountToAdd: azdata.Account): AccountListOperationResult {
|
||||
// Check if the entry already exists
|
||||
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, accountToAdd.key));
|
||||
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, accountToAdd.key));
|
||||
if (match >= 0) {
|
||||
// Account already exists, we won't do anything
|
||||
return {
|
||||
@@ -126,7 +125,7 @@ export default class AccountStore implements IAccountStore {
|
||||
|
||||
private removeFromAccountList(accounts: azdata.Account[], accountToRemove: azdata.AccountKey): AccountListOperationResult {
|
||||
// Check if the entry exists
|
||||
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, accountToRemove));
|
||||
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, accountToRemove));
|
||||
if (match >= 0) {
|
||||
// Account exists, remove it from the account list
|
||||
accounts.splice(match, 1);
|
||||
@@ -143,7 +142,7 @@ export default class AccountStore implements IAccountStore {
|
||||
|
||||
private updateAccountList(accounts: azdata.Account[], accountToUpdate: azdata.AccountKey, updateOperation: (account: azdata.Account) => void): AccountListOperationResult {
|
||||
// Check if the entry exists
|
||||
const match = firstIndex(accounts, account => AccountStore.findAccountByKey(account.key, accountToUpdate));
|
||||
const match = accounts.findIndex(account => AccountStore.findAccountByKey(account.key, accountToUpdate));
|
||||
if (match < 0) {
|
||||
// Account doesn't exist, we won't do anything
|
||||
return {
|
||||
|
||||
@@ -20,7 +20,7 @@ export interface IAccountManagementService {
|
||||
addAccount(providerId: string): Thenable<void>;
|
||||
getAccountProviderMetadata(): Thenable<azdata.AccountProviderMetadata[]>;
|
||||
getAccountsForProvider(providerId: string): Thenable<azdata.Account[]>;
|
||||
getSecurityToken(account: azdata.Account, resource: azdata.AzureResource): Thenable<{ [key: string]: { token: string } }>;
|
||||
getSecurityToken(account: azdata.Account, resource: azdata.AzureResource): Thenable<{}>;
|
||||
removeAccount(accountKey: azdata.AccountKey): Thenable<boolean>;
|
||||
refreshAccount(account: azdata.Account): Thenable<azdata.Account>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user