Skip to content

Commit 12cbe8b

Browse files
committed
Disable GDrive/Github buttons when workspaceLocation is not playground
1 parent fb238b0 commit 12cbe8b

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

src/commons/controlBar/ControlBarGoogleDriveButtons.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const stateToIntent: { [state in PersistenceState]: Intent } = {
1515

1616
type Props = {
1717
isFolderModeEnabled: boolean;
18+
workspaceLocation: string;
1819
loggedInAs?: string;
1920
accessToken?: string;
2021
currPersistenceFile?: PersistenceFile;
@@ -35,12 +36,13 @@ export const ControlBarGoogleDriveButtons: React.FC<Props> = props => {
3536
? 'DIRTY'
3637
: 'SAVED'
3738
: 'INACTIVE';
39+
const isNotPlayground = props.workspaceLocation !== "playground";
3840
const mainButton = (
3941
<ControlButton
4042
label={(props.currPersistenceFile && props.currPersistenceFile.name) || 'Google Drive'}
4143
icon={IconNames.CLOUD}
4244
options={{ intent: stateToIntent[state] }}
43-
//isDisabled={props.isFolderModeEnabled}
45+
isDisabled={isNotPlayground}
4446
/>
4547
);
4648
const openButton = (
@@ -86,13 +88,12 @@ export const ControlBarGoogleDriveButtons: React.FC<Props> = props => {
8688
<ControlButton label="Log In" icon={IconNames.LOG_IN} onClick={props.onClickLogIn} />
8789
);
8890

89-
//const tooltipContent = props.isFolderModeEnabled
90-
// ? 'Currently unsupported in Folder mode'
91-
// : undefined;
92-
const tooltipContent = undefined;
91+
const tooltipContent = isNotPlayground
92+
? 'Currently unsupported in non playground workspaces'
93+
: undefined;
9394

9495
return (
95-
<Tooltip2 content={tooltipContent} disabled={false}>
96+
<Tooltip2 content={tooltipContent} disabled={tooltipContent === undefined}>
9697
<Popover2
9798
autoFocus={false}
9899
content={
@@ -108,7 +109,7 @@ export const ControlBarGoogleDriveButtons: React.FC<Props> = props => {
108109
}
109110
onOpening={props.onPopoverOpening}
110111
popoverClassName={Classes.POPOVER_DISMISS}
111-
//disabled={props.isFolderModeEnabled}
112+
disabled={isNotPlayground}
112113
>
113114
{mainButton}
114115
</Popover2>

src/commons/controlBar/github/ControlBarGitHubButtons.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import ControlButton from '../../ControlButton';
1111

1212
type Props = {
1313
isFolderModeEnabled: boolean;
14+
workspaceLocation: string;
1415
currPersistenceFile?: PersistenceFile;
1516
loggedInAs?: Octokit;
1617
githubSaveInfo: GitHubSaveInfo;
@@ -34,6 +35,8 @@ export const ControlBarGitHubButtons: React.FC<Props> = props => {
3435

3536
const filePath = props.githubSaveInfo.filePath || '';
3637

38+
const isNotPlayground = props.workspaceLocation !== "playground";
39+
3740
const isLoggedIn = props.loggedInAs !== undefined;
3841
const shouldDisableButtons = !isLoggedIn;
3942
const hasFilePath = filePath !== '';
@@ -51,7 +54,7 @@ export const ControlBarGitHubButtons: React.FC<Props> = props => {
5154
label={mainButtonDisplayText}
5255
icon={IconNames.GIT_BRANCH}
5356
options={{ intent: mainButtonIntent }}
54-
//isDisabled={props.isFolderModeEnabled}
57+
isDisabled={isNotPlayground}
5558
/>
5659
);
5760

@@ -97,13 +100,12 @@ export const ControlBarGitHubButtons: React.FC<Props> = props => {
97100
<ControlButton label="Log In" icon={IconNames.LOG_IN} onClick={props.onClickLogIn} />
98101
);
99102

100-
//const tooltipContent = props.isFolderModeEnabled
101-
// ? 'Currently unsupported in Folder mode'
102-
// : undefined;
103-
const tooltipContent = undefined;
103+
const tooltipContent = isNotPlayground
104+
? 'Currently unsupported in non playground workspaces'
105+
: undefined;
104106

105107
return (
106-
<Tooltip2 content={tooltipContent} disabled={false}>
108+
<Tooltip2 content={tooltipContent} disabled={tooltipContent === undefined}>
107109
<Popover2
108110
autoFocus={false}
109111
content={
@@ -118,7 +120,7 @@ export const ControlBarGitHubButtons: React.FC<Props> = props => {
118120
</div>
119121
}
120122
popoverClassName={Classes.POPOVER_DISMISS}
121-
//disabled={props.isFolderModeEnabled}
123+
disabled={isNotPlayground}
122124
>
123125
{mainButton}
124126
</Popover2>

src/pages/playground/Playground.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ const Playground: React.FC<PlaygroundProps> = props => {
607607
return (
608608
<ControlBarGoogleDriveButtons
609609
isFolderModeEnabled={isFolderModeEnabled}
610+
workspaceLocation={workspaceLocation}
610611
currPersistenceFile={persistenceFile}
611612
loggedInAs={persistenceUser}
612613
isDirty={persistenceIsDirty}
@@ -629,7 +630,8 @@ const Playground: React.FC<PlaygroundProps> = props => {
629630
persistenceUser,
630631
persistenceIsDirty,
631632
dispatch,
632-
googleAccessToken
633+
googleAccessToken,
634+
workspaceLocation
633635
]);
634636

635637
const githubPersistenceIsDirty =
@@ -641,6 +643,7 @@ const Playground: React.FC<PlaygroundProps> = props => {
641643
<ControlBarGitHubButtons
642644
key="github"
643645
isFolderModeEnabled={isFolderModeEnabled}
646+
workspaceLocation={workspaceLocation}
644647
currPersistenceFile={persistenceFile}
645648
loggedInAs={githubOctokitObject.octokit}
646649
githubSaveInfo={githubSaveInfo}
@@ -659,7 +662,8 @@ const Playground: React.FC<PlaygroundProps> = props => {
659662
githubPersistenceIsDirty,
660663
githubSaveInfo,
661664
isFolderModeEnabled,
662-
persistenceFile
665+
persistenceFile,
666+
workspaceLocation
663667
]);
664668

665669
const executionTime = useMemo(

0 commit comments

Comments
 (0)