Skip to content

Commit

Permalink
feat: Add a clear cache button on general settings view
Browse files Browse the repository at this point in the history
  • Loading branch information
ashchan committed Nov 16, 2019
1 parent f9b3c15 commit 429be9c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
28 changes: 25 additions & 3 deletions packages/neuron-ui/src/components/GeneralSetting/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
import React from 'react'
import { Stack } from 'office-ui-fabric-react'
import React, { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Stack, PrimaryButton, Spinner } from 'office-ui-fabric-react'

const GeneralSetting = () => {
return <Stack tokens={{ childrenGap: 15 }} />
const [t] = useTranslation()
const [clearing, setClearing] = useState(false)

const clearCache = useCallback(() => {
// TODO: real clear action
setClearing(true)
setTimeout(() => {
setClearing(false)
}, 2000)
}, [])

return (
<Stack tokens={{ childrenGap: 15 }} horizontal horizontalAlign="start">
<PrimaryButton
text={t('settings.general.clear-cache')}
onClick={clearCache}
disabled={clearing}
ariaDescription="Create new network configuration"
/>
{clearing ? <Spinner /> : null}
</Stack>
)
}

GeneralSetting.displayName = 'GeneralSetting'
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"network": "Network"
},
"general": {
"skip-data-and-type": "Skip the Cells which contain Data or Type Script",
"clear-cache": "Clear cache",
"show": "Show",
"hide": "Hide"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/neuron-ui/src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"network": "网络"
},
"general": {
"skip-data-and-type": "忽略包含 Data 或 Type Script 的 Cells",
"clear-cache": "清空缓存",
"show": "显示",
"hide": "隐藏"
},
Expand Down

0 comments on commit 429be9c

Please sign in to comment.