Skip to content

Commit bbd7a40

Browse files
committed
allow completely disabling torchy
1 parent 7e6c1c9 commit bbd7a40

3 files changed

Lines changed: 31 additions & 19 deletions

File tree

src/addons/settings/settings.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ const Addon = ({
572572
<div className={styles.addonSwitch}>
573573
<Switch
574574
value={settings.enabled}
575-
disabled={id === 'ai-integration' || id === 'collaboration'}
575+
disabled={id === 'collaboration'}
576576
onChange={value => {
577577
if (
578578
!value ||

src/components/menu-bar/menu-bar.jsx

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import {
7676
closeErrorsMenu
7777
} from '../../reducers/menus';
7878
import {setFileHandle} from '../../reducers/tw.js';
79+
import SettingsStore from '../../addons/settings-store-singleton';
7980

8081
import collectMetadata from '../../lib/collect-metadata';
8182

@@ -101,6 +102,9 @@ import SeeInsideButton from './tw-see-inside.jsx';
101102
import {APP_NAME} from '../../lib/brand.js';
102103
import {showStandardAlert} from '../../reducers/alerts';
103104

105+
const isTorchyEnabled = SettingsStore.store['ai-integration'] &&
106+
SettingsStore.store['ai-integration'].enabled;
107+
104108
const twMessages = defineMessages({
105109
compileError: {
106110
id: 'tw.menuBar.compileError',
@@ -806,25 +810,28 @@ class MenuBar extends React.Component {
806810
</div>
807811
)}
808812
</div>
809-
<Divider className={styles.divider} />
810-
811-
<div className={styles.menuBarItem}>
812-
<Button
813-
className={classNames(styles.torchyButton, styles.feedbackLink)}
814-
iconSrc={aiIcon}
815-
onClick={this.handleClickTorchy}
816-
>
817-
<FormattedMessage
818-
defaultMessage="Torchy"
819-
description="Button to open the Torchy Popup"
820-
id="tw.topMenuTorchyButton"
821-
values={{
822-
APP_NAME
823-
}}
824-
/>
825-
</Button>
826-
</div>
813+
{isTorchyEnabled && (
814+
<React.Fragment>
827815

816+
<Divider className={styles.divider} />
817+
<div className={styles.menuBarItem}>
818+
<Button
819+
className={classNames(styles.torchyButton, styles.feedbackLink)}
820+
iconSrc={aiIcon}
821+
onClick={this.handleClickTorchy}
822+
>
823+
<FormattedMessage
824+
defaultMessage="Torchy"
825+
description="Button to open the Torchy Popup"
826+
id="tw.topMenuTorchyButton"
827+
values={{
828+
APP_NAME
829+
}}
830+
/>
831+
</Button>
832+
</div>
833+
</React.Fragment>
834+
)}
828835
<Divider className={styles.divider} />
829836

830837
{this.props.canEditTitle ? (

src/containers/blocks.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ import AddonHooks from '../addons/hooks.js';
4747
import LoadScratchBlocksHOC from '../lib/tw-load-scratch-blocks-hoc.jsx';
4848
import {findTopBlock} from '../lib/backpack/code-payload.js';
4949
import {gentlyRequestPersistentStorage} from '../lib/tw-persistent-storage.js';
50+
import SettingsStore from '../addons/settings-store-singleton';
51+
52+
const showAI = SettingsStore.store['ai-integration'] &&
53+
SettingsStore.store['ai-integration'].enabled;
5054

5155
// TW: Strings we add to scratch-blocks are localized here
5256
const messages = defineMessages({
@@ -161,6 +165,7 @@ class Blocks extends React.Component {
161165
rtl: this.props.isRtl,
162166
toolbox: this.props.toolboxXML,
163167
colours: this.props.theme.getBlockColors(),
168+
showAIButton: showAI,
164169
grid: {
165170
colour: this.props.theme.getBlockColors().gridColor
166171
}

0 commit comments

Comments
 (0)