Skip to content
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

Fiks for uthenting av prosjektinformasjon for brukere uten tilgang til hubområdet #1088

Merged
merged 5 commits into from
Apr 19, 2023
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Sjekk ut [release notes](./releasenotes/1.8.0.md) for høydepunkter og mer detal

### Feilrettinger

- Fiks for uthenting av prosjektinformasjon for brukere uten tilgang til hubområdet [#1080](https://github.com/Puzzlepart/prosjektportalen365/issues/1080)
- Håndterer deaktiverte/stengte kontoer i kopiering av tillatelseskonfigurasjon [#1085](https://github.com/Puzzlepart/prosjektportalen365/issues/1085)

## 1.8.1 - 31.03.2023
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ export interface IProjectInformationState
properties?: ProjectPropertyModel[]

/**
* All Properties
* All properties (used for the properties panel)
*/
allProperties?: ProjectPropertyModel[]

/**
* Progress
* Progress dialog props
*/
progress?: IProgressDialogProps

Expand Down Expand Up @@ -151,7 +151,7 @@ export interface IProjectInformationState
userHasEditPermission?: boolean

/**
* Is Project data synced
* Is project data synced
*/
isProjectDataSynced?: boolean
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { MessageBarType } from '@fluentui/react'
import { LogLevel } from '@pnp/logging'
import strings from 'ProjectWebPartsStrings'
import _ from 'lodash'
import { ProjectAdminPermission } from 'pp365-shared/lib/data/SPDataAdapterBase/ProjectAdminPermission'
import { ListLogger } from 'pp365-shared/lib/logging'
import strings from 'ProjectWebPartsStrings'
import { ProjectColumnConfig, SectionModel, StatusReport } from 'pp365-shared/lib/models'
import { useEffect } from 'react'
import { isEmpty } from 'underscore'
import { ProjectInformation } from '.'
Expand Down Expand Up @@ -78,6 +79,35 @@ const checkProjectDataSynced: DataFetchFunction<IProjectInformationProps, boolea
}
}

/**
* Fetch project status reports, sections and column config if `props.hideStatusReport` is false.
* Catches errors and returns empty arrays to support e.g. the case where the user does not have
* access to the hub site.
*
* @param props Component properties for `ProjectInformation`
*/
const fetchProjectStatusReports: DataFetchFunction<
IProjectInformationProps,
[StatusReport[], SectionModel[], ProjectColumnConfig[]]
> = async (props) => {
if (props.hideStatusReport) {
return [[], [], []]
}
try {
const [reports, sections, columnConfig] = await Promise.all([
SPDataAdapter.portal.getStatusReports({
filter: `(GtSiteId eq '${props.siteId}') and GtModerationStatus eq '${strings.GtModerationStatus_Choice_Published}'`,
publishedString: strings.GtModerationStatus_Choice_Published
}),
SPDataAdapter.portal.getProjectStatusSections(),
SPDataAdapter.portal.getProjectColumnConfig()
])
return [reports, sections, columnConfig]
} catch (error) {
return [[], [], []]
}
}

/**
* Fetch data for `ProjectInformation` component. This function is used in
* `useProjectInformationDataFetch` hook.
Expand All @@ -103,9 +133,7 @@ const fetchData: DataFetchFunction<
columns,
propertiesData,
parentProjects,
reports,
sections,
columnConfig
[reports, sections, columnConfig]
] = await Promise.all([
SPDataAdapter.portal.getProjectColumns(),
SPDataAdapter.project.getPropertiesData(),
Expand All @@ -115,16 +143,7 @@ const fetchData: DataFetchFunction<
ProjectInformationParentProject
)
: Promise.resolve([]),
props.hideStatusReport
? Promise.resolve([])
: SPDataAdapter.portal.getStatusReports({
filter: `(GtSiteId eq '${props.siteId}') and GtModerationStatus eq '${strings.GtModerationStatus_Choice_Published}'`,
publishedString: strings.GtModerationStatus_Choice_Published
}),
props.hideStatusReport
? Promise.resolve([])
: SPDataAdapter.portal.getProjectStatusSections(),
props.hideStatusReport ? Promise.resolve([]) : SPDataAdapter.portal.getProjectColumnConfig()
fetchProjectStatusReports(props)
])
const data: IProjectInformationData = {
columns,
Expand Down