Skip to content

Adding groups for access management #73

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

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Statuses from "@/src/components/shared/statuses/Statuses";
import { selectAllLookupLists, setAllLookupLists } from "@/src/reduxStore/states/pages/lookup-lists";
import { selectAttributes, selectVisibleAttributeAC, setAllAttributes, setLabelingTasksAll, updateAttributeById } from "@/src/reduxStore/states/pages/settings";
import { selectAttributes, selectVisibleAttributeAC, selectVisibleAttributesWithoutPermissions, setAllAttributes, setLabelingTasksAll, updateAttributeById } from "@/src/reduxStore/states/pages/settings";
import { selectProjectId } from "@/src/reduxStore/states/project"
import { Attribute, AttributeState, AttributeVisibility, AttributeWithOnClick, LLMConfig } from "@/src/types/components/projects/projectId/settings/data-schema";
import { DataTypeEnum } from "@/src/types/shared/general";
Expand Down Expand Up @@ -52,7 +52,7 @@ export default function AttributeCalculation() {

const projectId = useSelector(selectProjectId);
const attributes = useSelector(selectAttributes);
const usableAttributes = useSelector(selectVisibleAttributeAC)
const usableAttributes = useSelector(selectVisibleAttributesWithoutPermissions);
const lookupLists = useSelector(selectAllLookupLists);
const allUsers = useSelector(selectAllUsers);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export default function SearchGroups() {
});
colors.push('gray');
visibleAttributes.forEach((att) => {
if (att.dataType == DataTypeEnum.PERMISSION) return;
attributesSort.push({
name: att.name,
key: att.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { postProcessCurrentHeuristic, postProcessLastTaskLogs } from "@/src/util
import { Tooltip } from "@nextui-org/react";
import { TOOLTIPS_DICT } from "@/src/util/tooltip-constants";
import { postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper";
import { selectVisibleAttributesHeuristics, selectLabelingTasksAll, setLabelingTasksAll } from "@/src/reduxStore/states/pages/settings";
import { selectVisibleAttributesHeuristics, selectLabelingTasksAll, setLabelingTasksAll, selectVisibleAttributesWithoutPermissions } from "@/src/reduxStore/states/pages/settings";
import HeuristicsEditor from "../shared/HeuristicsEditor";
import DangerZone from "@/src/components/shared/danger-zone/DangerZone";
import HeuristicRunButtons from "../shared/HeuristicRunButtons";
Expand Down Expand Up @@ -46,7 +46,7 @@ export default function LabelingFunction() {
const projectId = useSelector(selectProjectId);
const currentHeuristic = useSelector(selectHeuristic);
const labelingTasks = useSelector(selectLabelingTasksAll);
const attributes = useSelector(selectVisibleAttributesHeuristics);
const attributes = useSelector(selectVisibleAttributesWithoutPermissions);
const allUsers = useSelector(selectAllUsers);

const [lastTaskLogs, setLastTaskLogs] = useState<string[]>([]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Statuses from "@/src/components/shared/statuses/Statuses";
import { selectHeuristic, setActiveHeuristics, updateHeuristicsState } from "@/src/reduxStore/states/pages/heuristics";
import { selectAllLookupLists, setAllLookupLists } from "@/src/reduxStore/states/pages/lookup-lists";
import { selectVisibleAttributesHeuristics, setAllAttributes } from "@/src/reduxStore/states/pages/settings";
import { selectVisibleAttributesHeuristics, selectVisibleAttributesWithoutPermissions, setAllAttributes } from "@/src/reduxStore/states/pages/settings";
import { selectProjectId } from "@/src/reduxStore/states/project"
import { HeuristicsProperty } from "@/src/types/components/projects/projectId/heuristics/heuristicId/heuristics-details";
import { Attribute } from "@/src/types/components/projects/projectId/settings/data-schema";
Expand All @@ -26,7 +26,7 @@ export default function HeuristicsLayout(props: any) {

const projectId = useSelector(selectProjectId);
const currentHeuristic = useSelector(selectHeuristic);
const usableAttributes = useSelector(selectVisibleAttributesHeuristics);
const usableAttributes = useSelector(selectVisibleAttributesWithoutPermissions);
const lookupLists = useSelector(selectAllLookupLists);

const [isHeaderNormal, setIsHeaderNormal] = useState(true);
Expand Down
10 changes: 8 additions & 2 deletions src/reduxStore/StoreManagerComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useState } from "react";
import { useRouter } from "next/router";
import { useDispatch, useSelector } from "react-redux";
import { selectIsAdmin, selectOrganization, setAllUsers, setIsAdmin, setOrganization, setRouteColor, setUser } from "./states/general";
import { selectIsAdmin, selectOrganization, selectUser, setAllUsers, setIsAdmin, setOrganization, setRouteColor, setUser } from "./states/general";
import { getUserAvatarUri } from "@/submodules/javascript-functions/general";
import { setActiveProject } from "./states/project";
import { WebSocketsService } from "../../submodules/react-components/hooks/web-socket/WebSocketsService";
Expand All @@ -18,12 +18,14 @@ import { getProjectByProjectId } from "../services/base/project";
import { getIsAdmin, getVersionOverview } from "../services/base/misc";
import { getUserInfo, getOrganization, getOrganizationUsers } from "../services/base/organization";
import { getAllTokenizerOptions, getEmbeddingPlatforms, getRecommendedEncoders } from "../services/base/embedding";
import { UserRole } from "../types/shared/sidebar";

export function GlobalStoreDataComponent(props: React.PropsWithChildren) {
const router = useRouter();
const dispatch = useDispatch();
const isAdmin = useSelector(selectIsAdmin);
const organization = useSelector(selectOrganization);
const userRole = useSelector(selectUser)?.role;

const [dataLoaded, setDataLoaded] = useState(false);

Expand All @@ -33,6 +35,10 @@ export function GlobalStoreDataComponent(props: React.PropsWithChildren) {
});

getUserInfo((res) => {
if (res.role == UserRole.ANNOTATOR || res.role == UserRole.EXPERT) {
window.location.href = '/cognition';
return;
}
const userInfo = { ...res };
userInfo.avatarUri = getUserAvatarUri(res);
dispatch(setUser(userInfo));
Expand Down Expand Up @@ -106,6 +112,6 @@ export function GlobalStoreDataComponent(props: React.PropsWithChildren) {
})
}, [ConfigManager.isInit()]);

if (!dataLoaded) return <></>;
if (!dataLoaded || userRole !== UserRole.ENGINEER) return <></>;
return <div>{props.children}</div>;
}
1 change: 1 addition & 0 deletions src/reduxStore/states/pages/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export const selectVisibleAttributesDataBrowser = createSelector([selectUsableAt
export const selectVisibleAttributeAC = createSelector([selectUsableAttributesFiltered], (a): any => a ? a.filter((a) => a.visibility != AttributeVisibility.HIDE) : null);
export const selectVisibleAttributesHeuristics = createSelector([selectUsableAttributesFiltered], (a): any => a ? a.filter((a) => a.visibility != AttributeVisibility.HIDE) : null);
export const selectOnAttributeEmbeddings = createSelector([selectEmbeddings], (a): any => a ? a.filter((embedding) => embedding.type == EmbeddingType.ON_ATTRIBUTE && embedding.state == Status.FINISHED) : null);
export const selectVisibleAttributesWithoutPermissions = createSelector([selectUsableAttributesFiltered], (a): any => a ? a.filter((a) => a.dataType != DataTypeEnum.PERMISSION) : null);

export const { setAllAttributes, extendAllAttributes, removeFromAllAttributesById, updateAttributeById, setAllEmbeddings, setFilteredEmbeddings, removeFromAllEmbeddingsById, setAllRecommendedEncodersDict, setRecommendedEncodersAll, setLabelingTasksAll, removeFromAllLabelingTasksById, removeLabelFromLabelingTask } = settingsSlice.actions;
export const settingsReducer = settingsSlice.reducer;
3 changes: 2 additions & 1 deletion src/types/shared/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ export enum DataTypeEnum {
FLOAT = "FLOAT",
BOOLEAN = "BOOLEAN",
EMBEDDING_LIST = "EMBEDDING_LIST",
LLM_RESPONSE = "LLM_RESPONSE"
LLM_RESPONSE = "LLM_RESPONSE",
PERMISSION = "PERMISSION",
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const DATA_TYPES = [
{ name: 'Boolean', value: 'BOOLEAN' },
{ name: 'Embedding List', value: 'EMBEDDING_LIST' },
{ name: 'LLM Response', value: 'LLM_RESPONSE' },
{ name: 'Permission', value: 'PERMISSION' },
];

export const ATTRIBUTES_VISIBILITY_STATES = [
Expand Down