mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-30 01:25:38 -05:00
Show user email address in account picker (#5015)
* Show user email address in account picker * Fix build break and remove Azure account from sqlops namespace
This commit is contained in:
7
src/sql/azdata.proposed.d.ts
vendored
7
src/sql/azdata.proposed.d.ts
vendored
@@ -2055,9 +2055,14 @@ declare module 'azdata' {
|
||||
accountType: string;
|
||||
|
||||
/**
|
||||
* A display name that identifies the account, such as "user@contoso.com".
|
||||
* A display name that identifies the account, such as "User Name".
|
||||
*/
|
||||
displayName: string;
|
||||
|
||||
/**
|
||||
* User id that identifies the account, such as "user@contoso.com".
|
||||
*/
|
||||
userId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -69,7 +69,14 @@ export class AccountPickerListRenderer implements IListRenderer<azdata.Account,
|
||||
templateData.icon.classList.add('account-logo', account.displayInfo.accountType);
|
||||
|
||||
templateData.contextualDisplayName.innerText = account.displayInfo.contextualDisplayName;
|
||||
templateData.displayName.innerText = account.displayInfo.displayName;
|
||||
|
||||
// show the account display name text, something like "User Name (user@email.com)"
|
||||
if (account.displayInfo.userId && account.displayInfo.displayName) {
|
||||
templateData.displayName.innerText = account.displayInfo.displayName + ' (' + account.displayInfo.userId + ')';
|
||||
} else {
|
||||
templateData.displayName.innerText = account.displayInfo.displayName ;
|
||||
}
|
||||
|
||||
if (account.isStale) {
|
||||
templateData.badgeContent.className = 'badge-content icon warning-badge';
|
||||
} else {
|
||||
|
||||
258
src/sql/sqlops.d.ts
vendored
258
src/sql/sqlops.d.ts
vendored
@@ -1994,269 +1994,11 @@ declare module 'sqlops' {
|
||||
message: string;
|
||||
}
|
||||
|
||||
// ACCOUNT MANAGEMENT //////////////////////////////////////////////////
|
||||
export namespace accounts {
|
||||
export function registerAccountProvider(providerMetadata: AccountProviderMetadata, provider: AccountProvider): vscode.Disposable;
|
||||
|
||||
/**
|
||||
* Launches a flyout dialog that will display the information on how to complete device
|
||||
* code OAuth login to the user. Only one flyout can be opened at once and each must be closed
|
||||
* by calling {@link endAutoOAuthDeviceCode}.
|
||||
* @param {string} providerId ID of the provider that's requesting the flyout be opened
|
||||
* @param {string} title
|
||||
* @param {string} message
|
||||
* @param {string} userCode
|
||||
* @param {string} uri
|
||||
*/
|
||||
export function beginAutoOAuthDeviceCode(providerId: string, title: string, message: string, userCode: string, uri: string): Thenable<void>;
|
||||
|
||||
/**
|
||||
* Closes the flyout dialog opened by {@link beginAutoOAuthDeviceCode}
|
||||
*/
|
||||
export function endAutoOAuthDeviceCode(): void;
|
||||
|
||||
/**
|
||||
* Notifies the account management service that an account has updated (usually due to the
|
||||
* account going stale).
|
||||
* @param {Account} updatedAccount Account object with updated properties
|
||||
*/
|
||||
export function accountUpdated(updatedAccount: Account): void;
|
||||
|
||||
/**
|
||||
* Gets all added accounts.
|
||||
* @returns {Thenable<Account>} Promise to return the accounts
|
||||
*/
|
||||
export function getAllAccounts(): Thenable<Account[]>;
|
||||
|
||||
/**
|
||||
* Generates a security token by asking the account's provider
|
||||
* @param {Account} account Account to generate security token for (defaults to
|
||||
* AzureResource.ResourceManagement if not given)
|
||||
* @return {Thenable<{}>} Promise to return the security token
|
||||
*/
|
||||
export function getSecurityToken(account: Account, resource?: AzureResource): Thenable<{}>;
|
||||
|
||||
/**
|
||||
* An [event](#Event) which fires when the accounts have changed.
|
||||
*/
|
||||
export const onDidChangeAccounts: vscode.Event<DidChangeAccountsParams>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents display information for an account.
|
||||
*/
|
||||
export interface AccountDisplayInfo {
|
||||
/**
|
||||
* A display name that offers context for the account, such as "Contoso".
|
||||
*/
|
||||
contextualDisplayName: string;
|
||||
|
||||
/**
|
||||
* account provider (eg, Work/School vs Microsoft Account)
|
||||
*/
|
||||
accountType: string;
|
||||
|
||||
/**
|
||||
* A display name that identifies the account, such as "user@contoso.com".
|
||||
*/
|
||||
displayName: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a key that identifies an account.
|
||||
*/
|
||||
export interface AccountKey {
|
||||
/**
|
||||
* Identifier of the provider
|
||||
*/
|
||||
providerId: string;
|
||||
|
||||
/**
|
||||
* Any arguments that identify an instantiation of the provider
|
||||
*/
|
||||
providerArgs?: any;
|
||||
|
||||
/**
|
||||
* Identifier for the account, unique to the provider
|
||||
*/
|
||||
accountId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents an account.
|
||||
*/
|
||||
export interface Account {
|
||||
/**
|
||||
* The key that identifies the account
|
||||
*/
|
||||
key: AccountKey;
|
||||
|
||||
/**
|
||||
* Display information for the account
|
||||
*/
|
||||
displayInfo: AccountDisplayInfo;
|
||||
|
||||
/**
|
||||
* Custom properties stored with the account
|
||||
*/
|
||||
properties: any;
|
||||
|
||||
/**
|
||||
* Indicates if the account needs refreshing
|
||||
*/
|
||||
isStale: boolean;
|
||||
}
|
||||
|
||||
export enum AzureResource {
|
||||
ResourceManagement = 0,
|
||||
Sql = 1
|
||||
}
|
||||
|
||||
export interface DidChangeAccountsParams {
|
||||
// Updated accounts
|
||||
accounts: Account[];
|
||||
}
|
||||
|
||||
// - ACCOUNT PROVIDER //////////////////////////////////////////////////
|
||||
/**
|
||||
* Error to be used when the user has cancelled the prompt or refresh methods. When
|
||||
* AccountProvider.refresh or AccountProvider.prompt are rejected with this error, the error
|
||||
* will not be reported to the user.
|
||||
*/
|
||||
export interface UserCancelledSignInError extends Error {
|
||||
/**
|
||||
* Type guard for differentiating user cancelled sign in errors from other errors
|
||||
*/
|
||||
userCancelledSignIn: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a provider of accounts.
|
||||
*/
|
||||
export interface AccountProviderMetadata {
|
||||
/**
|
||||
* The identifier of the provider
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Display name of the provider
|
||||
*/
|
||||
displayName: string;
|
||||
|
||||
/**
|
||||
* Any arguments that identify an instantiation of the provider
|
||||
*/
|
||||
args?: any;
|
||||
|
||||
/**
|
||||
* Optional settings that identify an instantiation of a provider
|
||||
*/
|
||||
settings?: {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a provider of accounts for use with the account management service
|
||||
*/
|
||||
export interface AccountProvider {
|
||||
/**
|
||||
* Initializes the account provider with the accounts restored from the memento,
|
||||
* @param {Account[]} storedAccounts Accounts restored from the memento
|
||||
* @return {Thenable<Account[]>} Account objects after being rehydrated (if necessary)
|
||||
*/
|
||||
initialize(storedAccounts: Account[]): Thenable<Account[]>;
|
||||
|
||||
/**
|
||||
* Generates a security token for the provided account
|
||||
* @param {Account} account The account to generate a security token for
|
||||
* @param {AzureResource} resource The resource to get the token for
|
||||
* @return {Thenable<{}>} Promise to return a security token object
|
||||
*/
|
||||
getSecurityToken(account: Account, resource: AzureResource): Thenable<{}>;
|
||||
|
||||
/**
|
||||
* Prompts the user to enter account information.
|
||||
* Returns an error if the user canceled the operation.
|
||||
*/
|
||||
prompt(): Thenable<Account>;
|
||||
|
||||
/**
|
||||
* Refreshes a stale account.
|
||||
* Returns an error if the user canceled the operation.
|
||||
* Otherwise, returns a new updated account instance.
|
||||
* @param account - An account.
|
||||
*/
|
||||
refresh(account: Account): Thenable<Account>;
|
||||
|
||||
/**
|
||||
* Clears sensitive information for an account. To be called when account is removed
|
||||
* @param accountKey - Key that uniquely identifies the account to clear
|
||||
*/
|
||||
clear(accountKey: AccountKey): Thenable<void>;
|
||||
|
||||
/**
|
||||
* Called from the account management service when the user has cancelled an auto OAuth
|
||||
* authorization process. Implementations should use this to cancel any polling process
|
||||
* and call the end OAuth method.
|
||||
*/
|
||||
autoOAuthCancelled(): Thenable<void>;
|
||||
}
|
||||
|
||||
// Resource provider interfaces -----------------------------------------------------------------------
|
||||
|
||||
// - ACCOUNT PROVIDER //////////////////////////////////////////////////
|
||||
/**
|
||||
* Represents a provider of accounts.
|
||||
*/
|
||||
export interface ResourceProviderMetadata {
|
||||
/**
|
||||
* The identifier of the provider
|
||||
*/
|
||||
id: string;
|
||||
|
||||
/**
|
||||
* Display name of the provider
|
||||
*/
|
||||
displayName: string;
|
||||
|
||||
/**
|
||||
* Optional settings that identify an instantiation of a provider
|
||||
*/
|
||||
settings?: {};
|
||||
}
|
||||
|
||||
export namespace resources {
|
||||
/**
|
||||
* Registers a resource provider that can suport
|
||||
*/
|
||||
export function registerResourceProvider(providerMetadata: ResourceProviderMetadata, provider: ResourceProvider): vscode.Disposable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a provider of resource
|
||||
*/
|
||||
export interface ResourceProvider {
|
||||
createFirewallRule(account: Account, firewallruleInfo: FirewallRuleInfo): Thenable<CreateFirewallRuleResponse>;
|
||||
handleFirewallRule(errorCode: number, errorMessage: string, connectionTypeId: string): Thenable<HandleFirewallRuleResponse>;
|
||||
}
|
||||
|
||||
export interface FirewallRuleInfo {
|
||||
startIpAddress: string;
|
||||
endIpAddress: string;
|
||||
serverName: string;
|
||||
securityTokenMappings: {};
|
||||
}
|
||||
|
||||
export interface CreateFirewallRuleResponse {
|
||||
result: boolean;
|
||||
errorMessage: string;
|
||||
}
|
||||
|
||||
export interface HandleFirewallRuleResponse {
|
||||
result: boolean;
|
||||
ipAddress: string;
|
||||
}
|
||||
|
||||
export interface ModalDialog {
|
||||
/**
|
||||
* Title of the webview.
|
||||
|
||||
@@ -531,30 +531,6 @@ export function createApiFactory(
|
||||
|
||||
// "sqlops" namespace provided for back-compat only, add new interfaces to "azdata"
|
||||
sqlopsFactory: function (extension: IExtensionDescription): typeof sqlops {
|
||||
// namespace: accounts
|
||||
const accounts: typeof sqlops.accounts = {
|
||||
registerAccountProvider(providerMetadata: sqlops.AccountProviderMetadata, provider: sqlops.AccountProvider): vscode.Disposable {
|
||||
return extHostAccountManagement.$registerAccountProvider(providerMetadata, provider);
|
||||
},
|
||||
beginAutoOAuthDeviceCode(providerId: string, title: string, message: string, userCode: string, uri: string): Thenable<void> {
|
||||
return extHostAccountManagement.$beginAutoOAuthDeviceCode(providerId, title, message, userCode, uri);
|
||||
},
|
||||
endAutoOAuthDeviceCode(): void {
|
||||
return extHostAccountManagement.$endAutoOAuthDeviceCode();
|
||||
},
|
||||
accountUpdated(updatedAccount: sqlops.Account): void {
|
||||
return extHostAccountManagement.$accountUpdated(updatedAccount);
|
||||
},
|
||||
getAllAccounts(): Thenable<sqlops.Account[]> {
|
||||
return extHostAccountManagement.$getAllAccounts();
|
||||
},
|
||||
getSecurityToken(account: sqlops.Account, resource?: sqlops.AzureResource): Thenable<{}> {
|
||||
return extHostAccountManagement.$getSecurityToken(account, resource);
|
||||
},
|
||||
onDidChangeAccounts(listener: (e: sqlops.DidChangeAccountsParams) => void, thisArgs?: any, disposables?: extHostTypes.Disposable[]) {
|
||||
return extHostAccountManagement.onDidChangeAccounts(listener, thisArgs, disposables);
|
||||
}
|
||||
};
|
||||
|
||||
// namespace: connection
|
||||
const connection: typeof sqlops.connection = {
|
||||
@@ -623,12 +599,6 @@ export function createApiFactory(
|
||||
},
|
||||
};
|
||||
|
||||
// namespace: serialization
|
||||
const resources: typeof sqlops.resources = {
|
||||
registerResourceProvider(providerMetadata: sqlops.ResourceProviderMetadata, provider: sqlops.ResourceProvider): vscode.Disposable {
|
||||
return extHostResourceProvider.$registerResourceProvider(providerMetadata, provider);
|
||||
}
|
||||
};
|
||||
|
||||
let registerConnectionProvider = (provider: sqlops.ConnectionProvider): vscode.Disposable => {
|
||||
// Connection callbacks
|
||||
@@ -955,11 +925,9 @@ export function createApiFactory(
|
||||
};
|
||||
|
||||
return {
|
||||
accounts,
|
||||
connection,
|
||||
credentials,
|
||||
objectexplorer: objectExplorer,
|
||||
resources,
|
||||
serialization,
|
||||
dataprotocol,
|
||||
DataProviderType: sqlExtHostTypes.DataProviderType,
|
||||
|
||||
Reference in New Issue
Block a user