Skip to content

Commit 19f5f70

Browse files
authored
Merge branch 'main' into actually-test-packaged-app
2 parents c269d98 + 074292b commit 19f5f70

File tree

21 files changed

+106
-72
lines changed

21 files changed

+106
-72
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,4 @@ Ruchitha Rajaghatta <[email protected]>
9595
9696
Nikola Irinchev <[email protected]>
9797
djechlin-mongodb <[email protected]>
98+
Dylan Richardson <[email protected]>

docs/tracking-plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Compass Tracking Plan
33

4-
Generated on Mon, Dec 9, 2024 at 02:09 PM
4+
Generated on Mon, Dec 9, 2024 at 06:45 PM
55

66
## Table of Contents
77

package-lock.json

Lines changed: 23 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/atlas-service/src/atlas-auth-service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { AtlasUserInfo } from './util';
44
export type ArgsWithSignal<T = Record<string, unknown>> = T & {
55
signal?: AbortSignal;
66
};
7-
export type SignInPrompt = 'none';
87

98
type AtlasAuthServiceEvents = {
109
'signed-in': [];
@@ -19,7 +18,7 @@ type AtlasAuthEventListener<T extends AtlasAuthEventNames> = (
1918

2019
export abstract class AtlasAuthService extends EventEmitter {
2120
abstract signIn(
22-
opts?: ArgsWithSignal<{ promptType?: SignInPrompt }>
21+
opts?: ArgsWithSignal<{ mainProcessSignIn?: boolean }>
2322
): Promise<AtlasUserInfo>;
2423
abstract signOut(): Promise<void>;
2524
abstract isAuthenticated(opts?: ArgsWithSignal): Promise<boolean>;

packages/atlas-service/src/compass-atlas-auth-service.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ describe('CompassAtlasAuthService', function () {
4343
const atlasAuthService = getAtlasAuthService({
4444
signIn: signInStub,
4545
});
46-
await atlasAuthService.signIn({ signal: c.signal });
46+
await atlasAuthService.signIn({
47+
mainProcessSignIn: true,
48+
signal: c.signal,
49+
});
4750
expect(signInStub.calledOnce).to.be.true;
4851
expect(signInStub.firstCall.firstArg).to.deep.equal({ signal: c.signal });
4952
});

packages/atlas-service/src/compass-atlas-auth-service.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { ipcRenderer } from 'hadron-ipc';
22
import type { CompassAuthService as AtlasServiceMain } from './main';
3-
import { signInWithoutPrompt } from './store/atlas-signin-reducer';
3+
import { performSignInAttempt } from './store/atlas-signin-reducer';
44
import { getStore } from './store/atlas-signin-store';
55
import { AtlasAuthService } from './atlas-auth-service';
6-
import type { ArgsWithSignal, SignInPrompt } from './atlas-auth-service';
6+
import type { ArgsWithSignal } from './atlas-auth-service';
77

88
export class CompassAtlasAuthService extends AtlasAuthService {
99
private _ipc = ipcRenderer?.createInvoke<
@@ -37,15 +37,14 @@ export class CompassAtlasAuthService extends AtlasAuthService {
3737
return this.ipc.signOut();
3838
}
3939
signIn({
40-
promptType,
40+
mainProcessSignIn,
4141
signal,
42-
}: ArgsWithSignal<{ promptType?: SignInPrompt }> = {}) {
43-
switch (promptType) {
44-
case 'none':
45-
return getStore().dispatch(signInWithoutPrompt({ signal }));
46-
default:
47-
return this.ipc.signIn({ signal });
42+
}: ArgsWithSignal<{ mainProcessSignIn?: boolean }> = {}) {
43+
if (mainProcessSignIn) {
44+
return this.ipc.signIn({ signal });
4845
}
46+
47+
return getStore().dispatch(performSignInAttempt({ signal }));
4948
}
5049
getUserInfo(opts?: ArgsWithSignal) {
5150
return this.ipc.getUserInfo(opts);

packages/atlas-service/src/store/atlas-signin-reducer.spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
cancelSignIn,
66
attemptId,
77
AttemptStateMap,
8-
signInWithoutPrompt,
8+
performSignInAttempt,
99
} from './atlas-signin-reducer';
1010
import { expect } from 'chai';
1111
import { configureStore } from './atlas-signin-store';
@@ -174,7 +174,7 @@ describe('atlasSignInReducer', function () {
174174
atlasAuthService: mockAtlasService as any,
175175
});
176176

177-
void store.dispatch(signInWithoutPrompt()).catch(() => {});
177+
void store.dispatch(performSignInAttempt()).catch(() => {});
178178

179179
await Promise.all([
180180
store.dispatch(signIn()),
@@ -184,7 +184,7 @@ describe('atlasSignInReducer', function () {
184184
});
185185
});
186186

187-
describe('signInWithoutPrompt', function () {
187+
describe('performSignInAttempt', function () {
188188
it('should resolve when sign in flow finishes', async function () {
189189
const mockAtlasService = {
190190
isAuthenticated: sandbox.stub().resolves(false),
@@ -195,7 +195,7 @@ describe('atlasSignInReducer', function () {
195195
const store = configureStore({
196196
atlasAuthService: mockAtlasService as any,
197197
});
198-
await store.dispatch(signInWithoutPrompt());
198+
await store.dispatch(performSignInAttempt());
199199
expect(store.getState()).to.have.property('state', 'success');
200200
});
201201

@@ -210,8 +210,8 @@ describe('atlasSignInReducer', function () {
210210
atlasAuthService: mockAtlasService as any,
211211
});
212212
try {
213-
await store.dispatch(signInWithoutPrompt());
214-
expect.fail('Expected signInWithoutPrompt action to throw');
213+
await store.dispatch(performSignInAttempt());
214+
expect.fail('Expected performSignInAttempt action to throw');
215215
} catch (err) {
216216
expect(err).to.have.property('message', 'Sign in failed');
217217
}
@@ -237,7 +237,7 @@ describe('atlasSignInReducer', function () {
237237
});
238238
const c = new AbortController();
239239
const signInPromise = store.dispatch(
240-
signInWithoutPrompt({ signal: c.signal })
240+
performSignInAttempt({ signal: c.signal })
241241
);
242242
c.abort(new Error('Aborted from outside'));
243243
try {

packages/atlas-service/src/store/atlas-signin-reducer.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ const startAttempt = (fn: () => void): AtlasSignInThunkAction<AttemptState> => {
308308
};
309309
};
310310

311-
export const signInWithoutPrompt = ({
311+
export const performSignInAttempt = ({
312312
signal,
313313
}: { signal?: AbortSignal } = {}): AtlasSignInThunkAction<
314314
Promise<AtlasUserInfo>
@@ -348,7 +348,10 @@ export const signIn = (): AtlasSignInThunkAction<Promise<void>> => {
348348
if (await atlasAuthService.isAuthenticated({ signal })) {
349349
userInfo = await atlasAuthService.getUserInfo({ signal });
350350
} else {
351-
userInfo = await atlasAuthService.signIn({ signal });
351+
userInfo = await atlasAuthService.signIn({
352+
mainProcessSignIn: true,
353+
signal,
354+
});
352355
}
353356
openToast('atlas-sign-in-success', {
354357
variant: 'success',

packages/compass-components/src/components/document-list/element-editors.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export const KeyEditor: React.FunctionComponent<{
8282
enabled={!valid}
8383
trigger={({
8484
className,
85+
children,
8586
// Having a tooltip connected to the input elements is not the most
8687
// accessible thing ever and so a lot of event listeners of the
8788
// tooltip conflict with the textarea default behavior (due to
@@ -93,6 +94,8 @@ export const KeyEditor: React.FunctionComponent<{
9394
onPointerUp,
9495
onPointerDown,
9596
onMouseDown,
97+
/* eslint-enable @typescript-eslint/no-unused-vars */
98+
...triggerProps
9699
}: React.HTMLProps<HTMLInputElement>) => {
97100
return (
98101
<div className={className}>
@@ -118,7 +121,9 @@ export const KeyEditor: React.FunctionComponent<{
118121
)}
119122
style={{ width }}
120123
spellCheck="false"
124+
{...triggerProps}
121125
></input>
126+
{children}
122127
</div>
123128
);
124129
}}
@@ -185,6 +190,7 @@ export const ValueEditor: React.FunctionComponent<{
185190
onBlur,
186191
}) => {
187192
const val = String(value);
193+
const darkMode = useDarkMode();
188194

189195
const inputStyle = useMemo(() => {
190196
if (type === 'String') {
@@ -280,7 +286,11 @@ export const ValueEditor: React.FunctionComponent<{
280286
className={cx(
281287
editorReset,
282288
editorOutline,
283-
!valid && editorInvalid
289+
!valid && editorInvalid,
290+
!valid &&
291+
(darkMode
292+
? editorInvalidDarkMode
293+
: editorInvalidLightMode)
284294
)}
285295
style={inputStyle}
286296
spellCheck="false"

packages/compass-components/src/components/document-list/element.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ function useHadronElement(el: HadronElementType) {
9292
[el, forceUpdate]
9393
);
9494

95+
const onElementReverted = useCallback(
96+
(changedElement: HadronElementType) => {
97+
if (el.uuid === changedElement.uuid) {
98+
// When an element is reverted we check again if the key is a duplicate.
99+
setIsDuplicateKey(el.isDuplicateKey(el.key));
100+
forceUpdate();
101+
}
102+
},
103+
[el, forceUpdate]
104+
);
105+
95106
useEffect(() => {
96107
if (prevEl && prevEl !== el) {
97108
forceUpdate();
@@ -101,7 +112,7 @@ function useHadronElement(el: HadronElementType) {
101112
useEffect(() => {
102113
el.on(ElementEvents.Converted, onElementChanged);
103114
el.on(ElementEvents.Edited, onElementChanged);
104-
el.on(ElementEvents.Reverted, onElementChanged);
115+
el.on(ElementEvents.Reverted, onElementReverted);
105116
el.on(ElementEvents.Invalid, onElementChanged);
106117
el.on(ElementEvents.Valid, onElementChanged);
107118
el.on(ElementEvents.Added, onElementAddedOrRemoved);
@@ -113,15 +124,15 @@ function useHadronElement(el: HadronElementType) {
113124
return () => {
114125
el.off(ElementEvents.Converted, onElementChanged);
115126
el.off(ElementEvents.Edited, onElementChanged);
116-
el.off(ElementEvents.Reverted, onElementChanged);
127+
el.off(ElementEvents.Reverted, onElementReverted);
117128
el.off(ElementEvents.Valid, onElementChanged);
118129
el.off(ElementEvents.Added, onElementAddedOrRemoved);
119130
el.off(ElementEvents.Removed, onElementAddedOrRemoved);
120131
el.off(ElementEvents.Expanded, onElementChanged);
121132
el.off(ElementEvents.Collapsed, onElementChanged);
122133
el.off(ElementEvents.VisibleElementsChanged, onElementChanged);
123134
};
124-
}, [el, onElementChanged, onElementAddedOrRemoved]);
135+
}, [el, onElementChanged, onElementAddedOrRemoved, onElementReverted]);
125136

126137
const isValid = el.isCurrentTypeValid();
127138

0 commit comments

Comments
 (0)