Skip to content

Commit

Permalink
Rename user/userSlice to auth/authSlice
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielrindlaub committed Dec 13, 2023
1 parent c095c22 commit 1947028
Show file tree
Hide file tree
Showing 25 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import * as Tooltip from '@radix-ui/react-tooltip';
import * as Toast from '@radix-ui/react-toast';
import { initTracking } from '../features/tracking/trackingSlice';
import { selectRouterLocation } from '../features/images/imagesSlice';
import { userAuthStateChanged } from '../features/user/userSlice';
import { userAuthStateChanged } from '../features/auth/authSlice';
import { mouseEventDetected, selectIsDrawingBbox } from '../features/loupe/loupeSlice';
import logo from '../assets/animl-logo.svg';
import { IN_MAINTENANCE_MODE, GA_CONFIG, AWS_AUTH_CONFIG } from '../config';
Expand Down
6 changes: 3 additions & 3 deletions src/app/rootReducer.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { combineReducers } from '@reduxjs/toolkit';
import { connectRouter } from 'connected-react-router';
import { undoHistoryReducer } from 'redux-undo-redo';
import userSlice from '../features/user/userSlice';
import authSlice from '../features/auth/authSlice';
import filtersReducer from '../features/filters/filtersSlice';
import imagesReducer from '../features/images/imagesSlice';
import wirelessCamerasReducer from '../features/cameras/wirelessCamerasSlice';
import reviewReducer from '../features/review/reviewSlice';
import loupeReducer from '../features/loupe/loupeSlice';
import projectReducer from '../features/projects/projectsSlice';
import usersReducer from '../features/projects/userSlice';
import usersReducer from '../features/projects/usersSlice';
import trackingReducer from '../features/tracking/trackingSlice';
import uploadReducer from '../features/upload/uploadSlice';

const createRootReducer = (history) => combineReducers({
router: connectRouter(history),
user: userSlice, // TODO: we have two separate usersSlices. Fix
auth: authSlice,
projects: projectReducer,
users: usersReducer,
filters: filtersReducer,
Expand Down
2 changes: 1 addition & 1 deletion src/components/ErrorAlerts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
dismissExportError,
} from '../features/images/imagesSlice';
import getErrorContent from '../content/Errors';
import { selectManageUserErrors, dismissManageUsersError } from '../features/projects/userSlice';
import { selectManageUserErrors, dismissManageUsersError } from '../features/projects/usersSlice';

// TODO: add updateAutomationRules errors

Expand Down
2 changes: 1 addition & 1 deletion src/components/HydratedModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
setModalOpen,
setModalContent
} from '../features/projects/projectsSlice';
import { clearUsers } from '../features/projects/userSlice.js';
import { clearUsers } from '../features/projects/usersSlice.js';

// Modal populated with content
const HydratedModal = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { useSelector } from 'react-redux';
import { styled } from '../theme/stitches.config.js';
import { Link } from 'react-router-dom';
import { selectUserUsername, selectUserAuthStatus } from '../features/user/userSlice.js';
import { selectUserUsername, selectUserAuthStatus } from '../features/auth/authSlice.js';
import { selectRouterLocation } from '../features/images/imagesSlice.js';
import ProjectAndViewNav from '../features/projects/ProjectAndViewNav.jsx';
import { useAuthenticator } from '@aws-amplify/ui-react';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { indigo } from '@radix-ui/colors';
import Button from '../../components/Button.jsx';
import '@aws-amplify/ui-react/styles.css';
import { useSelector } from 'react-redux';
import { selectUserUsername } from './userSlice.js';
import { selectUserUsername } from './authSlice.js';

const LoginScreen = styled('div', {
display: 'flex',
Expand Down
20 changes: 10 additions & 10 deletions src/features/user/userSlice.js → src/features/auth/authSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const initialState = {
authStatus: null,
};

export const userSlice = createSlice({
name: 'user',
export const authSlice = createSlice({
name: 'auth',
initialState,
reducers: {

Expand Down Expand Up @@ -43,15 +43,15 @@ export const userSlice = createSlice({

export const {
userAuthStateChanged,
} = userSlice.actions;
} = authSlice.actions;

// Selectors
export const selectUserAuthStatus = state => state.user.authStatus;
export const selectUserGroups = state => state.user.groups;
export const selectUserUsername = state => state.user.username;
export const selectUserProjects = state => state.user.projects;
export const selectUserIsSuperUser = state => state.user.groups && state.user.groups.includes('animl_superuser');
export const selectUserHasBetaAccess = state => state.user.groups.includes('beta_access');
export const selectUserAuthStatus = state => state.auth.authStatus;
export const selectUserGroups = state => state.auth.groups;
export const selectUserUsername = state => state.auth.username;
export const selectUserProjects = state => state.auth.projects;
export const selectUserIsSuperUser = state => state.auth.groups && state.auth.groups.includes('animl_superuser');
export const selectUserHasBetaAccess = state => state.auth.groups.includes('beta_access');
export const selectUserCurrentRoles = createSelector(
[selectSelectedProject, selectUserProjects, selectUserIsSuperUser],
(selectedProject, userProjects, isSuperUser) => {
Expand All @@ -67,4 +67,4 @@ export const selectUserCurrentRoles = createSelector(
);


export default userSlice.reducer;
export default authSlice.reducer;
File renamed without changes.
4 changes: 2 additions & 2 deletions src/features/cameras/CameraAdminModal.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useEffect, useState }from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { selectUserCurrentRoles } from '../user/userSlice';
import { hasRole, WRITE_CAMERA_REGISTRATION_ROLES } from '../../auth/roles';
import { selectUserCurrentRoles } from '../auth/authSlice';
import { hasRole, WRITE_CAMERA_REGISTRATION_ROLES } from '../auth/roles';
import {
selectWirelessCamerasLoading,
selectWirelessCameras,
Expand Down
4 changes: 2 additions & 2 deletions src/features/cameras/CameraList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { DateTime } from 'luxon';
import { styled } from '../../theme/stitches.config';
import { selectUserCurrentRoles } from '../user/userSlice';
import { selectUserCurrentRoles } from '../auth/authSlice';
import { unregisterCamera } from './wirelessCamerasSlice';
import Accordion from '../../components/Accordion';
import IconButton from '../../components/IconButton';
Expand All @@ -11,7 +11,7 @@ import {
hasRole,
WRITE_CAMERA_REGISTRATION_ROLES,
WRITE_DEPLOYMENTS_ROLES
} from '../../auth/roles';
} from '../auth/roles';


const StyledCameraList = styled('div', {
Expand Down
4 changes: 2 additions & 2 deletions src/features/filters/FiltersPanel.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { styled } from '../../theme/stitches.config.js';
import { selectUserCurrentRoles } from '../user/userSlice.js';
import { hasRole, QUERY_WITH_CUSTOM_FILTER } from '../../auth/roles.js';
import { selectUserCurrentRoles } from '../auth/authSlice.js';
import { hasRole, QUERY_WITH_CUSTOM_FILTER } from '../auth/roles.js';
import PanelHeader from '../../components/PanelHeader.jsx';
import StyledScrollArea from '../../components/ScrollArea.jsx';
import DeploymentFilter from './DeploymentFilter.jsx';
Expand Down
4 changes: 2 additions & 2 deletions src/features/filters/FiltersPanelFooter.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { styled } from '../../theme/stitches.config.js';
import { selectUserCurrentRoles } from '../user/userSlice.js';
import { hasRole, READ_STATS_ROLES, EXPORT_DATA_ROLES } from '../../auth/roles.js';
import { selectUserCurrentRoles } from '../auth/authSlice.js';
import { hasRole, READ_STATS_ROLES, EXPORT_DATA_ROLES } from '../auth/roles.js';
import { useDispatch, useSelector } from 'react-redux';
import { selectImagesCount, fetchImages } from '../images/imagesSlice.js';
import { selectActiveFilters } from './filtersSlice.js';
Expand Down
4 changes: 2 additions & 2 deletions src/features/images/ImagesTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import {
selectSelectedImageIndices
} from '../review/reviewSlice';
import { toggleOpenLoupe, selectLoupeOpen } from '../loupe/loupeSlice';
import { selectUserUsername, selectUserCurrentRoles } from '../user/userSlice.js';
import { hasRole, WRITE_OBJECTS_ROLES } from '../../auth/roles';
import { selectUserUsername, selectUserCurrentRoles } from '../auth/authSlice.js';
import { hasRole, WRITE_OBJECTS_ROLES } from '../auth/roles';
import { selectAvailLabels } from '../filters/filtersSlice.js';
import { selectIsAddingLabel, addLabelStart, addLabelEnd } from '../loupe/loupeSlice.js';
import { Image } from '../../components/Image';
Expand Down
4 changes: 2 additions & 2 deletions src/features/loupe/BoundingBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import _ from 'lodash';
import Draggable from 'react-draggable';
import { ResizableBox } from 'react-resizable';
import 'react-resizable/css/styles.css';
import { selectUserUsername, selectUserCurrentRoles } from '../user/userSlice';
import { hasRole, WRITE_OBJECTS_ROLES } from '../../auth/roles';
import { selectUserUsername, selectUserCurrentRoles } from '../auth/authSlice';
import { hasRole, WRITE_OBJECTS_ROLES } from '../auth/roles';
import {
ContextMenu,
ContextMenuTrigger,
Expand Down
4 changes: 2 additions & 2 deletions src/features/loupe/FullSizeImage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { useState, useRef, useEffect } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { useResizeObserver } from '../../app/utils';
import { styled } from '../../theme/stitches.config';
import { selectUserUsername, selectUserCurrentRoles } from '../user/userSlice';
import { selectUserUsername, selectUserCurrentRoles } from '../auth/authSlice';
import { selectIsDrawingBbox} from './loupeSlice';
import { hasRole, WRITE_OBJECTS_ROLES, DELETE_IMAGES } from '../../auth/roles';
import { hasRole, WRITE_OBJECTS_ROLES, DELETE_IMAGES } from '../auth/roles';
import { selectWorkingImages, labelsValidated, markedEmpty } from '../review/reviewSlice';
import { deleteImages } from '../images/imagesSlice';
import { Image } from '../../components/Image';
Expand Down
4 changes: 2 additions & 2 deletions src/features/loupe/ImageReviewToolbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import { selectAvailLabels } from '../filters/filtersSlice.js';
import IconButton from '../../components/IconButton.jsx';
import { labelsAdded } from '../review/reviewSlice.js';
import { addLabelStart, addLabelEnd, selectIsDrawingBbox, selectIsAddingLabel } from './loupeSlice.js';
import { selectUserUsername, selectUserCurrentRoles } from '../user/userSlice.js';
import { hasRole, WRITE_OBJECTS_ROLES } from '../../auth/roles';
import { selectUserUsername, selectUserCurrentRoles } from '../auth/authSlice.js';
import { hasRole, WRITE_OBJECTS_ROLES } from '../auth/roles.js';
import { violet, blackA, mauve } from '@radix-ui/colors';
import Button from '../../components/Button.jsx';
import {
Expand Down
4 changes: 2 additions & 2 deletions src/features/loupe/Loupe.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import {
drawBboxStart,
addLabelStart,
} from './loupeSlice.js';
import { selectUserUsername, selectUserCurrentRoles } from '../user/userSlice';
import { hasRole, WRITE_OBJECTS_ROLES } from '../../auth/roles';
import { selectUserUsername, selectUserCurrentRoles } from '../auth/authSlice';
import { hasRole, WRITE_OBJECTS_ROLES } from '../auth/roles.js';
import PanelHeader from '../../components/PanelHeader.jsx';
import FullSizeImage from './FullSizeImage.jsx';
import ImageReviewToolbar from './ImageReviewToolbar.jsx';
Expand Down
2 changes: 1 addition & 1 deletion src/features/projects/ManageUsersAddForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Formik, Form, Field } from 'formik';
import { styled } from "@stitches/react";
import * as Yup from 'yup';

import { createUser, cancel } from './userSlice.js';
import { createUser, cancel } from './usersSlice.js';
import {
FormWrapper,
FormSubheader,
Expand Down
2 changes: 1 addition & 1 deletion src/features/projects/ManageUsersEditForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useSelector, useDispatch } from "react-redux";
import { Formik, Form } from 'formik';
import { styled } from "@stitches/react";

import { selectUsers, selectSelectedUser, updateUser, cancel } from './userSlice.js';
import { selectUsers, selectSelectedUser, updateUser, cancel } from './usersSlice.js';
import {
FormWrapper,
FormSubheader,
Expand Down
2 changes: 1 addition & 1 deletion src/features/projects/ManageUsersModal.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useSelector } from 'react-redux';

import { selectMode } from './userSlice.js';
import { selectMode } from './usersSlice.js';
import ManageUsersAddForm from './ManageUsersAddForm.jsx';
import ManageUsersEditForm from './ManageUsersEditForm.jsx';
import ManageUsersTable from "./ManageUsersTable";
Expand Down
2 changes: 1 addition & 1 deletion src/features/projects/ManageUsersTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import IconButton from '../../components/IconButton.jsx';
import { Tooltip, TooltipContent, TooltipArrow, TooltipTrigger } from '../../components/Tooltip.jsx';
import { ButtonRow } from '../../components/Form';
import { SimpleSpinner, SpinnerOverlay } from '../../components/Spinner.jsx';
import { addUser, editUser, fetchUsers, selectUsers, selectUsersLoading } from './userSlice.js';
import { addUser, editUser, fetchUsers, selectUsers, selectUsersLoading } from './usersSlice.js';

const ManageUsersTable = () => {
const dispatch = useDispatch();
Expand Down
4 changes: 2 additions & 2 deletions src/features/projects/SidebarNav.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { selectUserCurrentRoles, selectUserHasBetaAccess } from '../user/userSlice';
import { selectUserCurrentRoles, selectUserHasBetaAccess } from '../auth/authSlice';
import {
hasRole,
WRITE_AUTOMATION_RULES_ROLES,
WRITE_VIEWS_ROLES,
WRITE_IMAGES_ROLES,
MANAGE_USERS_ROLES,
} from '../../auth/roles';
} from '../auth/roles';
import { styled } from '../../theme/stitches.config.js';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const initialState = {
}
}

export const userSlice = createSlice({
export const usersSlice = createSlice({
name: 'users',
initialState,
reducers: {
Expand Down Expand Up @@ -129,7 +129,7 @@ export const {
cancel,
clearUsers,
dismissManageUsersError
} = userSlice.actions;
} = usersSlice.actions;

export const fetchUsers = () => {
return async (dispatch, getState) => {
Expand Down Expand Up @@ -211,4 +211,4 @@ export const selectSelectedUser = state => state.users.selectedUser;
export const selectUsersLoading = state => state.users.loadingStates.users.isLoading;
export const selectManageUserErrors = state => state.users.loadingStates.users.errors;

export default userSlice.reducer;
export default usersSlice.reducer;
4 changes: 2 additions & 2 deletions src/pages/AppPage.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { selectUserUsername, selectUserAuthStatus } from '../features/user/userSlice.js';
import { selectUserUsername, selectUserAuthStatus } from '../features/auth/authSlice.js';
import { Page } from '../components/Page.jsx';
import ViewExplorer from '../features/projects/ViewExplorer.jsx';
import LoginForm from '../features/user/LoginForm.jsx';
import LoginForm from '../features/auth/LoginForm.jsx';

const AppPage = () => {
const authStatus = useSelector(selectUserAuthStatus);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/CreateProjectPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { useSelector } from 'react-redux';

import { Page } from '../components/Page.jsx';
import { NotFound } from '../components/NotFound.jsx'
import { selectUserUsername, selectUserAuthStatus, selectUserIsSuperUser } from '../features/user/userSlice.js';
import LoginForm from '../features/user/LoginForm.jsx';
import { selectUserUsername, selectUserAuthStatus, selectUserIsSuperUser } from '../features/auth/authSlice.js';
import LoginForm from '../features/auth/LoginForm.jsx';
import CreateProjectForm from '../features/projects/CreateProjectForm.jsx';

const CreateProjectPage = () => {
Expand Down

0 comments on commit 1947028

Please sign in to comment.