Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Desktop: Resolves #8625: Show missing sync password warning and link …
…to FAQ (#8644)
- Loading branch information
1 parent
9e55d90
commit c6c2733
Showing
17 changed files
with
146 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...es/lib/components/shared/config-shared.js → ...components/shared/config/config-shared.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/lib/components/shared/config/shouldShowMissingPasswordWarning.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import SyncTargetRegistry from '../../../SyncTargetRegistry'; | ||
import shouldShowMissingPasswordWarning from './shouldShowMissingPasswordWarning'; | ||
|
||
// Maps targets to whether each target requires a password. | ||
// A subset of all sync targets. | ||
const targetToRequiresPassword: Record<string, boolean> = { | ||
'nextcloud': true, | ||
'webdav': true, | ||
'amazon_s3': true, | ||
'joplinServer': true, | ||
'joplinCloud': true, | ||
'onedrive': false, | ||
'dropbox': false, | ||
}; | ||
|
||
describe('shouldShowMissingPasswordWarning', () => { | ||
it('should return true when sync target requires a password and the password is missing', () => { | ||
for (const targetName in targetToRequiresPassword) { | ||
const targetId = SyncTargetRegistry.nameToId(targetName); | ||
const expected = targetToRequiresPassword[targetName]; | ||
|
||
expect(shouldShowMissingPasswordWarning(targetId, {})).toBe(expected); | ||
|
||
// Should also consider an empty string to be missing | ||
const settings = { | ||
[`sync.${targetId}.password`]: '', | ||
}; | ||
expect(shouldShowMissingPasswordWarning(targetId, settings)).toBe(expected); | ||
} | ||
}); | ||
|
||
it('should return false when a password is present', () => { | ||
for (const targetName in targetToRequiresPassword) { | ||
const targetId = SyncTargetRegistry.nameToId(targetName); | ||
const settings = { | ||
[`sync.${targetId}.password`]: 'some nonempty', | ||
}; | ||
|
||
expect(shouldShowMissingPasswordWarning(targetId, settings)).toBe(false); | ||
} | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/lib/components/shared/config/shouldShowMissingPasswordWarning.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import SyncTargetRegistry from '../../../SyncTargetRegistry'; | ||
|
||
const shouldShowMissingPasswordWarning = (syncTargetId: number, settings: any) => { | ||
const syncTargetClass = SyncTargetRegistry.classById(syncTargetId); | ||
|
||
return syncTargetClass.requiresPassword() && !settings[`sync.${syncTargetId}.password`]; | ||
}; | ||
|
||
export default shouldShowMissingPasswordWarning; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters