Skip to content

Commit

Permalink
Merge pull request #78 from GBSL-Informatik/refactor/make-solutions-h…
Browse files Browse the repository at this point in the history
…idden-by-default

refactor: use None-Access for initializing solutions and  restricted's
  • Loading branch information
lebalz authored Jan 6, 2025
2 parents baeb8df + e916757 commit 7f1b4d1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/components/documents/Restricted/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ interface Props extends MetaInit {

const Restricted = observer((props: Props) => {
const [meta] = React.useState(new ModelMeta(props));
const docRoot = useDocumentRoot(props.id, meta, false);
const docRoot = useDocumentRoot(props.id, meta, false, {
access: props.access || Access.None_DocumentRoot
});
const userStore = useStore('userStore');
if (!docRoot || docRoot.isDummy) {
if (!!userStore.current) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/documents/Solution/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface Props extends MetaInit {

const Solution = observer((props: Props) => {
const [meta] = React.useState(new ModelMeta(props));
const docRoot = useDocumentRoot(props.id, meta, false);
const docRoot = useDocumentRoot(props.id, meta, false, { access: Access.None_DocumentRoot });
const userStore = useStore('userStore');
if (!docRoot || docRoot.isDummy) {
return <Loader />;
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useDocumentRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { Config } from '@tdev-api/documentRoot';
export const useDocumentRoot = <Type extends DocumentType>(
id: string | undefined,
meta: TypeMeta<Type>,
createFirstDocument: boolean = true,
addDummyToStore: boolean = true,
access: Partial<Config> = {},
skipCreate?: boolean
) => {
Expand All @@ -43,7 +43,7 @@ export const useDocumentRoot = <Type extends DocumentType>(
if (rootDoc) {
return;
}
if (createFirstDocument) {
if (addDummyToStore) {
documentRootStore.addDocumentRoot(dummyDocumentRoot);
}
if (!id) {
Expand Down

0 comments on commit 7f1b4d1

Please sign in to comment.