-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Display remote configuration components in Alloy's local UI (#1472)
Signed-off-by: Paschalis Tsilias <[email protected]>
- Loading branch information
1 parent
5206290
commit 2c56755
Showing
12 changed files
with
180 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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,46 @@ | ||
import { faCubes } from '@fortawesome/free-solid-svg-icons'; | ||
|
||
import ComponentList from '../features/component/ComponentList'; | ||
import { ComponentInfo, SortOrder } from '../features/component/types'; | ||
import Page from '../features/layout/Page'; | ||
import { useComponentInfo } from '../hooks/componentInfo'; | ||
|
||
const fieldMappings: { [key: string]: (comp: ComponentInfo) => string | undefined } = { | ||
Health: (comp) => comp.health?.state?.toString(), | ||
ID: (comp) => comp.localID, | ||
// Add new fields if needed here. | ||
}; | ||
|
||
function getSortValue(component: ComponentInfo, field: string): string | undefined { | ||
const valueGetter = fieldMappings[field]; | ||
return valueGetter ? valueGetter(component) : undefined; | ||
} | ||
|
||
function PageRemoteComponentList() { | ||
const [components, setComponents] = useComponentInfo('', true); | ||
|
||
// TODO: make this sorting logic reusable | ||
const handleSorting = (sortField: string, sortOrder: SortOrder): void => { | ||
if (!sortField || !sortOrder) return; | ||
const sorted = [...components].sort((a, b) => { | ||
const sortValueA = getSortValue(a, sortField); | ||
const sortValueB = getSortValue(b, sortField); | ||
if (!sortValueA) return 1; | ||
if (!sortValueB) return -1; | ||
return ( | ||
sortValueA.localeCompare(sortValueB, 'en', { | ||
numeric: true, | ||
}) * (sortOrder === SortOrder.ASC ? 1 : -1) | ||
); | ||
}); | ||
setComponents(sorted); | ||
}; | ||
|
||
return ( | ||
<Page name="Remote Configuration" desc="List of remote configuration pipelines" icon={faCubes}> | ||
<ComponentList components={components} useRemotecfg={true} handleSorting={handleSorting} /> | ||
</Page> | ||
); | ||
} | ||
|
||
export default PageRemoteComponentList; |
Oops, something went wrong.