Skip to content

Commit

Permalink
Fix for 3.14 #1267
Browse files Browse the repository at this point in the history
  • Loading branch information
olemp committed Nov 7, 2023
1 parent b3dfea7 commit 62f5a68
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,60 +20,61 @@ export function useToolbarItems() {
const createNewStatusReport = useCreateNewStatusReport()
const deleteReport = useDeleteReport()
const publishReport = usePublishReport()
const hasUnpublishedReports = state.data.reports.some((report) => !report.published)

const menuItems = useMemo<ListMenuItem[]>(
() =>
[
new ListMenuItem(
strings.NewStatusReportLabel,
!any(state.data.reports, (report) => !report.published)
!hasUnpublishedReports
? state.userHasAdminPermission
? strings.NewStatusReportDescription
: strings.NewStatusReportDescriptionNoPermission
: strings.UnpublishedStatusReportInfo
)
.setDisabled(
state.data.reports.some((report) => !report.published) ||
!state.selectedReport?.published ||
state.isPublishing ||
!state.userHasAdminPermission
hasUnpublishedReports ||
(state.selectedReport && !state.selectedReport?.published) ||
state.isPublishing ||
!state.userHasAdminPermission
)
.setIcon('QuizNew')
.setOnClick(() => {
createNewStatusReport()
}),
state.selectedReport &&
new ListMenuItem(
strings.EditReportButtonLabel,
!state.selectedReport?.published
? state.userHasAdminPermission
? strings.EditReportButtonDescription
: strings.EditReportButtonDescriptionNoPermission
: strings.PublishedStatusReportInfo
new ListMenuItem(
strings.EditReportButtonLabel,
!state.selectedReport?.published
? state.userHasAdminPermission
? strings.EditReportButtonDescription
: strings.EditReportButtonDescriptionNoPermission
: strings.PublishedStatusReportInfo
)
.setDisabled(
state.selectedReport?.published || state.isPublishing || !state.userHasAdminPermission
)
.setDisabled(
state.selectedReport?.published || state.isPublishing || !state.userHasAdminPermission
)
.setIcon('Edit')
.setOnClick(() => {
dispatch(OPEN_PANEL({ name: 'EditStatusPanel' }))
}),
.setIcon('Edit')
.setOnClick(() => {
dispatch(OPEN_PANEL({ name: 'EditStatusPanel' }))
}),
state.selectedReport &&
new ListMenuItem(
state.isPublishing ? strings.PublishingReportLabel : strings.PublishReportButtonLabel,
!state.selectedReport?.published
? state.userHasAdminPermission
? strings.PublishReportButtonDescription
: strings.PublishReportButtonDescriptionNoPermission
: strings.AlreadyPublishedReportInfo
new ListMenuItem(
state.isPublishing ? strings.PublishingReportLabel : strings.PublishReportButtonLabel,
!state.selectedReport?.published
? state.userHasAdminPermission
? strings.PublishReportButtonDescription
: strings.PublishReportButtonDescriptionNoPermission
: strings.AlreadyPublishedReportInfo
)
.setDisabled(
state.selectedReport?.published || state.isPublishing || !state.userHasAdminPermission
)
.setDisabled(
state.selectedReport?.published || state.isPublishing || !state.userHasAdminPermission
)
.setIcon('CloudArrowUp')
.setOnClick(() => {
publishReport()
})
.setIcon('CloudArrowUp')
.setOnClick(() => {
publishReport()
})
].filter(Boolean),
[state]
)
Expand All @@ -82,19 +83,19 @@ export function useToolbarItems() {
() =>
[
state.sourceUrl &&
new ListMenuItem(strings.NavigateToSourceUrlText, strings.NavigateToSourceUrlText)
.setIcon('ArrowLeft')
.setOnClick(() => {
window.open(state.sourceUrl, '_self')
}),
new ListMenuItem(strings.NavigateToSourceUrlText, strings.NavigateToSourceUrlText)
.setIcon('ArrowLeft')
.setOnClick(() => {
window.open(state.sourceUrl, '_self')
}),
state.selectedReport &&
new ListMenuItem(strings.GetSnapshotButtonLabel, strings.GetSnapshotButtonDescription)
.setDisabled(!state.selectedReport?.snapshotUrl || state.isPublishing)
.setIcon('Image')
.setWidth('fit-content')
.setOnClick(() => {
window.open(state.selectedReport?.snapshotUrl, '_self')
}),
new ListMenuItem(strings.GetSnapshotButtonLabel, strings.GetSnapshotButtonDescription)
.setDisabled(!state.selectedReport?.snapshotUrl || state.isPublishing)
.setIcon('Image')
.setWidth('fit-content')
.setOnClick(() => {
window.open(state.selectedReport?.snapshotUrl, '_self')
}),
new ListMenuItem(
state.selectedReport
? formatDate(state.selectedReport.created)
Expand Down Expand Up @@ -123,21 +124,21 @@ export function useToolbarItems() {
{ report: [formatDate(state.selectedReport?.created, true)] }
),
state.selectedReport &&
new ListMenuItem(
strings.DeleteReportButtonLabel,
!state.selectedReport?.published
? state.userHasAdminPermission
? strings.DeleteReportButtonDescription
: strings.DeleteReportButtonDescriptionNoPermission
: strings.PublishedStatusReportInfo
new ListMenuItem(
strings.DeleteReportButtonLabel,
!state.selectedReport?.published
? state.userHasAdminPermission
? strings.DeleteReportButtonDescription
: strings.DeleteReportButtonDescriptionNoPermission
: strings.PublishedStatusReportInfo
)
.setDisabled(
state.selectedReport?.published || state.isPublishing || !state.userHasAdminPermission
)
.setDisabled(
state.selectedReport?.published || state.isPublishing || !state.userHasAdminPermission
)
.setIcon('Delete')
.setOnClick(() => {
deleteReport()
})
.setIcon('Delete')
.setOnClick(() => {
deleteReport()
})
].filter(Boolean),
[state]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export const CLOSE_PANEL = createAction('CLOSE_PANEL')
* The initial state for the project status reducer.
*/
export const initialState: IProjectStatusState = {
selectedReport: new StatusReport(),
data: {
reports: [],
sections: Array.apply(null, Array(6)).map(() => new SectionModel({ ContentTypeId: '' })),
Expand Down

0 comments on commit 62f5a68

Please sign in to comment.