Merge pull request #4787 from ethereum/ai_setting

enabled AI setting restore
pull/4806/head^2
Aniket 6 months ago committed by GitHub
commit 0239e06641
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      apps/remix-ide/src/app/tabs/settings-tab.tsx
  2. 3
      libs/remix-ui/settings/src/lib/remix-ui-settings.tsx
  3. 13
      libs/remix-ui/tabs/src/lib/remix-ui-tabs.tsx

@ -15,7 +15,7 @@ const _paq = (window._paq = window._paq || [])
const profile = {
name: 'settings',
displayName: 'Settings',
methods: ['get', 'updateCopilotChoice'],
methods: ['get', 'updateCopilotChoice', 'getCopilotSetting'],
events: [],
icon: 'assets/img/settings.webp',
description: 'Remix-IDE settings',
@ -52,7 +52,7 @@ module.exports = class SettingsTab extends ViewPlugin {
this.element = document.createElement('div')
this.element.setAttribute('id', 'settingsTab')
this.useMatomoAnalytics = null
this.useCopilot = false
this.useCopilot = this.get('settings/copilot/suggest/activate')
}
setDispatch(dispatch: React.Dispatch<any>) {
@ -102,6 +102,10 @@ module.exports = class SettingsTab extends ViewPlugin {
})
}
getCopilotSetting(){
return this.useCopilot
}
updateMatomoAnalyticsChoice(isChecked) {
this.config.set('settings/matomo-analytics', isChecked)
this.useMatomoAnalytics = isChecked

@ -58,7 +58,6 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
const [ipfsProtocol, setipfsProtocol] = useState('')
const [ipfsProjectId, setipfsProjectId] = useState('')
const [ipfsProjectSecret, setipfsProjectSecret] = useState('')
const copilotDownload = useRef(null)
const intl = useIntl()
const initValue = () => {
@ -145,7 +144,7 @@ export const RemixUiSettings = (props: RemixUiSettingsProps) => {
}
const startCopilot = async () => {
copilotActivate(props.config, true, dispatch)
copilotActivate(props.config, props.useCopilot, dispatch)
props.plugin.call('terminal', 'log', { type: 'typewriterlog', value: `Solidity copilot activated!` })
}

@ -5,6 +5,7 @@ import React, {useState, useRef, useEffect, useReducer} from 'react' // eslint-d
import { FormattedMessage } from 'react-intl'
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'
import './remix-ui-tabs.css'
import { values } from 'lodash'
const _paq = (window._paq = window._paq || [])
/* eslint-disable-next-line */
@ -64,7 +65,6 @@ export const TabsUI = (props: TabsUIProps) => {
const tabsRef = useRef({})
const tabsElement = useRef(null)
const [ai_switch, setAI_switch] = useState<boolean>(false)
const tabs = useRef(props.tabs)
tabs.current = props.tabs // we do this to pass the tabs list to the onReady callbacks
@ -77,6 +77,14 @@ export const TabsUI = (props: TabsUIProps) => {
}
}, [tabsState.selectedIndex])
const getAI = async() => {
try {
return await props.plugin.call('settings', 'getCopilotSetting')
} catch (e){
return false
}
}
const getFileDecorationClasses = (tab: any) => {
const fileDecoration = tabsState.fileDecorations.find((fileDecoration: fileDecoration) => {
if (`${fileDecoration.workspace.name}/${fileDecoration.path}` === tab.name) return true
@ -92,7 +100,6 @@ export const TabsUI = (props: TabsUIProps) => {
const classNameImg = 'my-1 mr-1 text-dark ' + tab.iconClass
const classNameTab = 'nav-item nav-link d-flex justify-content-center align-items-center px-2 py-1 tab' + (index === currentIndexRef.current ? ' active' : '')
const invert = props.themeQuality === 'dark' ? 'invert(1)' : 'invert(0)'
return (
<CustomTooltip tooltipId="tabsActive" tooltipText={tab.tooltip} placement="bottom-start">
<div
@ -133,6 +140,7 @@ export const TabsUI = (props: TabsUIProps) => {
}
const setFileDecorations = (fileStates: fileDecoration[]) => {
getAI().then(value => setAI_switch(value)).catch(error => console.log(error))
dispatch({ type: 'SET_FILE_DECORATIONS', payload: fileStates })
}
@ -208,6 +216,7 @@ export const TabsUI = (props: TabsUIProps) => {
<i className="fas fa-play"></i>
</button>
</CustomTooltip>
<div className= "d-flex border-left ml-2 align-items-center" style={{ height: "3em" }}>
<CustomTooltip
placement="bottom"

Loading…
Cancel
Save