unnecessary code and toaster fix

pull/2820/head
Aniket-Engg 2 years ago committed by Aniket
parent d18e9f4922
commit 972ab65680
  1. 42
      libs/remix-ui/settings/src/lib/remix-ui-settings.tsx
  2. 5
      libs/remix-ui/settings/src/lib/settingsAction.ts

@ -1,5 +1,4 @@
import React, { useState, useReducer, useEffect, useCallback } from 'react' // eslint-disable-line
import { CopyToClipboard } from '@remix-ui/clipboard' // eslint-disable-line
import { enablePersonalModeText, ethereunVMText, labels, generateContractMetadataText, matomoAnalytics, textDark, textSecondary, warnText, wordWrapText, swarmSettingsTitle, ipfsSettingsText, useAutoCompleteText, useShowGasInEditorText, displayErrorsText } from './constants'
@ -224,47 +223,6 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
)
}
// api key settings
const saveToken = (type: string) => {
saveTokenToast(props.config, dispatchToast, tokenValue[type], labels[type].key)
}
const removeToken = (type: string) => {
setTokenValue(prevState => {
return { ...prevState, [type]: '' }
})
removeTokenToast(props.config, dispatchToast, labels[type].key)
}
const handleSaveTokenState = useCallback(
(event, type) => {
setTokenValue(prevState => {
return { ...prevState, [type]: event.target.value }
})
},
[tokenValue]
)
const token = (type: string) => (
<div className="border-top">
<div className="card-body pt-3 pb-2">
<h6 className="card-title">{labels[type].title}</h6>
<p className="mb-1">{labels[type].message1}</p>
<p className="">{labels[type].message2}</p>
<p className="mb-1"><a className="text-primary" target="_blank" href={labels[type].link}>{labels[type].link}</a></p>
<div className=""><label className="m-0">TOKEN:</label>
<div className="text-secondary mb-0 h6">
<input id="gistaccesstoken" data-id="settingsTabGistAccessToken" type="password" className="form-control" onChange={(e) => handleSaveTokenState(e, type)} value={ tokenValue[type] || '' } />
<div className="d-flex justify-content-end pt-2">
<CopyToClipboard content={tokenValue[type]} data-id='copyToClipboardCopyIcon' />
<input className="btn btn-sm btn-primary ml-2" id="savegisttoken" data-id="settingsTabSaveGistToken" onClick={() => saveToken(type)} value="Save" type="button" disabled={tokenValue === ''}></input>
<button className="btn btn-sm btn-secondary ml-2" id="removegisttoken" data-id="settingsTabRemoveGistToken" title="Delete GitHub access token" onClick={() => removeToken(type)}>Remove</button>
</div>
</div></div>
</div>
</div>
)
// swarm settings
const handleSavePrivateBeeAddress = useCallback(
(event) => {

@ -57,14 +57,13 @@ export const useDisplayErrors = (config, checked, dispatch) => {
}
export const saveTokenToast = (config, dispatch, tokenValue, key) => {
console.log('key in saveToken---->', key)
config.set('settings/' + key, tokenValue)
dispatch({ type: 'save', payload: { message: 'GitHub credentials updated' } })
dispatch({ type: 'save', payload: { message: 'Credentials updated' } })
}
export const removeTokenToast = (config, dispatch, key) => {
config.set('settings/' + key, '')
dispatch({ type: 'removed', payload: { message: 'GitHub credentials removed' } })
dispatch({ type: 'removed', payload: { message: 'Credentials removed' } })
}
export const saveSwarmSettingsToast = (config, dispatch, privateBeeAddress, postageStampId) => {

Loading…
Cancel
Save