Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
31 changes: 19 additions & 12 deletions client-app/src/admin/tests/viewmanager/ViewManagerTestModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {get} from 'lodash';
import {sampleGrid, SampleGridModel} from '../../../desktop/common';

export class ViewManagerTestModel extends HoistModel {
override telemetryPrefix = 'toolbox.client.viewManager';

@managed @observable.ref viewManagerModel: ViewManagerModel;

/** FormModel for model configs and component props. */
Expand Down Expand Up @@ -137,18 +139,23 @@ export class ViewManagerTestModel extends HoistModel {
initialViewName
} = data;

const newModel = await ViewManagerModel.createAsync({
type,
instance,
typeDisplayName,
globalDisplayName,
manageGlobal,
enableGlobal,
enableSharing,
enableDefault,
enableAutoSave,
initialViewSpec: views => views.find(v => v.name == initialViewName) ?? views[0]
});
const newModel = await this.rootSpan('testRebuild').run(ctx =>
ViewManagerModel.createAsync(
{
type,
instance,
typeDisplayName,
globalDisplayName,
manageGlobal,
enableGlobal,
enableSharing,
enableDefault,
enableAutoSave,
initialViewSpec: views => views.find(v => v.name == initialViewName) ?? views[0]
},
ctx
)
);

runInAction(() => {
this.viewManagerModel = newModel;
Expand Down
8 changes: 4 additions & 4 deletions client-app/src/core/AuthModel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {HoistAuthModel, IdentityInfo, managed, PlainObject, XH} from '@xh/hoist/core';
import {CallContext, HoistAuthModel, IdentityInfo, managed, PlainObject, XH} from '@xh/hoist/core';
import {AuthZeroClient, AuthZeroClientConfig} from '@xh/hoist/security/authzero';
import {MsalClient, MsalClientConfig} from '@xh/hoist/security/msal';

Expand All @@ -13,7 +13,7 @@ export class AuthModel extends HoistAuthModel {
@managed
client: AuthZeroClient | MsalClient;

override async completeAuthAsync(): Promise<IdentityInfo> {
override async completeAuthAsync(ctx: CallContext): Promise<IdentityInfo> {
this.setMaskMsg('Authenticating...');

// Toolbox's server-provided configuration allows for OAuth to be disabled entirely, falling back to a username
Expand All @@ -26,7 +26,7 @@ export class AuthModel extends HoistAuthModel {
// then return the result of the server-based auth check - will be false if the user does not have an
// active session, at which point the Hoist login form will be displayed.
XH.appSpec.enableLoginForm = true;
const ret = await this.getAuthStatusFromServerAsync();
const ret = await this.getAuthStatusFromServerAsync(ctx);
this.setMaskMsg(null);
return ret;
}
Expand Down Expand Up @@ -63,7 +63,7 @@ export class AuthModel extends HoistAuthModel {
// installed above, which will be read and validated by Toolbox's server-side implementation of
// `AuthenticationService.completeAuthentication()`. Toolbox is unusual in that it is a deliberately open site
// and will create an account on the fly for any new user, so we expect this request to always return true.
const ret = await this.getAuthStatusFromServerAsync();
const ret = await this.getAuthStatusFromServerAsync(ctx);
this.setMaskMsg(null);
return ret;
}
Expand Down
19 changes: 11 additions & 8 deletions client-app/src/core/svc/DocService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface DocSearchResult {
* DocsService API. Maintains a MiniSearch full-text index for ranked search.
*/
export class DocService extends HoistService {
override telemetryPrefix = 'toolbox.client.docs';

static instance: DocService;

@observable indexReady: boolean = false;
Expand Down Expand Up @@ -89,14 +91,15 @@ export class DocService extends HoistService {
const cached = this.cache.get(cacheKey);
if (cached) return cached;

const resp = await this.newSpan('toolbox.client.docs.getContent').fetchJson({
url: 'docs/content',
params: {source, docId}
return this.rootSpan('getContent').run(async ctx => {
const resp = await ctx.fetchJson({
url: 'docs/content',
params: {source, docId}
});
const content = resp.content;
this.cache.set(cacheKey, content);
return content;
});

const content = resp.content;
this.cache.set(cacheKey, content);
return content;
}

/**
Expand Down Expand Up @@ -141,7 +144,7 @@ export class DocService extends HoistService {
// Implementation
//------------------
private async loadRegistryAsync() {
return this.newSpan('toolbox.client.docs.loadRegistry').run(async ctx => {
return this.rootSpan('loadRegistry').run(async ctx => {
const resp = await ctx.fetchJson({url: 'docs/registry'});
const sourceCount = Object.keys(resp.sources).length;

Expand Down
58 changes: 30 additions & 28 deletions client-app/src/core/svc/GitHubService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface Commit {
}

export class GitHubService extends HoistService {
override telemetryPrefix = 'toolbox.client.github';

static instance: GitHubService;

/** Loaded commits histories, keyed by repoName. */
Expand Down Expand Up @@ -58,37 +60,37 @@ export class GitHubService extends HoistService {
}

override async doLoadAsync(loadSpec: LoadSpec) {
try {
const priorCommitCount = this.allCommits.length,
commitHistories = await this.runner(loadSpec)
.newSpan('toolbox.client.github.allCommits')
.track('Loaded GitHub commit history')
.fetchJson({url: 'gitHub/allCommits'});
await this.runOn(loadSpec)
.newSpan('allCommits')
.withTrack('Loaded GitHub commit history')
.run(async ctx => {
const priorCommitCount = this.allCommits.length,
commitHistories = await ctx.fetchJson({url: 'gitHub/allCommits'});

forOwn(commitHistories, v => {
// Minor translations here on client for convenience.
v.commits.forEach(it => {
it.authorEmail = it.author.email;
it.authorName = it.author.name || it.authorEmail;
it.committedDate = new Date(it.committedDate);
it.committedDay = LocalDate.from(it.committedDate);
it.isRelease =
it.authorEmail === '[email protected]' && it.messageHeadline.startsWith('v');
forOwn(commitHistories, v => {
// Minor translations here on client for convenience.
v.commits.forEach(it => {
it.authorEmail = it.author.email;
it.authorName = it.author.name || it.authorEmail;
it.committedDate = new Date(it.committedDate);
it.committedDay = LocalDate.from(it.committedDate);
it.isRelease =
it.authorEmail === '[email protected]' &&
it.messageHeadline.startsWith('v');
});
});
});

runInAction(() => (this.commitHistories = commitHistories));
runInAction(() => (this.commitHistories = commitHistories));

const newCommitCount = this.allCommits.length;
if (priorCommitCount && newCommitCount > priorCommitCount) {
XH.toast({
message: 'New Hoist commit detected!',
icon: Icon.icon({iconName: 'github', prefix: 'fab'}),
intent: 'primary'
});
}
} catch (e) {
XH.handleException(e, {showAlert: false, showAsError: false});
}
const newCommitCount = this.allCommits.length;
if (priorCommitCount && newCommitCount > priorCommitCount) {
XH.toast({
message: 'New Hoist commit detected!',
icon: Icon.icon({iconName: 'github', prefix: 'fab'}),
intent: 'primary'
});
}
})
.catch(e => XH.handleException(e, {showAlert: false, showAsError: false}));
}
}
Loading
Loading