fix: Templates menu does not appear in collab editing (#2915)

* fix: Templates menu does not appear in collab editing

* Improved logic for display templates menu
This commit is contained in:
Tom Moor
2022-01-08 16:04:50 -08:00
committed by GitHub
parent c6cc04cad8
commit fc564cfc1a
2 changed files with 12 additions and 2 deletions

View File

@@ -161,9 +161,15 @@ class DocumentScene extends React.Component<Props> {
this.props.document.templateId = template.id;
}
this.title = template.title;
this.props.document.title = template.title;
this.props.document.text = template.text;
this.updateIsDirty();
this.onSave({
autosave: true,
publish: false,
done: false,
});
};
onSynced = async () => {

View File

@@ -78,6 +78,11 @@ function DocumentHeader({
const { team } = auth;
const isMobile = useMobile();
// We cache this value for as long as the component is mounted so that if you
// apply a template there is still the option to replace it until the user
// navigates away from the doc
const [isNew] = React.useState(document.isPersistedOnce);
const handleSave = React.useCallback(() => {
onSave({
done: true,
@@ -91,7 +96,6 @@ function DocumentHeader({
});
}, [onSave]);
const isNew = document.isPersistedOnce;
const isTemplate = document.isTemplate;
const can = policies.abilities(document.id);
const canToggleEmbeds = team?.documentEmbeds;
@@ -205,7 +209,7 @@ function DocumentHeader({
<Status>{t("Saving")}</Status>
)}
<Collaborators document={document} />
{isEditing && !isTemplate && isNew && (
{(isEditing || team?.collaborativeEditing) && !isTemplate && isNew && (
<Action>
<TemplatesMenu
document={document}