Skip to content

Commit

Permalink
Merge branch 'main' into kfluxui-217
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptoRodeo authored Dec 2, 2024
2 parents 97fe747 + 850c442 commit 3f778aa
Show file tree
Hide file tree
Showing 20 changed files with 294 additions and 227 deletions.
5 changes: 2 additions & 3 deletions codecv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ coverage:
project:
default:
target: auto
threshold: 0.2%
threshold: 1%
patch:
default:
target: 80% # coverage for new/modified code
threshold: 1%
informational: true

ignore:
- "**/*__data__*/*.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { useAppApplicationTestNodes } from './useAppApplicationTestNodes';
import { useAppBuildNodes } from './useAppBuildNodes';
import { useAppComponentsNodes } from './useAppComponentsNodes';
import { useAppReleaseNodes } from './useAppReleaseNodes';
import { useAppReleasePlanNodes } from './useAppReleasePlanNodes';

export const useAppWorkflowData = (
applicationName: string,
Expand Down Expand Up @@ -63,35 +62,17 @@ export const useAppWorkflowData = (
applicationIntegrationTestNodes,
]);

const [releaseNodes, releaseGroup, releaseTasks, releasesLoaded, releasesError] =
useAppReleaseNodes(
namespace,
applicationName,
expanded ? applicationIntegrationTestTasks : [testsGroup?.id ?? ''],
expanded,
);

const [
managedEnvironmentNodes,
managedEnvironmentGroup,
managedEnvironmentsLoaded,
managedEnvironmentsError,
] = useAppReleasePlanNodes(namespace, applicationName, releaseTasks, expanded);
const [releaseNodes, releaseGroup, , releasesLoaded, releasesError] = useAppReleaseNodes(
namespace,
applicationName,
expanded ? applicationIntegrationTestTasks : [testsGroup?.id ?? ''],
expanded,
);

const allResourcesLoaded: boolean =
componentsLoaded &&
buildsLoaded &&
applicationTestsLoaded &&
releasesLoaded &&
managedEnvironmentsLoaded;
componentsLoaded && buildsLoaded && applicationTestsLoaded && releasesLoaded;

const errors = [
...componentsErrors,
...buildsErrors,
...applicationErrors,
...releasesError,
...managedEnvironmentsError,
];
const errors = [...componentsErrors, ...buildsErrors, ...applicationErrors, ...releasesError];

if (!allResourcesLoaded || errors.length > 0) {
return [{ nodes: [], edges: [] }, allResourcesLoaded, errors];
Expand All @@ -103,7 +84,6 @@ export const useAppWorkflowData = (
...(buildNodes?.length ? buildNodes : [buildGroup]),
...applicationIntegrationTestNodes,
...(releaseNodes?.length ? releaseNodes : [releaseGroup]),
...(managedEnvironmentNodes?.length ? managedEnvironmentNodes : [managedEnvironmentGroup]),
];
const spacerNodes = getSpacerNodes(resourceNodes, NodeType.SPACER_NODE);
const nodes = [
Expand All @@ -113,13 +93,12 @@ export const useAppWorkflowData = (
buildGroup,
testsGroup,
releaseGroup,
managedEnvironmentGroup,
];
const edges = getEdgesFromNodes(nodes, NodeType.SPACER_NODE);

return [{ nodes, edges }, true, errors];
}
const nodes = [componentGroup, buildGroup, testsGroup, releaseGroup, managedEnvironmentGroup];
const nodes = [componentGroup, buildGroup, testsGroup, releaseGroup];
const edges = getEdgesFromNodes(nodes, NodeType.SPACER_NODE);

return [{ nodes, edges }, true, errors];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,14 @@ export const getLinkDataForElement = (
: {
tab: 'integrationtests',
};
case WorkflowNodeType.STATIC_ENVIRONMENT:
return {
tab: 'deployments',
filter:
!groupNode && !isDisabled
? { name: 'name', value: label }
: { name: 'envType', value: 'default,static' },
};
case WorkflowNodeType.MANAGED_ENVIRONMENT:
case WorkflowNodeType.RELEASE:
return {
tab: 'deployments',
filter:
!groupNode && !isDisabled
? { name: 'name', value: label }
: { name: 'envType', value: 'managed' },
};
return !groupNode && !isDisabled
? {
path: `/workspaces/${workspace}/applications/${
element.getData().application
}/releases/${label}`,
}
: { tab: 'releases' };
default:
return {
tab: 'overview',
Expand Down
56 changes: 46 additions & 10 deletions src/components/Applications/ApplicationListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ import {
EmptyStateBody,
PageSection,
PageSectionVariants,
SearchInput,
Spinner,
Toolbar,
ToolbarContent,
ToolbarItem,
} from '@patternfly/react-core';
import { debounce } from 'lodash-es';
import emptyStateImgUrl from '../../assets/Application.svg';
import { useApplications } from '../../hooks/useApplications';
import { useSearchParam } from '../../hooks/useSearchParam';
import { ApplicationModel, ComponentModel } from '../../models';
import { Table } from '../../shared';
import AppEmptyState from '../../shared/components/empty-state/AppEmptyState';
import FilteredEmptyState from '../../shared/components/empty-state/FilteredEmptyState';
import { ApplicationKind } from '../../types';
import { useApplicationBreadcrumbs } from '../../utils/breadcrumb-utils';
import { useAccessReviewForModel } from '../../utils/rbac';
Expand All @@ -29,12 +33,29 @@ const ApplicationListView: React.FC<React.PropsWithChildren<unknown>> = () => {
const applicationBreadcrumbs = useApplicationBreadcrumbs();
const [canCreateApplication] = useAccessReviewForModel(ApplicationModel, 'create');
const [canCreateComponent] = useAccessReviewForModel(ComponentModel, 'create');
const [nameFilter, setNameFilter] = useSearchParam('name', '');

const [applications, loaded] = useApplications(namespace, workspace);
applications?.sort(
(app1, app2) =>
+new Date(app2.metadata?.creationTimestamp) - +new Date(app1.metadata?.creationTimestamp),
);
const filteredApplications = React.useMemo(() => {
const lowerCaseNameFilter = nameFilter.toLowerCase();
return applications?.filter(
(app) =>
app.spec.displayName?.toLowerCase().includes(lowerCaseNameFilter) ??
app.metadata.name.includes(lowerCaseNameFilter),
);
}, [nameFilter, applications]);

const onClearFilters = () => {
setNameFilter('');
};

const onNameInput = debounce((n: string) => {
setNameFilter(n);
}, 600);

if (!loaded) {
return (
Expand Down Expand Up @@ -86,6 +107,17 @@ const ApplicationListView: React.FC<React.PropsWithChildren<unknown>> = () => {
<>
<Toolbar usePageInsets>
<ToolbarContent>
<ToolbarItem className="pf-v5-u-ml-0">
<SearchInput
name="nameInput"
data-test="name-input-filter"
type="search"
aria-label="name filter"
placeholder="Filter by name..."
onChange={(_, n) => onNameInput(n)}
value={nameFilter}
/>
</ToolbarItem>
<ToolbarItem>
<ButtonWithAccessTooltip
variant="primary"
Expand All @@ -104,16 +136,20 @@ const ApplicationListView: React.FC<React.PropsWithChildren<unknown>> = () => {
</ToolbarItem>
</ToolbarContent>
</Toolbar>
<Table
data={applications}
aria-label="Application List"
Header={ApplicationListHeader}
Row={ApplicationListRow}
loaded
getRowProps={(obj: ApplicationKind) => ({
id: obj.metadata?.name,
})}
/>
{filteredApplications.length !== 0 ? (
<Table
data={filteredApplications}
aria-label="Application List"
Header={ApplicationListHeader}
Row={ApplicationListRow}
loaded
getRowProps={(obj: ApplicationKind) => ({
id: obj.metadata?.name,
})}
/>
) : (
<FilteredEmptyState onClearFilters={onClearFilters} />
)}
</>
)}
</PageSection>
Expand Down
Loading

0 comments on commit 3f778aa

Please sign in to comment.