Skip to content

Commit

Permalink
Update Changelog
Browse files Browse the repository at this point in the history
w
  • Loading branch information
hannyle committed Mar 10, 2022
1 parent 5e108ee commit 13f4e65
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/e2etests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
if [[ $BRANCH == master ]]; then
echo "VERSION=master" >> $GITHUB_ENV
else
echo "VERSION=develop" >> $GITHUB_ENV
echo "VERSION=feature/project-ownership" >> $GITHUB_ENV
fi
- name: Clone backend
uses: actions/checkout@v2
Expand Down
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Folder's Id is needed when creating a new object or draft object
- Patching folder is no longer needed when patching object or draft object
- Updated projectId in GET and POST requests for folders and templates #696

### Added

- ProjectId is a mandatory query parameter in GET requests for folders and templates
- ProjectId is a mandatory propperty in POST requests for folders and templates
- Templates has a separate API endpoint and is no longer a propety under User
- Template's index is a mandatory property in PATCH request for a template

- Folder's Id is needed when creating a new object or draft object #672

### Added

- Added folderId as query parameter for object's and draft object's Post request
- Patching folder is no longer needed when patching object or draft object

- Updated Node.js version in GitHub workflows and Dockerfile #655
- Disallow use of any-type #624
Expand Down
2 changes: 1 addition & 1 deletion src/components/Home/UserDraftTemplateActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import WizardFillObjectDetailsForm from "components/NewDraftWizard/WizardForms/W
import { ResponseStatus } from "constants/responseStatus"
import { ObjectStatus } from "constants/wizardObject"
import { updateStatus } from "features/statusMessageSlice"
import { deleteTemplateByAccessionId } from "features/userSlice"
import { deleteTemplateByAccessionId } from "features/templateSlice"
import { setCurrentObject, resetCurrentObject } from "features/wizardCurrentObjectSlice"
import { setObjectType, resetObjectType } from "features/wizardObjectTypeSlice"
import { setFolder } from "features/wizardSubmissionFolderSlice"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { setDraftStatus, resetDraftStatus } from "features/draftStatusSlice"
import { setFileTypes } from "features/fileTypesSlice"
import { resetFocus } from "features/focusSlice"
import { updateStatus } from "features/statusMessageSlice"
import { updateTemplateDisplayTitle } from "features/userSlice"
import { updateTemplateDisplayTitle } from "features/templateSlice"
import { setCurrentObject, resetCurrentObject } from "features/wizardCurrentObjectSlice"
import { deleteObjectFromFolder, replaceObjectInFolder } from "features/wizardSubmissionFolderSlice"
import { useAppSelector, useAppDispatch } from "hooks"
Expand Down Expand Up @@ -246,8 +246,8 @@ const FormContent = ({
const draftStatus = useAppSelector(state => state.draftStatus)
const alert = useAppSelector(state => state.alert)
const clearForm = useAppSelector(state => state.clearForm)
const user = useAppSelector(state => state.user)

const templates = useAppSelector(state => state.templates)
const methods = useForm({ mode: "onBlur", resolver })

const [currentObjectId, setCurrentObjectId] = useState<string | null>(currentObject?.accessionId)
Expand Down Expand Up @@ -406,7 +406,6 @@ const FormContent = ({
const cleanedValues = getCleanedValues()

if (checkFormCleanedValuesEmpty(cleanedValues)) {
const templates = user.templates
const index =
templates?.findIndex((item: { accessionId: string }) => item.accessionId === currentObject.accessionId) || 0
const response = await templateAPI.patchTemplateFromJSON(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const CreateFolderForm = ({ createFolderFormRef }: { createFolderFormRef: Create
const dispatch = useAppDispatch()
const projectId = useAppSelector(state => state.projectId)
const folder = useAppSelector(state => state.submissionFolder)
const user = useAppSelector(state => state.user)
const templates = useAppSelector(state => state.templates)
const templateAccessionIds = useAppSelector(state => state.templateAccessionIds)

const {
Expand All @@ -80,8 +80,8 @@ const CreateFolderForm = ({ createFolderFormRef }: { createFolderFormRef: Create
const onSubmit = async (data: FolderDataFromForm) => {
// Transform the format of templates to drafts with proper values to be added to current folder or new folder
const selectedDraftsArray =
user.templates && folder?.folderId
? await transformTemplatesToDrafts(templateAccessionIds, user.templates, folder.folderId, dispatch)
templates && folder?.folderId
? await transformTemplatesToDrafts(templateAccessionIds, templates, folder.folderId, dispatch)
: []

if (folder && folder?.folderId) {
Expand Down
19 changes: 16 additions & 3 deletions src/features/templateSlice.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
import { createSlice } from "@reduxjs/toolkit"
import _reject from "lodash/reject"

import templateAPIService from "services/templateAPI"
import { APIResponse, DispatchReducer } from "types"
import { ObjectInsideFolderWithTags, APIResponse, DispatchReducer } from "types"

const initialState = []
const initialState: Array<ObjectInsideFolderWithTags> | [] = []

const templateSlice = createSlice({
name: "project",
initialState,
reducers: {
setTemplates: (_state, action) => action.payload,
updateTemplateDisplayTitle: (state, action) => {
const selectedTemplate = state.find(item => item.accessionId === action.payload.accessionId)
if (selectedTemplate) {
selectedTemplate.tags.displayTitle = action.payload.displayTitle
}
},
deleteTemplateByAccessionId: (state, action) => {
state = _reject(state, (template: { accessionId: string }) => {
return template.accessionId === action.payload
})
},
resetTemplates: () => initialState,
},
})
export const { setTemplates, resetTemplates } = templateSlice.actions
export const { setTemplates, updateTemplateDisplayTitle, deleteTemplateByAccessionId, resetTemplates } =
templateSlice.actions
export default templateSlice.reducer

export const getTemplates =
Expand Down
18 changes: 1 addition & 17 deletions src/features/userSlice.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createSlice } from "@reduxjs/toolkit"
import _reject from "lodash/reject"

import userAPIService from "services/usersAPI"
import type { User, APIResponse, DispatchReducer, ObjectInsideFolderWithTags } from "types"
Expand All @@ -8,32 +7,18 @@ const initialState: User = {
id: "",
name: "",
projects: [],
templates: [],
}

const userSlice = createSlice({
name: "user",
initialState,
reducers: {
setUser: (_state, action) => action.payload,
updateTemplateDisplayTitle: (state: { templates: ObjectInsideFolderWithTags[] }, action) => {
const selectedTemplate = state.templates.find(
(item: { accessionId: string }) => item.accessionId === action.payload.accessionId
)
if (selectedTemplate) {
selectedTemplate.tags.displayTitle = action.payload.displayTitle
}
},
deleteTemplateByAccessionId: (state, action) => {
state.templates = _reject(state.templates, (template: { accessionId: string }) => {
return template.accessionId === action.payload
})
},
resetUser: () => initialState,
},
})

export const { setUser, resetUser, updateTemplateDisplayTitle, deleteTemplateByAccessionId } = userSlice.actions
export const { setUser, resetUser } = userSlice.actions
export default userSlice.reducer

export const fetchUserById =
Expand All @@ -47,7 +32,6 @@ export const fetchUserById =
id: response.data.userId,
name: response.data.name,
projects: response.data.projects,
templates: [],
}
dispatch(setUser(user))
resolve(response)
Expand Down
1 change: 0 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export type User = {
id: string
name: string
projects: Array<{ projectId: string; projectNumber: string }>
templates: Array<ObjectInsideFolderWithTags>
}

export type Schema = "study" | "sample" | "experiment" | "run" | "analysis" | "dac" | "policy" | "dataset"
Expand Down

0 comments on commit 13f4e65

Please sign in to comment.