-
Notifications
You must be signed in to change notification settings - Fork 3
Notification Pages Slice Removal #911
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
Open
nbeatty-gpa
wants to merge
35
commits into
master
Choose a base branch
from
notificationPaginationFixes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
1c63e3c
move byReport away from slices
nbeatty-gpa edcf35d
move cell carrier away from slices
nbeatty-gpa 2704a4a
remove cell carrier slice
nbeatty-gpa 88409f9
remove email category slice
nbeatty-gpa 4cb451a
remove scheduledEmailType slice
nbeatty-gpa 7f10c50
remove scheduledDataSourceSetting slice
nbeatty-gpa de5a8c4
remove emailType slice
nbeatty-gpa 12a4234
remove eventSubscription slice
nbeatty-gpa 76b26a4
remove assetGroupSlice
nbeatty-gpa a97c876
remove settings slice
nbeatty-gpa f98df45
remove ReportSubscription slice
nbeatty-gpa 29effdb
remove activeSubscription slice
nbeatty-gpa 852566f
remove activeReportSubscription slice
nbeatty-gpa 39a8d08
fix data request
nbeatty-gpa 56c6d87
fix data request
nbeatty-gpa 9f83e48
remove eventTypeSlice
nbeatty-gpa ce4d517
remove userAccountSlice
nbeatty-gpa 157676d
remove triggeredDataSourceSlice
nbeatty-gpa 4abd12f
remove ScheduledEmailDataSource slice
nbeatty-gpa 6d815b1
remove triggeredEmailDataSource slice
nbeatty-gpa 44cc697
catch straggler
nbeatty-gpa d5a6af8
remove scheduledDataSource slice
nbeatty-gpa c9d5350
fix dependency arrays
nbeatty-gpa ac03d7e
fix use Effects
nbeatty-gpa 6273200
fix use Effects
nbeatty-gpa 7e5892a
fix use Effects
nbeatty-gpa 2e268ab
fix
nbeatty-gpa 4968331
remove eventRecord slices, replacing DefaultSelects with a common com…
nbeatty-gpa 52514c3
move additional fields to end of filterable columns
nbeatty-gpa 4f20e12
remove unneeded console message
nbeatty-gpa 7d59eaf
cleanup event filters
nbeatty-gpa 338144b
cleanup use effect
nbeatty-gpa 978c799
fix missing parentID
nbeatty-gpa 38e0290
guard against network requests with invalid emailTypeID
nbeatty-gpa d476f89
selects cleanup
nbeatty-gpa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
208 changes: 208 additions & 0 deletions
208
.../Applications/SystemCenterNotification/Scripts/TSX/CommonComponents/ControllerSelects.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,208 @@ | ||
| //****************************************************************************************************** | ||
| // ControllerSelects.tsx - Gbtc | ||
| // | ||
| // Copyright © 2026, Grid Protection Alliance. All Rights Reserved. | ||
| // | ||
| // Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See | ||
| // the NOTICE file distributed with this work for additional information regarding copyright ownership. | ||
| // The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this | ||
| // file except in compliance with the License. You may obtain a copy of the License at: | ||
| // | ||
| // http://opensource.org/licenses/MIT | ||
| // | ||
| // Unless agreed to in writing, the subject software distributed under the License is distributed on an | ||
| // "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the | ||
| // License for the specific language governing permissions and limitations. | ||
| // | ||
| // Code Modification History: | ||
| // ---------------------------------------------------------------------------------------------------- | ||
| // 07/15/2026 - N. Beatty | ||
| // Generated original version of source code. | ||
| // | ||
| //****************************************************************************************************** | ||
|
|
||
| import _ from "lodash"; | ||
| import * as React from 'react'; | ||
| import { Application } from '@gpa-gemstone/application-typings'; | ||
| import { ReactIcons } from '@gpa-gemstone/gpa-symbols'; | ||
| import { GenericController, Modal, Search } from '@gpa-gemstone/react-interactive'; | ||
| import { Column, ConfigurableColumn, FilterableColumn, Paging, Table } from '@gpa-gemstone/react-table'; | ||
|
|
||
| interface IProps<T> { | ||
| Controller: GenericController<T>, | ||
| Show: boolean, | ||
| Title: string, | ||
| Selection: T[], | ||
| PrimaryKey: keyof T, | ||
| OnClose: (selected: T[], conf: boolean) => void, | ||
| Searchbar: (children: React.ReactNode, SetFilter: (filters: Search.IFilter<T>[]) => void, SearchStatus: Application.Types.Status, ResultCount: number) => React.ReactNode, | ||
| MinSelection: number, | ||
| Type?: 'single' | 'multiple', | ||
| DefaultSortField: keyof T, | ||
| children?: React.ReactNode | ||
| } | ||
|
|
||
| export const ControllerSelects = <T,>(props: IProps<T>) => { | ||
| const [data, setData] = React.useState<T[]>([]); | ||
| const [filters, setFilters] = React.useState<Search.IFilter<T>[]>([]); | ||
| const [sortField, setSortField] = React.useState<keyof T>(props.DefaultSortField); | ||
| const [ascending, setAscending] = React.useState<boolean>(true); | ||
| const [activePage, setActivePage] = React.useState<number>(0); | ||
| const [totalPages, setTotalPages] = React.useState<number>(0); | ||
| const [totalRecords, setTotalRecords] = React.useState<number>(0); | ||
| const [searchStatus, setSearchStatus] = React.useState<Application.Types.Status>('uninitiated'); | ||
|
|
||
| const [selectedData, setSelectedData] = React.useState<T[]>(props.Selection); | ||
| const [sortKeySelected, setSortKeySelected] = React.useState<string>(''); | ||
| const [ascendingSelected, setAscendingSelected] = React.useState<boolean>(false); | ||
|
|
||
| //keep the active page valid when the filtered result set shrinks | ||
| React.useEffect(() => { | ||
| if (totalPages > 0 && activePage >= totalPages) | ||
| setActivePage(totalPages - 1); | ||
| }, [totalPages, activePage]); | ||
|
|
||
| React.useEffect(() => { | ||
| setSelectedData(props.Selection); | ||
| }, [props.Selection]) | ||
|
|
||
| // when controller is changed, use default sort field. | ||
| React.useEffect(() => { | ||
| setSortField(props.DefaultSortField); | ||
| },[props.Controller, props.DefaultSortField]) | ||
|
|
||
| React.useEffect(() => { | ||
| setSearchStatus('loading') | ||
| const h = props.Controller.PagedSearch(filters, sortField, ascending, activePage); | ||
| h.done((d) => { | ||
| setData(JSON.parse(d.Data)); | ||
| setTotalPages(d.NumberOfPages); | ||
| setTotalRecords(d.TotalRecords); | ||
| setSearchStatus('idle') | ||
| }) | ||
| h.fail(() => setSearchStatus('error')) | ||
| return function cleanup() { | ||
| if (h != null && h.abort != null) | ||
| h.abort(); | ||
| } | ||
| }, [props.Controller, filters, sortField, ascending, activePage]) | ||
|
|
||
| return ( | ||
| <Modal | ||
| Show={props.Show} | ||
| Title={props.Title} | ||
| CallBack={(conf) => props.OnClose(selectedData, conf)} | ||
| ShowX={true} | ||
| Size={'xlg'} | ||
| BodyStyle={{ display: 'flex', flexDirection: 'column', height: 'calc(100vh - 210px)', overflow: 'hidden' }} | ||
| DisableConfirm={props.MinSelection !== undefined && selectedData.length < props.MinSelection} | ||
| ConfirmShowToolTip={props.MinSelection !== undefined && selectedData.length < props.MinSelection} | ||
| ConfirmToolTipContent={ | ||
| <p> | ||
| <ReactIcons.CrossMark /> At least {props.MinSelection} items must be selected. | ||
| </p> | ||
| } | ||
| > | ||
|
|
||
| <div className="row" style={{ flexShrink: 0 }}> | ||
| <div className="col" style={{ width: (props.Type === undefined || props.Type === 'single' ? '100%' : '60%') }}> | ||
| {props.Searchbar( | ||
| <> | ||
| {React.Children.map(props.children, (e) => { | ||
| if (React.isValidElement(e)) { | ||
| if (((e as React.ReactElement).type === FilterableColumn) || | ||
| ((e as React.ReactElement).type === Column) || | ||
| ((e as React.ReactElement).type === ConfigurableColumn) | ||
| ) return null; | ||
| return e; | ||
| } | ||
| return null; | ||
| })} | ||
| </>, setFilters, searchStatus, totalRecords)} | ||
| </div> | ||
| {props.Type === 'multiple' ? <div className="col" style={{ width: '40%', borderLeft: '1px solid #dee2e6' }}> | ||
| <h3> Current Selection </h3> | ||
| </div> : null} | ||
| </div> | ||
| <div className="row d-flex" style={{ flex: 1, overflow: 'hidden'}}> | ||
| <div className="col d-flex h-100" style={{ width: (props.Type === undefined || props.Type === 'single' ? '100%' : '60%') }}> | ||
| <Table<T> | ||
| TableClass="table table-hover h-100" | ||
| Data={data} | ||
| SortKey={sortField as string} | ||
| Ascending={ascending} | ||
| OnSort={(d) => { | ||
| if (d.colKey === "Scroll") | ||
| return; | ||
| if (d.colKey === sortField) | ||
| setAscending(!ascending); | ||
| else { | ||
| setSortField(d.colField as keyof T); | ||
| setAscending(true); | ||
| } | ||
| }} | ||
| OnClick={(d, e) => { | ||
| //the table fires OnClick for both the clicked cell and the bubbled row, so stop | ||
| //propagation to avoid a double toggle that would immediately deselect the row | ||
| e.stopPropagation(); | ||
| setSelectedData((s) => { | ||
| const isSelected = s.findIndex(item => item[props.PrimaryKey] === d.row[props.PrimaryKey]) > -1; | ||
|
|
||
| if (isSelected) | ||
| return s.filter(item => item[props.PrimaryKey] !== d.row[props.PrimaryKey]); | ||
|
|
||
| if (props.Type === undefined || props.Type === 'single') | ||
| return [d.row] | ||
|
|
||
| return [...s, d.row] | ||
| }) | ||
| }} | ||
| Selected={(item) => selectedData.findIndex(d => d[props.PrimaryKey] === item[props.PrimaryKey]) > -1} | ||
| KeySelector={item => item[props.PrimaryKey] as string | number} | ||
| > | ||
| {props.children} | ||
| </Table> | ||
| </div> | ||
| {props.Type === 'multiple' ? <div className="col h-100" style={{ width: '40%', borderLeft: '1px solid #dee2e6' }}> | ||
| <Table<T> | ||
| TableClass="table table-hover h-100" | ||
| Data={selectedData} | ||
| SortKey={sortKeySelected} | ||
| Ascending={ascendingSelected} | ||
| OnSort={(d) => { | ||
| if (d.colKey === sortKeySelected) { | ||
| const ordered = _.orderBy<T[]>(selectedData, [d.colKey], [(!ascendingSelected ? "asc" : "desc")]) as T[]; | ||
| setAscendingSelected(!ascendingSelected); | ||
| setSelectedData(ordered); | ||
| } | ||
| else { | ||
| const ordered = _.orderBy(selectedData, [d.colKey], ["asc"]) as T[]; | ||
| setAscendingSelected(!ascendingSelected); | ||
| setSelectedData(ordered); | ||
| setSortKeySelected(d.colKey); | ||
| } | ||
| }} | ||
| OnClick={(d) => setSelectedData([...selectedData.filter(item => item[props.PrimaryKey] !== d.row[props.PrimaryKey])])} | ||
| Selected={() => false} | ||
| KeySelector={item => item[props.PrimaryKey] as string | number} | ||
| > | ||
| {props.children} | ||
| </Table> | ||
| </div> : null} | ||
| </div> | ||
| <div className="row" style={{ flexShrink: 0 }}> | ||
| <div className="col" style={{ width: (props.Type === undefined || props.Type === 'single' ? '100%' : '60%') }}> | ||
| <Paging | ||
| Current={activePage + 1} | ||
| Total={totalPages} | ||
| SetPage={(p) => setActivePage(p - 1)} | ||
| /> | ||
| </div> | ||
| {props.Type === 'multiple' ? | ||
| <div className="col" style={{ width: '40%' }} /> | ||
| : null | ||
| } | ||
| </div> | ||
| </Modal> | ||
| ) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.