geovistory / toolbox

Geovistory
MIT License
3 stars 0 forks source link

Configure entity visibility on project level #335

Closed joschne closed 9 months ago

joschne commented 9 months ago

Goal

The goal is to be able to configure, at the project level, the visibility entities receive upon their creation. This configuration happens via SQL directly. A corresponding UI is discussed here: #340.

Context

As of today:

An entity can be visible in the following ways:

a) The entity is visible to other projects in the Toolbox: Yes / No

If an entity is visible to other projects in the Toolbox, i.e., (a)=true, it can only be set to "(a)=false" if the entity has not been added to a second project. If it exists only in one project, it can be hidden again.

b) The entity has a URI and webpage on geovistory.org: Yes / No

Publication of an entity is irreversible: Once it has the value "(b)=true," it cannot be set to "(b)=false" again (In case of privacy violations, platform operators need to be requested to reset it to "(b)=false").

c) The entity is visible on a project webpage and in the project SPARQL endpoint: Yes / No

The two visibility settings (a) and (b) relate to entity visibility independent of a project, while (c) is project-specific. This means multiple projects can have different visibility settings for (c) for the same entity, but not for (a) and (b).

During entity creation, visibilities for (a), (b), and (c) are automatically set based on configurations. Currently, this configuration is possible at the class (and superclass) level. However, this setting applies system-wide and not just to a specific project.

Functional Requirement:

The default visibilities for (a), (b), and (c) should be configurable at the project level through this issue. Initially, only system administrators can make this setting, not project members themselves.

Technical Specification:

Create a new table in Postgres:

visibility_settings
- fk_project: int, references the project
- settings: jsonb, defines the visibility settings

The values in settings are structured as follows:

ProjectVisibilitySettings: {
    classesDefault?: ProjectClassConfig 
    classesByBasicType?: {[classId]: ProjectClassConfig}
    classes?: {[classId]: ProjectClassConfig}
}

ProjectClassConfig: {
    communityVisibilityDefault?: CommunityVisibilityOptions;
    projectVisibilityDefault?: ProjectVisibilityOptions;
}

In visibility.controller.ts, initializeConfiguration():

In getCommunityVisibilityDefault():

In getProjectVisibilityDefault():

Acceptance Criteria:

Given the following projectVisibilitySettings for Project 5:

{
    classesDefault: {
        communityVisibilityDefault: {toolbox: true, dataApi: true, website: true},
        projectVisibilityDefault: {dataApi: true, website: true},
    } 
    classesByBasicType?: {9: {
        communityVisibilityDefault: {toolbox: true, dataApi: true, website: false},
    }}
    classes?: {
        123: {
            communityVisibilityDefault: {toolbox: true, dataApi: false, website: false},
        }
    }
}

And the following system-wide communityVisibilitySettings:

{
    classesDefault: {
        communityVisibilityDefault: {toolbox: false, dataApi: false, website: false},
        projectVisibilityDefault: {dataApi: false, website: false},
    }
}
joschne commented 9 months ago

resolved by #336