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

withTranslationMaintenance button not visible #67

Open
sven5 opened this issue Sep 1, 2022 · 1 comment
Open

withTranslationMaintenance button not visible #67

sven5 opened this issue Sep 1, 2022 · 1 comment

Comments

@sven5
Copy link

sven5 commented Sep 1, 2022

What could be the issue if the maintenance button doesn't show in Sanity Studio?

@gian-reto
Copy link

Hey @sven5 👋

I'm not a maintainer, but I recently faced the exact same problem. In my case it didn't show up because I had defined my own desk-structure.js (or .ts), which was overriding the default Sanity desk structure that the plugin extends (AFAIK). As I needed the custom desk structure for other stuff, I didn't want to remove it, which would probably have solved the issue.

Turns out there is a MaintenanceTab component, but unfortunately it isn't exported via the parts system like in other Sanity plugins, so I wasn't able to import and add it to my desk structure directly. However, I was able to find the module where the plugin extends the desk structure, and there's an exported function getMaintenanceListItem which returns the ListItem that the plugin appends to the desk structure if the withTranslationsMaintenance option is set to true in the config.

In my case, desk-structure.ts looked something like this:

import S from "@sanity/desk-tool/structure-builder";
// ... other imports

export default () =>
  S.list()
    .id("__root__")
    .title("Content")
    .items([
      S.listItem()
        .title("Pages")
        .schemaType("page")
        .child(S.documentTypeList("page").title("Pages")),
      // ... other listItems
    ]);

The only change that was needed was to import the getMaintenanceListItem function and call it in a place where the structure builder expects a listItem:

import S from "@sanity/desk-tool/structure-builder";
// ... other imports
import { getMaintenanceListItem } from "@sanity/document-internationalization/lib/structure";

export default () =>
  S.list()
    .id("__root__")
    .title("Content")
    .items([
      S.listItem()
        .title("Pages")
        .schemaType("page")
        .child(S.documentTypeList("page").title("Pages")),
      // ... other listItems
      S.divider(),
      getMaintenanceListItem(),
    ]);

I'm pretty sure it's not even necessary to enable the withTranslationsMaintenance option in the plugin's settings if you add it manually to your desk structure, as I didn't see any other notable references to it in the code, but I left it on anyway, just to be sure.

Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants