Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] - Hide branches management UI #751

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/keystatic/src/app/dashboard/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ export function DashboardPage(props: { config: Config; basePath: string }) {
<PageBody isScrollable>
<Flex direction="column" gap="xxlarge">
{user && <UserInfo user={user} manageAccount={!!cloudInfo} />}

<BranchSection config={props.config} />
{!props.config.ui?.hideBranchesManagement && <BranchSection config={props.config} />}
<DashboardCards />
</Flex>
</PageBody>
Expand Down
10 changes: 6 additions & 4 deletions packages/keystatic/src/app/shell/topbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,13 @@ export const SidebarHeader = () => {
// -----------------------------------------------------------------------------

function CloudHeader() {
const config = useConfig();
const cloudInfo = useCloudInfo();
return (
<HeaderOuter>
<BrandButton />
<BranchPicker />
<GitMenu />
{!config.ui?.hideBranchesManagement && <BranchPicker />}
{!config.ui?.hideBranchesManagement && <GitMenu />}
<Box flex="1" />
<ImageLibraryButton />
<ThemeMenu />
Expand Down Expand Up @@ -144,12 +145,13 @@ function ImageLibraryButton() {
// -----------------------------------------------------------------------------

function GithubHeader() {
const config = useConfig();
const user = useViewer();
return (
<HeaderOuter>
<BrandButton />
<BranchPicker />
<GitMenu />
{!config.ui?.hideBranchesManagement && <BranchPicker />}
{!config.ui?.hideBranchesManagement && <GitMenu />}
<Box flex="1" />
<ThemeMenu />
<UserMenu
Expand Down
5 changes: 3 additions & 2 deletions packages/keystatic/src/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export type Singleton<Schema extends Record<string, ComponentSchema>> = {
type CommonConfig<Collections, Singletons> = {
locale?: Locale;
cloud?: { project: string };
ui?: UserInterface<Collections, Singletons>;
ui?: UserInterfaceConfig<Collections, Singletons>;
};

type CommonRemoteStorageConfig = {
Expand All @@ -52,7 +52,7 @@ type BrandMark = (props: {
colorScheme: Exclude<ColorScheme, 'auto'>; // we resolve "auto" to "light" or "dark" on the client
}) => ReactElement;
export const NAVIGATION_DIVIDER_KEY = '---';
type UserInterface<Collections, Singletons> = {
type UserInterfaceConfig<Collections, Singletons> = {
brand?: {
mark?: BrandMark;
name: string;
Expand All @@ -62,6 +62,7 @@ type UserInterface<Collections, Singletons> = {
| (keyof Singletons & string)
| typeof NAVIGATION_DIVIDER_KEY
>;
hideBranchesManagement?: boolean
};

type Navigation<K> = K[] | { [section: string]: K[] };
Expand Down