Skip to content

Commit dd48263

Browse files
authored
PICNIC-448: What's New Thingy (keybase#20403)
* Whats New * Snapshots * Padding update * Visual feedback * Fix tests * Review feedback * Partial review feedback * Make sure navigation will also close the popup * Add new images, fix styles, and new feature row * Fix inline icon size on mobile * Update copy, images, and font weight * Fix dark mode webpack path * Remove feature flag
1 parent e1e0647 commit dd48263

57 files changed

Lines changed: 6866 additions & 349 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎shared/.storybook/webpack.config.js‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ module.exports = ({config, mode}) => {
3939
__dirname + '/../util/__mocks__/typed-connect.tsx'
4040
),
4141
new webpack.NormalModuleReplacementPlugin(/^electron$/, __dirname + '/../__mocks__/electron.tsx'),
42-
new webpack.NormalModuleReplacementPlugin(/dark-mode/, __dirname + '/../styles/__mocks__/dark-mode.tsx'),
42+
new webpack.NormalModuleReplacementPlugin(
43+
// Don't match files that are named `dark-mode.png` accidentally
44+
/dark-mode.tsx/,
45+
__dirname + '/../styles/__mocks__/dark-mode.tsx'
46+
),
4347
new webpack.NormalModuleReplacementPlugin(/engine/, __dirname + '/../__mocks__/engine.tsx'),
4448
new webpack.NormalModuleReplacementPlugin(/util\/saga/, __dirname + '/../__mocks__/saga.tsx'),
4549
new webpack.NormalModuleReplacementPlugin(/feature-flags/, __dirname + '/../__mocks__/feature-flags.tsx'),
@@ -77,6 +81,11 @@ module.exports = ({config, mode}) => {
7781
test: [/.*\.(gif|png)$/],
7882
use: [fileLoaderRule],
7983
},
84+
{
85+
include: path.resolve(__dirname, '../images/releases'),
86+
test: [/.*\.png$/],
87+
use: [fileLoaderRule],
88+
},
8089
{
8190
test: /\.css$/,
8291
use: ['style-loader', 'css-loader'],

‎shared/actions/config-gen.tsx‎

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

‎shared/actions/config/index.tsx‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,22 @@ const logoutAndTryToLogInAs = async (
599599
return ConfigGen.createSetDefaultUsername({username: action.payload.username})
600600
}
601601

602+
const gregorPushState = (_: Container.TypedState, action: GregorGen.PushStatePayload) => {
603+
const actions: Array<Container.TypedActions> = []
604+
const items = action.payload.state
605+
const lastSeenItem = items.find(i => i.item && i.item.category === 'whatsNewLastSeenVersion')
606+
if (lastSeenItem) {
607+
const {body} = lastSeenItem.item
608+
const lastVersion = body.toString()
609+
actions.push(
610+
ConfigGen.createSetWhatsNewLastSeenVersion({
611+
lastSeenVersion: lastVersion,
612+
})
613+
)
614+
}
615+
return actions
616+
}
617+
602618
function* configSaga() {
603619
// Start the handshake process. This means we tell all sagas we're handshaking with the daemon. If another
604620
// saga needs to do something before we leave the loading screen they should call daemonHandshakeWait
@@ -668,6 +684,9 @@ function* configSaga() {
668684
yield* Saga.chainAction2(EngineGen.keybase1NotifyTrackingTrackingInfo, onTrackingInfo)
669685
yield* Saga.chainAction2(EngineGen.keybase1NotifyServiceHTTPSrvInfoUpdate, onHTTPSrvInfoUpdated)
670686

687+
// Listen for updates to `whatsNewLastSeenVersion`
688+
yield* Saga.chainAction2(GregorGen.pushState, gregorPushState, 'gregorPushState')
689+
671690
yield* Saga.chainAction2(SettingsGen.loadedSettings, maybeLoadAppLink)
672691

673692
yield* Saga.chainAction2(ConfigGen.setDarkModePreference, saveDarkPrefs)

‎shared/actions/json/config.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@
140140
},
141141
"setUseNativeFrame": {
142142
"useNativeFrame": "boolean"
143+
},
144+
"setWhatsNewLastSeenVersion": {
145+
"_description": "Set the latest version number that a user has seen from Gregor. This is used to set the badged state of the 'What's New' radio icon",
146+
"lastSeenVersion": "string"
143147
}
144148
}
145149
}

‎shared/actions/typed-actions-gen.tsx‎

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎shared/constants/config.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export const initialState: Types.State = {
133133
userActive: true,
134134
userSwitching: false,
135135
username: '',
136+
whatsNewLastSeenVersion: '',
136137
windowState: {
137138
dockHidden: false,
138139
height: 800,

‎shared/constants/settings.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export const logOutTab = 'settingsTabs.logOutTab'
280280
export const updatePaymentTab = 'settingsTabs.updatePaymentTab'
281281
export const walletsTab = 'settingsTabs.walletsTab'
282282
export const contactsTab = 'settingsTabs.contactsTab'
283+
export const whatsNewTab = 'settingsTabs.whatsNewTab'
283284

284285
export type SettingsTab =
285286
| typeof accountTab
@@ -300,3 +301,4 @@ export type SettingsTab =
300301
| typeof walletsTab
301302
| typeof chatTab
302303
| typeof contactsTab
304+
| typeof whatsNewTab

‎shared/constants/types/config.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@ export type State = {
8181
username: string
8282
userSwitching: boolean
8383
useNativeFrame: boolean
84+
whatsNewLastSeenVersion: string
8485
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export type NoVersion = '0.0.0'
2+
export type CurrentVersion = '4.8.0'
3+
export type LastVersion = NoVersion
4+
export type LastLastVersion = NoVersion
5+
export type WhatsNewVersion = CurrentVersion | LastVersion | LastLastVersion | NoVersion
6+
export type WhatsNewVersions = [CurrentVersion, LastVersion, LastLastVersion]
7+
8+
export type Feature = {
9+
primaryButtonText?: string
10+
secondaryButtonText?: string
11+
image?: string | null
12+
}
13+
14+
export type FeatureWithSeenState = Feature & {seen: boolean}

‎shared/constants/whats-new.tsx‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import semver from 'semver'
2+
import {
3+
NoVersion,
4+
CurrentVersion,
5+
LastVersion,
6+
LastLastVersion,
7+
WhatsNewVersion,
8+
WhatsNewVersions,
9+
} from './types/whats-new'
10+
11+
/*
12+
* IMPORTANT:
13+
* 1. currentVersion > lastVersion > lastLastVersion
14+
* 2. Must be semver compatible
15+
* Source: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
16+
*
17+
* HOW TO ADD A NEW RELEASE
18+
* 1. lastLastVersion = lastVersion
19+
* 2. lastVersion = currentVersion
20+
* 3. currentVersion = new version of release
21+
* 4. Update string-literal types in shared/constants/types/whats-new
22+
* 5. Add as many NewFeatureRows as needed
23+
*/
24+
25+
export const noVersion: NoVersion = '0.0.0'
26+
export const currentVersion: CurrentVersion = '4.8.0'
27+
export const lastVersion: LastVersion = '0.0.0'
28+
export const lastLastVersion: LastLastVersion = '0.0.0'
29+
export const versions: WhatsNewVersions = [currentVersion, lastVersion, lastLastVersion]
30+
export const keybaseFM = 'Keybase FM 87.8'
31+
32+
type seenVersionsMap = {[key in WhatsNewVersion]: boolean}
33+
34+
export const isVersionValid = (version: string) => {
35+
return version ? semver.valid(version) : false
36+
}
37+
38+
export const anyVersionsUnseen = (lastSeenVersion: string): boolean =>
39+
Object.values(getSeenVersions(lastSeenVersion)).some(seen => !seen)
40+
41+
export const getSeenVersions = (lastSeenVersion: string): seenVersionsMap => {
42+
// Mark all versions as seen so that the icon doesn't change as Gregor state is loading
43+
const initialMap: seenVersionsMap = {
44+
[currentVersion]: true,
45+
[lastLastVersion]: true,
46+
[lastVersion]: true,
47+
}
48+
49+
// User has no entry in Gregor for lastSeenVersion, so mark all as unseen
50+
if (!lastSeenVersion || !semver.valid(lastSeenVersion)) {
51+
return initialMap
52+
}
53+
54+
// last and lastLast versions might not be set
55+
const validVersions = versions.filter(isVersionValid)
56+
57+
// Unseen versions are ones that are greater than the lastSeenVersion
58+
// seen = lastLastVersion >= version
59+
const seenVersions = validVersions.reduce(
60+
(acc, version) => ({
61+
...acc,
62+
[version]: version === noVersion ? true : semver.gte(lastSeenVersion, version),
63+
}),
64+
initialMap
65+
)
66+
67+
return seenVersions
68+
}

0 commit comments

Comments
 (0)