Skip to content

Commit 8d6b0ac

Browse files
authored
Support for Pagination (#806)
* Setup shared component * Add type overrides * Expand Button prop to take in supported HTML attributes * WIP `Paginate` * Type updates * [Paginate] Consolidate callback prop into single `handlePageChange` * [ConnectionList] Use <Paginate> component * [Wrapper] Handle pageChange action * Update qs using `window.pushState` API * Refetch list based on current offset from URL * Rename identifier * Read the offset from the URL on mount * Fix state shadowing (mitosis gotcha) * Add missing offset state update * Fix qs name for pagination, add pageLimit * Support for toggling Pagination display * Tweak pushState call for fixing back nav * Sync offset from query params with `onMount` hook * Trigger pageChange callback with `onUpdate` hook * Cleanup routing logic * Refactor * [ConnectionList] Fetch data on offset change * WIP Split refetch and route change callbacks for more predictability * Turn off vue2 for now * Avoid identical names for state and variables - should fix vue2 build issue * Listen for browser back/forward interactions using popstate API * Button style fixes * Paginate button style fixes * [WIP] Context seems to be of help * Use getter for proper itemsPerPage value with fallback to default * Hide pagination nav if total items are contained in the first page * Cleanup context test files * Simplify by removing children prop * Table component support no more results * Wrapper around table for using context * Support both Paginated/non paginated listings * Avoid duplicate fetch, ensure that paginated fetch and hook fetch don't run at same time causing race conditions * Cleanup unused props * Consolidate non offset params in baseFetchUrl * Type updates * Fix hover color for outline button * Type updates * Use pageTokenMap to fetch data * Extract pageToken from response header * Refactor into Paginated and Non Paginated table * Added left/right arrow in prev next buttons, style fixes * Tweak types * Tweak type * Fix type error * [Dsync] Support for pagination * Fine tune types * Cleanup * Type tweak * System SSO badge fixes * Update mitosis * Remove vue2 generation * Spacing in badge display * Remove vue2 scripts * Add space only if required * Fix conditional render
1 parent 4a30148 commit 8d6b0ac

29 files changed

+665
-753
lines changed

.github/workflows/main.yml

-6
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ jobs:
4242
name: mitosis-out-vue
4343
path: |
4444
./vue/src
45-
- name: Export framework code for vue2
46-
uses: actions/upload-artifact@v4
47-
with:
48-
name: mitosis-out-vue2
49-
path: |
50-
./vue2/src
5145
- name: Export framework code for angular
5246
uses: actions/upload-artifact@v4
5347
with:

mitosis.config.cjs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const VUE_OPTIONS = {
2020
api: 'composition',
2121
};
2222

23-
const components = ['Login', 'CreateOIDCConnection', 'CreateSAMLConnection', 'ConnectionList'];
23+
const components = ['Login', 'CreateOIDCConnection', 'CreateSAMLConnection'];
2424

2525
const isMitosisNode = (x) => x && x['@type'] === '@builder.io/mitosis/node';
2626

@@ -134,6 +134,6 @@ module.exports = {
134134
vue2: VUE_OPTIONS,
135135
svelte: { typescript: true },
136136
},
137-
targets: ['react', 'angular', 'vue', 'vue2', 'svelte'],
137+
targets: ['react', 'angular', 'vue', 'svelte'],
138138
exclude: ['src/css.d.ts'],
139139
};

overrides/react/src/shared/types.ts

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import type { SVGAttributes, ComponentPropsWithRef, ReactElement, ReactNode } from 'react';
1+
import type {
2+
SVGAttributes,
3+
ComponentPropsWithRef,
4+
ReactElement,
5+
ReactNode,
6+
ButtonHTMLAttributes,
7+
} from 'react';
28

39
export type SVGProps = SVGAttributes<SVGSVGElement>;
410

@@ -43,14 +49,17 @@ export interface ModalProps {
4349
children?: any;
4450
}
4551

46-
export interface ButtonProps extends ComponentPropsWithRef<'button'> {
52+
export interface ButtonProps
53+
extends ComponentPropsWithRef<'button'>,
54+
ButtonHTMLAttributes<HTMLButtonElement> {
4755
buttonRef?: HTMLButtonElement;
4856
name: string;
4957
type?: 'submit' | 'reset' | 'button';
5058
handleClick?: (event: any) => void;
5159
variant?: 'primary' | 'secondary' | 'destructive' | 'outline';
5260
classNames?: string;
5361
isLoading?: boolean;
62+
icon?: 'LeftArrowIcon' | 'RightArrowIcon';
5463
}
5564

5665
export interface ToggleSwitchProps {
@@ -139,6 +148,7 @@ export interface TableProps {
139148
icon?: string;
140149
iconSpan?: string;
141150
};
151+
noMoreResults?: boolean;
142152
}
143153

144154
export interface ConfirmationPromptProps {
@@ -149,3 +159,16 @@ export interface ConfirmationPromptProps {
149159
confirmationCallback: (event: Event) => void;
150160
cancelCallback: (event: Event) => void;
151161
}
162+
163+
export type PageToken = string | null;
164+
165+
export type PaginatePayload = { offset: number; limit: number; pageToken?: PageToken };
166+
167+
export interface PaginateProps {
168+
handlePageChange?: (payload: Partial<PaginatePayload>) => void;
169+
reFetch: (payload: PaginatePayload) => any;
170+
pageTokenMap: Record<number, PageToken>;
171+
itemsPerPage?: number;
172+
currentPageItemsCount: number;
173+
children?: any;
174+
}

overrides/svelte/src/shared/types.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ export interface BadgeProps {
3434
variant?: 'success' | 'info' | 'warning';
3535
}
3636

37-
export interface ButtonProps {
37+
export type ButtonProps = {
3838
buttonRef?: any;
3939
name: string;
4040
type?: 'submit' | 'reset' | 'button';
4141
handleClick?: (event: any) => void;
4242
variant?: 'primary' | 'secondary' | 'destructive' | 'outline';
4343
classNames?: string;
4444
isLoading?: boolean;
45-
}
45+
icon?: 'LeftArrowIcon' | 'RightArrowIcon';
46+
} & HTMLButtonElement;
4647

4748
export interface ToggleSwitchProps {
4849
label: string;
@@ -102,6 +103,7 @@ export interface TableProps {
102103
icon?: string;
103104
iconSpan?: string;
104105
};
106+
noMoreResults?: boolean;
105107
}
106108

107109
export interface ConfirmationPromptProps {
@@ -112,3 +114,16 @@ export interface ConfirmationPromptProps {
112114
confirmationCallback: (event: Event) => void;
113115
cancelCallback: (event: Event) => void;
114116
}
117+
118+
export type PageToken = string | null;
119+
120+
export type PaginatePayload = { offset: number; limit: number; pageToken?: PageToken };
121+
122+
export interface PaginateProps {
123+
handlePageChange?: (payload: Partial<PaginatePayload>) => void;
124+
reFetch: (payload: PaginatePayload) => any;
125+
pageTokenMap: Record<number, PageToken>;
126+
itemsPerPage?: number;
127+
currentPageItemsCount: number;
128+
children?: any;
129+
}

overrides/vue/vue3/src/shared/types.ts

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { SVGAttributes } from 'vue';
1+
import type { SVGAttributes, ButtonHTMLAttributes } from 'vue';
22

33
export type SVGProps = SVGAttributes;
44

@@ -43,15 +43,16 @@ export interface ModalProps {
4343
children?: any;
4444
}
4545

46-
export interface ButtonProps {
46+
export type ButtonProps = {
4747
buttonRef?: any;
4848
name: string;
4949
type?: 'submit' | 'reset' | 'button';
5050
handleClick?: (event: any) => void;
5151
variant?: 'primary' | 'secondary' | 'destructive' | 'outline';
5252
classNames?: string;
5353
isLoading?: boolean;
54-
}
54+
icon?: 'LeftArrowIcon' | 'RightArrowIcon';
55+
} & ButtonHTMLAttributes;
5556

5657
export interface ToggleSwitchProps {
5758
label: string;
@@ -110,6 +111,7 @@ export interface TableProps {
110111
icon?: string;
111112
iconSpan?: string;
112113
};
114+
noMoreResults?: boolean;
113115
}
114116

115117
export interface ConfirmationPromptProps {
@@ -120,3 +122,16 @@ export interface ConfirmationPromptProps {
120122
confirmationCallback: (event: Event) => void;
121123
cancelCallback: (event: Event) => void;
122124
}
125+
126+
export type PageToken = string | null;
127+
128+
export type PaginatePayload = { offset: number; limit: number; pageToken?: PageToken };
129+
130+
export interface PaginateProps {
131+
handlePageChange?: (payload: Partial<PaginatePayload>) => void;
132+
reFetch: (payload: PaginatePayload) => any;
133+
pageTokenMap: Record<number, PageToken>;
134+
itemsPerPage?: number;
135+
currentPageItemsCount: number;
136+
children?: any;
137+
}

0 commit comments

Comments
 (0)