Skip to content

Commit

Permalink
Rename userEditPerms to canEditPlotInformation
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWags committed Oct 30, 2024
1 parent 4079066 commit 9ecb9eb
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ const main = () => {
- `visualizeAttributes` (optional)(`string[]`): List of attribute names (strings) which should be visualized. Defaults to the first 3 if no value is provided. If an empty list is provided, displays no attributes.
- `visualizeUpsetAttributes` (optional)(`boolean`): Whether or not to visualize UpSet generated attributes (`degree` and `deviation`). Defaults to `false`.
- `allowAttributeRemoval` (optional)(`boolean`): Whether or not to allow the user to remove attribute columns. This should be enabled only if there is an option within the parent application which allows for attributes to be added after removal. Default attribute removal behavior in UpSet 2.0 is done via context menu on attribute headers. Defaults to `false`.
- `userEditPerms` (optional)(`boolean`): Whether or not the user has plot information edit permissions.
- `canEditPlotInformation` (optional)(`boolean`): Whether or not the user can edit the plot information in the text descriptions sidebar.
- `hideSettings` (optional)(`boolean`): Hide the aggregations/filter settings sidebar.
- `parentHasHeight` (optional)(`boolean`): Indicates if the parent component has a fixed height. If this is set to `false`, the plot will occupy the full viewport height. When set to `true`, the plot will fit entirely within the parent component. Defaults to `false`.
- `extProvenance` (optional): External provenance actions and [TrrackJS](https://github.com/Trrack/trrackjs) object for provenance history tracking and actions. This should only be used if your tool is using TrrackJS and the Trrack object you provide has all the actions used by UpSet 2.0. Provenance is still tracked if nothing is provided. See [App.tsx](https://github.com/visdesignlab/upset2/blob/main/packages/app/src/App.tsx) to see how UpSet 2.0 and Multinet use an external Trrack object. Note that [initializeProvenanceTracking](https://github.com/visdesignlab/upset2/blob/main/packages/upset/src/provenance/index.ts#L300) and [getActions](https://github.com/visdesignlab/upset2/blob/main/packages/upset/src/provenance/index.ts#L322) are used to ensure that the provided provenance object is compatible. The provided provenance object must have a type compatible with the [extProvenance](https://vdl.sci.utah.edu/upset2/interfaces/_visdesignlab_upset2_react.UpsetProps.html#extProvenance) UpSet 2.0 prop type.
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/components/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const Body = ({ data, config }: Props) => {
<Upset
data={data}
extProvenance={provObject}
userEditPerms={permissions}
canEditPlotInformation={permissions}
config={config}
provVis={provVis}
elementSidebar={elementSidebar}
Expand Down
6 changes: 6 additions & 0 deletions packages/upset/src/atoms/config/canEditPlotInformationAtom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { atom } from 'recoil';

export const canEditPlotInformationAtom = atom<boolean>({
key: 'canEditPlotInformationAtom',
default: false,
});
6 changes: 0 additions & 6 deletions packages/upset/src/atoms/config/userEditPermsAtoms.ts

This file was deleted.

12 changes: 6 additions & 6 deletions packages/upset/src/components/AltTextSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import '../index.css';
import { PlotInformation } from './custom/PlotInformation';
import { UpsetActions } from '../provenance';
import { plotInformationSelector } from '../atoms/config/plotInformationAtom';
import { userEditPermsAtom } from '../atoms/config/userEditPermsAtoms';
import { canEditPlotInformationAtom } from '../atoms/config/canEditPlotInformationAtoms';

/**
* Props for the AltTextSidebar component.
Expand Down Expand Up @@ -67,7 +67,7 @@ export const AltTextSidebar: FC<Props> = ({ open, close, generateAltText }) => {

const { actions }: {actions: UpsetActions} = useContext(ProvenanceContext);
const currState = useRecoilValue(upsetConfigAtom);
const userEditPerms = useRecoilValue(userEditPermsAtom);
const canEditPlotInformation = useRecoilValue(canEditPlotInformationAtom);
const [altText, setAltText] = useState<AltText | null>(null);
const [textGenErr, setTextGenErr] = useState<string | false>(false);
const [textEditing, setTextEditing] = useState(false);
Expand All @@ -87,7 +87,7 @@ export const AltTextSidebar: FC<Props> = ({ open, close, generateAltText }) => {
const saveButtonClick: () => void = useCallback(() => {
// if the user doesn't have edit permissions, don't allow saving
// The user shouldn't be able to edit in this case, but this is a failsafe
if (!userEditPerms) return;
if (!canEditPlotInformation) return;

setTextEditing(false);
if (!currState.useUserAlt) actions.setUseUserAltText(true);
Expand All @@ -101,7 +101,7 @@ export const AltTextSidebar: FC<Props> = ({ open, close, generateAltText }) => {
const enableTextEditing: () => void = useCallback(() => {
// if the user doesn't have edit permissions, don't allow editing
// The button should be hidden in this case, but this is a failsafe
if (!userEditPerms) return;
if (!canEditPlotInformation) return;

setTextEditing(true);
if (!currState.userAltText?.shortDescription) setUserShortText(altText?.shortDescription);
Expand Down Expand Up @@ -217,7 +217,7 @@ export const AltTextSidebar: FC<Props> = ({ open, close, generateAltText }) => {
/>
) : (
// only show "Add Plot Information" if the user has edit permissions
userEditPerms ? (
canEditPlotInformation ? (
<Button
onClick={() => setPlotInfoEditing(true)}
tabIndex={PLOT_INFO_TAB_INDEX}
Expand Down Expand Up @@ -281,7 +281,7 @@ export const AltTextSidebar: FC<Props> = ({ open, close, generateAltText }) => {
}}
tabIndex={3}
>
{userEditPerms && (
{canEditPlotInformation && (
// Only show the edit button if the user has edit permissions
<Button
style={{
Expand Down
14 changes: 7 additions & 7 deletions packages/upset/src/components/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { dataAtom } from '../atoms/dataAtom';
import { allowAttributeRemovalAtom } from '../atoms/config/allowAttributeRemovalAtom';
import { contextMenuAtom } from '../atoms/contextMenuAtom';
import { upsetConfigAtom } from '../atoms/config/upsetConfigAtoms';
import { userEditPermsAtom } from '../atoms/config/userEditPermsAtoms';
import { canEditPlotInformationAtom } from '../atoms/config/canEditPlotInformationAtoms';
import {
getActions, initializeProvenanceTracking, UpsetActions, UpsetProvenance,
} from '../provenance';
Expand Down Expand Up @@ -42,7 +42,7 @@ type Props = {
config: UpsetConfig;
allowAttributeRemoval?: boolean;
hideSettings?: boolean;
userEditPerms?: boolean;
canEditPlotInformation?: boolean;
extProvenance?: {
provenance: UpsetProvenance;
actions: UpsetActions;
Expand All @@ -63,13 +63,13 @@ type Props = {
};

export const Root: FC<Props> = ({
data, config, allowAttributeRemoval, hideSettings, userEditPerms, extProvenance, provVis, elementSidebar, altTextSidebar, generateAltText,
data, config, allowAttributeRemoval, hideSettings, canEditPlotInformation, extProvenance, provVis, elementSidebar, altTextSidebar, generateAltText,
}) => {
// Get setter for recoil config atom
const setState = useSetRecoilState(upsetConfigAtom);
const [sets, setSets] = useRecoilState(setsAtom);
const [items, setItems] = useRecoilState(itemsAtom);
const setUserEditPerms = useSetRecoilState(userEditPermsAtom);
const setcanEditPlotInformation = useSetRecoilState(canEditPlotInformationAtom);
const setAttributeColumns = useSetRecoilState(attributeAtom);
const setAllColumns = useSetRecoilState(columnsAtom);
const setData = useSetRecoilState(dataAtom);
Expand All @@ -82,10 +82,10 @@ export const Root: FC<Props> = ({
}, []);

useEffect(() => {
if (userEditPerms !== undefined) {
setUserEditPerms(userEditPerms);
if (canEditPlotInformation !== undefined) {
setcanEditPlotInformation(canEditPlotInformation);
}
}, [userEditPerms]);
}, [canEditPlotInformation]);

// Initialize Provenance and pass it setter to connect
const { provenance, actions } = useMemo(() => {
Expand Down
6 changes: 3 additions & 3 deletions packages/upset/src/components/Upset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const defaultVisibleSets = 6;
* @param {boolean} [allowAttributeRemoval=false] - Whether or not to allow the user to remove attribute columns. This should be enabled only if there is an option within the parent application which allows for attributes to be added after removal. Default attribute removal behavior in UpSet 2.0 is done via context menu on attribute headers. Defaults to `false`.
* @param {boolean} [hideSettings] - Hide the aggregations/filter settings sidebar.
* @param {boolean} [parentHasHeight=false] - Indicates if the parent component has a fixed height. If this is set to `false`, the plot will occupy the full viewport height. When set to `true`, the plot will fit entirely within the parent component. Defaults to `false`.
* @param {boolean} [userEditPerms=false] - Whether or not the user has plot information edit permissions.
* @param {boolean} [canEditPlotInformation=false] - Whether or not the user has plot information edit permissions.
* @param {Object} [extProvenance] - External provenance actions and [TrrackJS](https://github.com/Trrack/trrackjs) object for provenance history tracking and actions. This should only be used if your tool is using TrrackJS and has all the actions used by UpSet 2.0. Provenance is still tracked if nothing is provided. See [App.tsx](https://github.com/visdesignlab/upset2/blob/main/packages/app/src/App.tsx) to see how UpSet 2.0 and Multinet use an external Trrack object. Note that [initializeProvenanceTracking](https://github.com/visdesignlab/upset2/blob/main/packages/upset/src/provenance/index.ts#L300) and [getActions](https://github.com/visdesignlab/upset2/blob/main/packages/upset/src/provenance/index.ts#L322) are used to ensure that the provided provenance object is compatible.
* @param {SidebarProps} [provVis] - The provenance visualization sidebar options.
* @param {SidebarProps} [elementSidebar] - The element sidebar options. This sidebar is used for element queries, element selection datatable, and supplimental plot generation.
Expand All @@ -35,7 +35,7 @@ export const Upset: FC<UpsetProps> = ({
visualizeDatasetAttributes,
visualizeUpsetAttributes = false,
allowAttributeRemoval = false,
userEditPerms = false,
canEditPlotInformation = false,
hideSettings,
extProvenance,
provVis,
Expand Down Expand Up @@ -109,7 +109,7 @@ export const Upset: FC<UpsetProps> = ({
data={processData}
config={combinedConfig}
allowAttributeRemoval={allowAttributeRemoval}
userEditPerms={userEditPerms}
canEditPlotInformation={canEditPlotInformation}
hideSettings={hideSettings}
extProvenance={extProvenance}
provVis={provVis}
Expand Down
6 changes: 3 additions & 3 deletions packages/upset/src/components/custom/PlotInformation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
useContext, useState, useCallback,
} from 'react';
import { plotInformationSelector } from '../../atoms/config/plotInformationAtom';
import { userEditPermsAtom } from '../../atoms/config/userEditPermsAtoms';
import { canEditPlotInformationAtom } from '../../atoms/config/canEditPlotInformationAtoms';
import { ProvenanceContext } from '../Root';

/**
Expand Down Expand Up @@ -86,7 +86,7 @@ export const PlotInformation = ({
*/

const plotInformationState = useRecoilValue(plotInformationSelector);
const userEditPerms = useRecoilValue(userEditPermsAtom);
const canEditPlotInformation = useRecoilValue(canEditPlotInformationAtom);
const [plotInformation, setPlotInformation] = useState(plotInformationState);
const { actions } = useContext(ProvenanceContext);

Expand Down Expand Up @@ -144,7 +144,7 @@ export const PlotInformation = ({
}}
>
<div style={{ minHeight: '1.6em' }}>
{userEditPerms && (
{canEditPlotInformation && (
// Hide the edit button if the user does not have permissions
<Button
aria-label="Plot Information Editor"
Expand Down
2 changes: 1 addition & 1 deletion packages/upset/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export interface UpsetProps {
/**
* Whether or not the user has plot information edit permissions.
*/
userEditPerms?: boolean;
canEditPlotInformation?: boolean;

/**
* Hide the aggregations/filter settings sidebar.
Expand Down

0 comments on commit 9ecb9eb

Please sign in to comment.