Skip to content

Commit 4a407d6

Browse files
committed
wip - wf items not addressable
1 parent 14d9152 commit 4a407d6

File tree

5 files changed

+67
-4
lines changed

5 files changed

+67
-4
lines changed

frontend/src/pages/Navbar/actions.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export const SAVE_EMAIL_ADDRESS_SUCCESS = "SAVE_EMAIL_ADDRESS_SUCCESS";
3636
export const SAVE_EMAIL_ADDRESS_FAILED = "SAVE_EMAIL_ADDRESS_FAILED";
3737
export const SET_VALID_EMAIL_ADDRESS_INPUT = "SET_VALID_EMAIL_ADDRESS_INPUT";
3838

39+
export const CLIPBOARD_COPY = "CLIPBOARD_COPY";
40+
export const CLIPBOARD_PASTE = "CLIPBOARD_PASTE";
41+
3942
export function toggleSidebar() {
4043
return {
4144
type: TOGGLE_SIDEBAR
@@ -144,3 +147,16 @@ export function setValidEmailAddressInput(valid) {
144147
valid
145148
};
146149
}
150+
151+
export function clipboardCopy(text) {
152+
return {
153+
type: CLIPBOARD_COPY,
154+
text
155+
};
156+
}
157+
158+
export function clipboardPaste() {
159+
return {
160+
type: CLIPBOARD_PASTE
161+
};
162+
}

frontend/src/pages/Navbar/reducer.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
import { FETCH_ALL_SUBPROJECT_DETAILS_SUCCESS } from "../Workflows/actions";
1111

1212
import {
13+
CLIPBOARD_COPY,
14+
CLIPBOARD_PASTE,
1315
DISABLE_USER_PROFILE_EDIT,
1416
ENABLE_USER_PROFILE_EDIT,
1517
FETCH_ACTIVE_PEERS_SUCCESS,
@@ -40,7 +42,8 @@ const defaultState = fromJS({
4042
userProfileOpen: false,
4143
userProfileEdit: false,
4244
tempEmailAddress: "",
43-
isEmailAddressInputValid: true
45+
isEmailAddressInputValid: true,
46+
clipboard: null
4447
});
4548

4649
export default function navbarReducer(state = defaultState, action) {
@@ -100,6 +103,12 @@ export default function navbarReducer(state = defaultState, action) {
100103
searchTerm: defaultState.get("searchTerm"),
101104
searchBarDisplayed: defaultState.get("searchBarDisplayed")
102105
});
106+
case CLIPBOARD_COPY: {
107+
return state.set("clipboard", action.text || "");
108+
}
109+
case CLIPBOARD_PASTE: {
110+
return state.set("clipboard", null);
111+
}
103112
default:
104113
return state;
105114
}

frontend/src/pages/SubProjects/SubProjectContainer.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ class SubProjectContainer extends Component {
7171
}
7272

7373
componentDidUpdate(prevProps) {
74+
if (this.props.router.location.pathname !== prevProps.router.location.pathname) {
75+
const newProjectId = this.props.router.location.pathname.split("/")[2];
76+
if (newProjectId !== this.projectId) {
77+
this.setState({ isDataFetched: false });
78+
this.projectId = newProjectId;
79+
this.props.setSelectedView(this.projectId, "project");
80+
this.props.fetchAllProjectDetails(this.projectId, true);
81+
this.setState({ isDataFetched: true });
82+
}
83+
}
7484
const searchTermChanges = this.props.searchTerm !== prevProps.searchTerm;
7585
const projectsChange = !_isEqual(this.props.subProjects, prevProps.subProjects);
7686

frontend/src/pages/Workflows/WorkflowContainer.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import InformationDialog from "../Common/InformationDialog";
1818
import { addDocument } from "../Documents/actions";
1919
import LiveUpdates from "../LiveUpdates/LiveUpdates";
2020
import { fetchUser } from "../Login/actions";
21-
import { setSelectedView } from "../Navbar/actions";
21+
import { clipboardCopy, setSelectedView } from "../Navbar/actions";
2222
import { openHistory } from "../Notifications/actions";
2323
import SubProjectHistoryDrawer from "../SubProjects/SubProjectHistoryDrawer";
2424

@@ -275,7 +275,8 @@ const mapDispatchToProps = (dispatch, _ownProps) => {
275275
disableLiveUpdatesSubproject: () => dispatch(disableLiveUpdatesSubproject()),
276276
storeWorkflowSearchBarDisplayed: (workflowSearchBarDisplayed) =>
277277
dispatch(storeWorkflowSearchBarDisplayed(workflowSearchBarDisplayed)),
278-
storeWorkflowSearchTermArray: (searchTerms) => dispatch(storeWorkflowSearchTermArray(searchTerms))
278+
storeWorkflowSearchTermArray: (searchTerms) => dispatch(storeWorkflowSearchTermArray(searchTerms)),
279+
clipboardCopy: (text) => dispatch(clipboardCopy(text))
279280
};
280281
};
281282

@@ -325,7 +326,8 @@ const mapStateToProps = (state) => {
325326
workflowMode: state.getIn(["workflow", "workflowMode"]),
326327
workflowItemsBeforeSort: state.getIn(["workflow", "workflowItemsBeforeSort"]),
327328
workflowitemsBulkAction: state.getIn(["workflow", "workflowitemsBulkAction"]),
328-
workflowSortEnabled: state.getIn(["workflow", "workflowSortEnabled"])
329+
workflowSortEnabled: state.getIn(["workflow", "workflowSortEnabled"]),
330+
clipboard: state.getIn(["navbar", "clipboard"])
329331
};
330332
};
331333

frontend/src/pages/Workflows/WorkflowItem.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React from "react";
22
import { Draggable } from "react-beautiful-dnd";
3+
import { useLocation } from "react-router-dom";
34
import _isEmpty from "lodash/isEmpty";
45

6+
import AddLinkIcon from "@mui/icons-material/AddLink";
57
import AttachmentIcon from "@mui/icons-material/Attachment";
68
import RejectedIcon from "@mui/icons-material/Block";
79
import DoneIcon from "@mui/icons-material/Check";
@@ -200,6 +202,27 @@ const getAttachmentButton = ({ openWorkflowDetails, projectId, subProjectId }, w
200202
);
201203
};
202204

205+
const renderCopyButton = (props, workflow, location) => {
206+
const { clipboardCopy } = props;
207+
208+
return (
209+
<>
210+
<StyledBadge variant="dot" data-test={`info-warning-badge-enabled-${"someid"}`} className="button-style">
211+
<IconButton
212+
aria-label="show info"
213+
onClick={() => {
214+
clipboardCopy(location);
215+
}}
216+
data-test={`workflowitem-copy-button-${"someid"}`}
217+
size="large"
218+
>
219+
<AddLinkIcon />
220+
</IconButton>
221+
</StyledBadge>
222+
</>
223+
);
224+
};
225+
203226
const isWorkflowSelectable = (currentWorkflowSelectable, workflowSortEnabled, status, workflowMode) => {
204227
const workflowSortable = status === "open";
205228
return workflowSortEnabled ? workflowSortable : workflowMode === "unordered" ? true : currentWorkflowSelectable;
@@ -393,11 +416,13 @@ export const WorkflowItem = ({
393416
additionalData,
394417
tags
395418
} = workflow.data;
419+
const location = useLocation();
396420
const allowedIntents = workflow.allowedIntents;
397421
const workflowSelectable = isWorkflowSelectable(currentWorkflowSelectable, workflowSortEnabled, status, workflowMode);
398422
const canEditWorkflow = canUpdateWorkflowItem(allowedIntents) && status !== "closed";
399423
const infoButton = getInfoButton(props, status, workflowSortEnabled, workflow.data);
400424
const attachmentButton = getAttachmentButton(props, workflow.data);
425+
const copyButton = renderCopyButton(props, workflow, location);
401426
const canAssign = canAssignWorkflowItem(allowedIntents) && status !== "closed";
402427
const canCloseWorkflow = currentUser === assignee && workflowSelectable && status !== "closed";
403428

@@ -459,6 +484,7 @@ export const WorkflowItem = ({
459484
</div>
460485
<div className="info-cell">{infoButton}</div>
461486
<div className="info-cell">{attachmentButton}</div>
487+
<div className="info-cell">{copyButton}</div>
462488
<div className={workflowSelectable ? "workflow-cell" : "workflow-cell not-selectable"}>
463489
<Tooltip id="workflow-title" title={displayName}>
464490
<Typography variant="body2" className="workflow-item-title">

0 commit comments

Comments
 (0)