Does a `section` have to have a
# package-development
r
Does a
section
have to have a
sectionView
by default or is there any way you could route workspaces in there? Effectively I'm looking for a
sectionView
to be able to have a configurable
header
slot but that only appears to be in a workspace?
Figured this out... my
section
loads a
sectionView
which in turn renders a new
workspace
. The
workspace
then has to have an attached context to know what
workspaceView
entities to render.
Copy code
ts
export class SectionViewElement extends UmbLitElement implements UmbSectionViewElement {
    constructor() {
        super();
    }
    override render() {
        return html`<custom-workspace-root></custom-workspace-root>`;
    }
}
Copy code
ts
const workspace: ManifestWorkspace = {
    type: 'workspace',
    alias: CUSTOM_WORKSPACE_ALIAS,
    name: 'Custom Workspace',
    element: () => import('./workspace.element'),
    meta: {
        entityType: 'custom-entity'
    }
}


const workspaceContext: ManifestWorkspaceContext = {
    type: 'workspaceContext',
    alias: CUSTOM_CONTEXT_ALIAS,
    name: 'Custom Workspace Context',
    js: () => import('./workspace.context'),
    conditions: [
        {
            alias: 'Umb.Condition.WorkspaceAlias',
            match: CUSTOM_WORKSPACE_ALIAS
        }
    ]
}
Copy code
ts
export class CustomWorkspaceRootElement extends UmbElementMixin(LitElement) {

    #workspaceContext: CustomWorkspaceContext;

    constructor() {
        super();

        this.#workspaceContext = new CustomWorkspaceContext(this);
    }

    override render() {
        return html`
            <umb-workspace-editor .enforceNoFooter=${true}>
            </umb-workspace-editor>
        `;
    }
}
Workspace context then has to implement
UmbWorkspaceContext
...
Copy code
ts
export class CustomWorkspaceContext extends UmbControllerBase implements UmbWorkspaceContext {
    public readonly workspaceAlias: string = CUSTOM_WORKSPACE_ALIAS;

    getEntityType(): string {
        return CUSTOM_ENTITY_TYPE;
    }

    constructor(host: UmbControllerHost) {
        super(host);
        this.provideContext(UMB_WORKSPACE_CONTEXT, this);
    }
}

export default CustomWorkspaceContext;

export const CUSTOM_CONTEXT_TOKEN = new UmbContextToken<CustomWorkspaceContext>(
    'CustomWorkspaceContext',
);
n
Hi Rick, looks good.. but you should ideally not spin up the workspace on your own. Instead use the element
<umb-workspace entity-type="MyEntityType">
🤓 In this way it will be loaded via the extension registry and handled properly. And then we have a naming problem... cause the UmbWorkspaceContext interface is intended for the main workspace context, which is given via the api property of the actual workspace manifest. Where a manifest of type workspaceContext is an additional one and does not need to follow that interface... 😒 we would need to solve that, and i would say the main problem is the naming. Actually the last part here, let me rephrase —
UmbWorkspaceContext
is intended for the
api
of the workspace, so you do not need to implement that for an extension of the type
workspaceContext
Also I assume your Workspace Context does not get initialized, cause there is a bug where this would have to be implemented by the specific Workspace, and I assume yu havent implemented that. We should make sure that extensions of type Workspace Context is initialized despite the workspace implementation. We are looking into this soon, so that may reach 15.2.
You may also want to know this: Yes, You can open a Workspace from a 'empty' section? all sections provides the adjacent path of
workspace/[entity-type]
also you can add more routes to sections, also sections that you did not create, the extension type is called
sectionRoute