Skip to content

Commit 0701892

Browse files
committed
GitHub top bar to reflect folder name like GDrive
1 parent b293269 commit 0701892

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/commons/controlBar/ControlBarGoogleDriveButtons.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type Props = {
1717
isFolderModeEnabled: boolean;
1818
loggedInAs?: string;
1919
accessToken?: string;
20-
currentObject?: PersistenceFile;
20+
currPersistenceFile?: PersistenceFile;
2121
isDirty?: boolean;
2222
onClickOpen?: () => any;
2323
onClickSave?: () => any;
@@ -30,14 +30,14 @@ type Props = {
3030

3131
export const ControlBarGoogleDriveButtons: React.FC<Props> = props => {
3232
const { isMobileBreakpoint } = useResponsive();
33-
const state: PersistenceState = props.currentObject
33+
const state: PersistenceState = props.currPersistenceFile
3434
? props.isDirty
3535
? 'DIRTY'
3636
: 'SAVED'
3737
: 'INACTIVE';
3838
const mainButton = (
3939
<ControlButton
40-
label={(props.currentObject && props.currentObject.name) || 'Google Drive'}
40+
label={(props.currPersistenceFile && props.currPersistenceFile.name) || 'Google Drive'}
4141
icon={IconNames.CLOUD}
4242
options={{ intent: stateToIntent[state] }}
4343
//isDisabled={props.isFolderModeEnabled}

src/commons/controlBar/github/ControlBarGitHubButtons.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ import { useResponsive } from 'src/commons/utils/Hooks';
77

88
import { GitHubSaveInfo } from '../../../features/github/GitHubTypes';
99
import ControlButton from '../../ControlButton';
10+
import { PersistenceFile } from 'src/features/persistence/PersistenceTypes';
1011

1112
type Props = {
1213
isFolderModeEnabled: boolean;
14+
currPersistenceFile?: PersistenceFile;
1315
loggedInAs?: Octokit;
1416
githubSaveInfo: GitHubSaveInfo;
1517
isDirty: boolean;
@@ -31,14 +33,13 @@ export const ControlBarGitHubButtons: React.FC<Props> = props => {
3133
const { isMobileBreakpoint } = useResponsive();
3234

3335
const filePath = props.githubSaveInfo.filePath || '';
34-
const fileName = (filePath.split('\\').pop() || '').split('/').pop() || '';
3536

3637
const isLoggedIn = props.loggedInAs !== undefined;
3738
const shouldDisableButtons = !isLoggedIn;
3839
const hasFilePath = filePath !== '';
3940
const hasOpenFile = isLoggedIn && hasFilePath;
4041

41-
const mainButtonDisplayText = hasOpenFile ? fileName : 'GitHub';
42+
const mainButtonDisplayText = (props.currPersistenceFile && props.currPersistenceFile.name) || 'GitHub';
4243
let mainButtonIntent: Intent = Intent.NONE;
4344
if (hasOpenFile) {
4445
mainButtonIntent = props.isDirty ? Intent.WARNING : Intent.PRIMARY;

src/pages/playground/Playground.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,7 @@ const Playground: React.FC<PlaygroundProps> = props => {
603603
return (
604604
<ControlBarGoogleDriveButtons
605605
isFolderModeEnabled={isFolderModeEnabled}
606-
currentObject={persistenceFile}
606+
currPersistenceFile={persistenceFile}
607607
loggedInAs={persistenceUser}
608608
isDirty={persistenceIsDirty}
609609
accessToken={googleAccessToken}
@@ -637,6 +637,7 @@ const Playground: React.FC<PlaygroundProps> = props => {
637637
<ControlBarGitHubButtons
638638
key="github"
639639
isFolderModeEnabled={isFolderModeEnabled}
640+
currPersistenceFile={persistenceFile}
640641
loggedInAs={githubOctokitObject.octokit}
641642
githubSaveInfo={githubSaveInfo}
642643
isDirty={githubPersistenceIsDirty}

0 commit comments

Comments
 (0)