Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3b01379
APIs List V2 - init
JMach1 Feb 6, 2024
ef3f4cc
APIs List V2 - APIs List v2
JMach1 Feb 13, 2024
14f67a1
APIs List V2 - @fluentui/react-components
JMach1 Feb 20, 2024
715ed6d
APIs List V2 - TODO
JMach1 Feb 20, 2024
4a4bae4
APIs List V2 - api-list base working
JMach1 Feb 21, 2024
6e1aa55
APIs List V2 - api-list pagination working
JMach1 Feb 21, 2024
0059561
APIs List V2 - api-list first row info
JMach1 Feb 21, 2024
8a6e07a
APIs List V2 - api-list cards & fuiTheme fix
JMach1 Feb 22, 2024
2aa751d
APIs List V2 - ApisCards
JMach1 Mar 4, 2024
ebdddde
APIs List V2 - cleanup
JMach1 Mar 4, 2024
46126b6
Merge branch 'fui/main' into fui/api-list
JMach1 Mar 4, 2024
1392b6b
APIs List V2 - npm i
JMach1 Mar 4, 2024
fd4d151
APIs List V2 - search & group by WiP
JMach1 Mar 19, 2024
90f0f12
APIs list - group by tag & sorting WiP (TODO)
JMach1 May 20, 2024
4b5d273
Products list - table & cards views
JMach1 May 21, 2024
161f918
Merge remote-tracking branch 'refs/remotes/origin/fui/master' into fu…
JMach1 May 21, 2024
c0ff185
merge - styling refactor
JMach1 May 21, 2024
6ca6e5b
page size fix
JMach1 May 21, 2024
2c9d719
Merge branch 'refs/heads/fui/api-list' into fui/products-list
JMach1 May 21, 2024
8c6d9b4
merge fix
JMach1 May 21, 2024
769b983
refactor of style handling
JMach1 May 21, 2024
a407642
markdown processing
JMach1 May 21, 2024
bf7e358
margin adjusted
JMach1 May 21, 2024
0d61bed
Merge branch 'refs/heads/fui/api-list' into fui/products-list
JMach1 May 21, 2024
c8be66d
merge adaptation
JMach1 May 21, 2024
e2bf237
chevron icon fix
JMach1 May 21, 2024
03ec2a0
allowViewSwitching for table views
JMach1 May 21, 2024
025baec
FUI - product APIs list
JMach1 May 22, 2024
6766c8f
FUI - group by tag implemented
JMach1 May 22, 2024
38bc0b5
FUI - group by tag implemented
JMach1 May 22, 2024
dd346d9
markdown truncate
JMach1 May 22, 2024
cd8e41b
markdown truncate styling
JMach1 May 22, 2024
3c1863b
pagination refactor
JMach1 May 24, 2024
5b9f6f8
Merge remote-tracking branch 'refs/remotes/origin/fui/master' into fu…
JMach1 May 28, 2024
8a3b65c
Merge branch 'refs/heads/fui/products-list' into fui/products-apis-list
JMach1 May 28, 2024
ffe5c27
merge fix
JMach1 May 28, 2024
7bcd61d
Merge branch 'refs/heads/fui/products-list' into fui/products-apis-list
JMach1 May 28, 2024
fe870c1
Merge remote-tracking branch 'refs/remotes/origin/fui/master' into fu…
JMach1 May 28, 2024
cb2ec75
icon replaced
JMach1 May 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"rehype-raw": "^6.1.1",
"rehype-sanitize": "^5.0.1",
"rehype-stringify": "^9.0.3",
"rehype-truncate": "^1.2.2",
"remark": "^14.0.3",
"remark-gfm": "^3.0.1",
"remark-parse": "^10.0.2",
Expand Down
2 changes: 2 additions & 0 deletions src/apim.runtime.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import { TraceClick } from "./bindingHandlers/traceClick";
import { GraphqlService } from "./services/graphqlService";
import { ListOfApisRuntimeModule } from "./components/apis/list-of-apis/listOfApis.runtime.module";
import { ProductListRuntimeModule } from "./components/products/product-list/productList.runtime.module";
import { ProductApisRuntimeModule } from "./components/products/product-apis/productApis.runtime.module";
import { OperationListRuntimeModule } from "./components/operations/operation-list/operationList.runtime.module";
import { DetailsOfApiRuntimeModule } from "./components/apis/details-of-api/detailsOfApi.runtime.module";

Expand Down Expand Up @@ -174,6 +175,7 @@ export class ApimRuntimeModule implements IInjectorModule {
injector.bindModule(new RoleBasedSecurityRuntimeModule());
injector.bindModule(new ListOfApisRuntimeModule());
injector.bindModule(new ProductListRuntimeModule());
injector.bindModule(new ProductApisRuntimeModule());
injector.bindModule(new OperationListRuntimeModule());
injector.bindModule(new DetailsOfApiRuntimeModule());

Expand Down
27 changes: 12 additions & 15 deletions src/components/apis/list-of-apis/ko/listOfApisViewModelBinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@ import { ViewModelBinder, WidgetState } from "@paperbits/common/widgets";
import { ListOfApisViewModel } from "./listOfApisViewModel";
import { ListOfApisModel } from "../listOfApisModel";
import { StyleCompiler } from "@paperbits/common/styles";
import { TLayout } from "../../../utils/react/TableListInfo";

const layoutsMap = {
"tiles": TLayout.cards,
"list": TLayout.table,
"dropdown": undefined, // TODO
}
import { layoutsMap } from "../../../utils/react/TableListInfo";

export class ListOfApisViewModelBinder implements ViewModelBinder<ListOfApisModel, ListOfApisViewModel> {
constructor(private readonly styleCompiler: StyleCompiler) { }
Expand All @@ -22,21 +16,24 @@ export class ListOfApisViewModelBinder implements ViewModelBinder<ListOfApisMode
allowViewSwitching: state.allowViewSwitching,
showApiType: state.showApiType,
defaultGroupByTagToEnabled: state.defaultGroupByTagToEnabled,
detailsPageUrl: state.detailsPageUrl,
layoutDefault: layoutsMap[state.layout],
detailsPageUrl: state.detailsPageHyperlink
? state.detailsPageHyperlink.href
: undefined,
detailsPageTarget: state.detailsPageHyperlink
? state.detailsPageHyperlink.target
: undefined,
}));
}

public async modelToState(model: ListOfApisModel, state: WidgetState): Promise<void> {
state.layout = model.layout;

state.allowSelection = model.allowSelection,
state.allowViewSwitching = model.allowViewSwitching,
state.showApiType = model.showApiType,
state.defaultGroupByTagToEnabled = model.defaultGroupByTagToEnabled,
state.detailsPageUrl = model.detailsPageHyperlink
? model.detailsPageHyperlink.href
: undefined
state.allowSelection = model.allowSelection;
state.allowViewSwitching = model.allowViewSwitching;
state.showApiType = model.showApiType;
state.defaultGroupByTagToEnabled = model.defaultGroupByTagToEnabled;
state.detailsPageHyperlink = model.detailsPageHyperlink;

if (model.styles) {
state.styles = await this.styleCompiler.getStyleModelAsync(model.styles);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class ApiListDropdown {
) {
this.apis = ko.observableArray([]);
this.detailsPageUrl = ko.observable();
this.detailsPageTarget = ko.observable();
this.allowSelection = ko.observable(false);
this.defaultGroupByTagToEnabled = ko.observable(false);
this.groupByTag = ko.observable(false);
Expand All @@ -63,6 +64,9 @@ export class ApiListDropdown {
@Param()
public detailsPageUrl: ko.Observable<string>;

@Param()
public detailsPageTarget: ko.Observable<string>;

@Param()
public defaultGroupByTagToEnabled: ko.Observable<boolean>;

Expand Down
24 changes: 16 additions & 8 deletions src/components/apis/list-of-apis/react/runtime/ApiListRuntime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,28 @@ import { ApisCards } from "./ApisCards";
import { TApisData } from "./utils";

export interface ApiListProps {
productName?: string;
allowSelection?: boolean;
allowViewSwitching?: boolean;
showApiType?: boolean;
defaultGroupByTagToEnabled?: boolean;
detailsPageUrl: string;
detailsPageTarget: string;

layoutDefault: TLayout | undefined; // TODO remove undefined once finished
}

const loadApis = async (apiService: ApiService, query: SearchQuery, groupByTags?: boolean) => {
const loadApis = async (apiService: ApiService, query: SearchQuery, groupByTags?: boolean, productName?: string) => {
let apis: TApisData;

try {
apis = await (groupByTags ? apiService.getApisByTags(query) : apiService.getApis(query));
if (productName) {
apis = await apiService.getProductApis(`products/${productName}`, query);
} else if (groupByTags) {
apis = await apiService.getApisByTags(query);
} else {
apis = await apiService.getApis(query);
}
} catch (error) {
throw new Error(`Unable to load APIs. Error: ${error.message}`);
}
Expand All @@ -38,7 +46,7 @@ const loadApis = async (apiService: ApiService, query: SearchQuery, groupByTags?
}

const ApiListRuntimeFC = ({
apiService, getReferenceUrl, layoutDefault, showApiType, allowViewSwitching, defaultGroupByTagToEnabled
apiService, getReferenceUrl, productName, layoutDefault, showApiType, allowViewSwitching, detailsPageTarget, defaultGroupByTagToEnabled
}: ApiListProps & { apiService: ApiService, getReferenceUrl: (api: Api) => string }) => {
const [working, setWorking] = useState(false)
const [pageNumber, setPageNumber] = useState(1)
Expand All @@ -60,10 +68,10 @@ const ApiListRuntimeFC = ({
};

setWorking(true)
loadApis(apiService, query, groupByTag)
loadApis(apiService, query, groupByTag, productName)
.then(apis => setApis(apis))
.finally(() => setWorking(false))
}, [apiService, pageNumber, groupByTag, pattern])
}, [apiService, pageNumber, groupByTag, pattern, productName])

return (
<Stack tokens={{childrenGap: "1rem"}}>
Expand All @@ -73,7 +81,7 @@ const ApiListRuntimeFC = ({
setLayout={setLayout}
pattern={pattern}
setPattern={setPattern}
setGroupByTag={setGroupByTag} // don't allow grouping by tags when filtering for product APIs
setGroupByTag={productName ? undefined : setGroupByTag} // don't allow grouping by tags when filtering for product APIs
allowViewSwitching={allowViewSwitching}
defaultGroupByTagToEnabled={defaultGroupByTagToEnabled}
/>
Expand All @@ -89,9 +97,9 @@ const ApiListRuntimeFC = ({
<>
<Stack.Item>
{layout === TLayout.table ? (
<ApisTable apis={apis} showApiType={showApiType} getReferenceUrl={getReferenceUrl} />
<ApisTable apis={apis} showApiType={showApiType} getReferenceUrl={getReferenceUrl} detailsPageTarget={detailsPageTarget} />
) : (
<ApisCards apis={apis} showApiType={showApiType} getReferenceUrl={getReferenceUrl} />
<ApisCards apis={apis} showApiType={showApiType} getReferenceUrl={getReferenceUrl} detailsPageTarget={detailsPageTarget} />
)}
</Stack.Item>

Expand Down
26 changes: 12 additions & 14 deletions src/components/apis/list-of-apis/react/runtime/ApisCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { Api } from "../../../../../models/api";
import { isApisGrouped, toggleValueInSet, TagGroupToggleBtn, TApisData } from "./utils";
import { TagGroup } from "../../../../../models/tagGroup";
import { MarkdownProcessor } from "../../../../react-markdown/MarkdownProcessor";
import { markdownMaxCharsMap } from "../../../../../constants";

type Props = {
showApiType: boolean;
getReferenceUrl: (api: Api) => string;
detailsPageTarget: string;
};

const ApiCard = ({ api, getReferenceUrl, showApiType }: Props & { api: Api }) => {
const ApiCard = ({ api, getReferenceUrl, showApiType, detailsPageTarget }: Props & { api: Api }) => {
return (
<div className={"fui-list-card"}>
<div style={{ height: "100%" }}>
Expand All @@ -22,11 +24,11 @@ const ApiCard = ({ api, getReferenceUrl, showApiType }: Props & { api: Api }) =>
)}
<Subtitle1>{api.displayName}</Subtitle1>

<MarkdownProcessor markdownToDisplay={api.description}/>
<MarkdownProcessor markdownToDisplay={api.description} maxChars={markdownMaxCharsMap.cards} />
</div>

<div>
<Link href={getReferenceUrl(api)} title={api.displayName}>
<Link href={getReferenceUrl(api)} target={detailsPageTarget} title={api.displayName}>
<Button appearance={"outline"}>
Go to API
</Button>
Expand All @@ -36,20 +38,19 @@ const ApiCard = ({ api, getReferenceUrl, showApiType }: Props & { api: Api }) =>
);
};

const ApisCardsContainer = ({ showApiType, apis, getReferenceUrl }: Props & { apis: Api[] }) => (
const ApisCardsContainer = ({ apis, ...props }: Props & { apis: Api[] }) => (
<div className={"fui-list-cards-container"}>
{apis?.map((api) => (
<ApiCard
{...props}
key={api.id}
api={api}
getReferenceUrl={getReferenceUrl}
showApiType={showApiType}
/>
))}
</div>
);

const ApisGroupedCards = ({ showApiType, tags, getReferenceUrl }: Props & { tags: TagGroup<Api>[] }) => {
const ApisGroupedCards = ({ tags, ...props }: Props & { tags: TagGroup<Api>[] }) => {
const [expanded, setExpanded] = React.useState(new Set());

return (
Expand All @@ -69,9 +70,8 @@ const ApisGroupedCards = ({ showApiType, tags, getReferenceUrl }: Props & { tags

{expanded.has(tag) && (
<ApisCardsContainer
{...props}
apis={items}
getReferenceUrl={getReferenceUrl}
showApiType={showApiType}
/>
)}
</div>
Expand All @@ -80,17 +80,15 @@ const ApisGroupedCards = ({ showApiType, tags, getReferenceUrl }: Props & { tags
);
};

export const ApisCards = ({ showApiType, apis, getReferenceUrl }: Props & { apis: TApisData }) =>
export const ApisCards = ({ apis, ...props }: Props & { apis: TApisData }) =>
isApisGrouped(apis) ? (
<ApisGroupedCards
{...props}
tags={apis.value}
getReferenceUrl={getReferenceUrl}
showApiType={showApiType}
/>
) : (
<ApisCardsContainer
{...props}
apis={apis.value}
getReferenceUrl={getReferenceUrl}
showApiType={showApiType}
/>
);
29 changes: 13 additions & 16 deletions src/components/apis/list-of-apis/react/runtime/ApisTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,34 @@ import { Page } from "../../../../../models/page";
import { TagGroup } from "../../../../../models/tagGroup";
import { isApisGrouped, toggleValueInSet, TagGroupToggleBtn, TApisData } from "./utils";
import { MarkdownProcessor } from "../../../../react-markdown/MarkdownProcessor";
import { markdownMaxCharsMap } from "../../../../../constants";

type Props = {
showApiType: boolean;
getReferenceUrl: (api: Api) => string;
detailsPageTarget: string;
};

const TableBodyApis = ({ showApiType, apis, getReferenceUrl }: Props & { apis: Api[] }) => (
const TableBodyApis = ({ showApiType, apis, getReferenceUrl, detailsPageTarget }: Props & { apis: Api[] }) => (
<>
{apis?.map((api) => (
<TableRow key={api.id}>
<TableCell>
<Link href={getReferenceUrl(api)} title={api.displayName}>
<Link href={getReferenceUrl(api)} target={detailsPageTarget} title={api.displayName}>
{api.displayName}
{!!api.apiVersion && " - " + api.apiVersion}
</Link>
</TableCell>
<TableCell>
<TableCellLayout truncate title={api.description}>
<MarkdownProcessor markdownToDisplay={api.description} />
</TableCellLayout>
<TableCell style={{padding: ".5rem 0"}}>
<MarkdownProcessor markdownToDisplay={api.description} maxChars={markdownMaxCharsMap.table} />
</TableCell>
{showApiType && <TableCell>{api.typeName}</TableCell>}
</TableRow>
))}
</>
);

const TableBodyTags = ({ showApiType, tags, getReferenceUrl }: Props & { tags: Page<TagGroup<Api>> }) => {
const TableBodyTags = ({ tags, ...props }: Props & { tags: Page<TagGroup<Api>> }) => {
const [expanded, setExpanded] = React.useState(new Set());

return (
Expand All @@ -61,14 +61,13 @@ const TableBodyTags = ({ showApiType, tags, getReferenceUrl }: Props & { tags: P
<TagGroupToggleBtn expanded={expanded.has(tag)}/>
</TableCell>
<TableCell></TableCell>
{showApiType && <TableCell></TableCell>}
{props.showApiType && <TableCell></TableCell>}
</TableRow>

{expanded.has(tag) && (
<TableBodyApis
{...props}
apis={items}
showApiType={showApiType}
getReferenceUrl={getReferenceUrl}
/>
)}
</React.Fragment>
Expand All @@ -77,7 +76,7 @@ const TableBodyTags = ({ showApiType, tags, getReferenceUrl }: Props & { tags: P
);
};

export const ApisTable = ({ showApiType, apis, getReferenceUrl }: Props & { apis: TApisData }) => (
export const ApisTable = ({ apis, ...props }: Props & { apis: TApisData }) => (
<div className={"fui-table"}>
<Table size={"small"} aria-label={"APIs List table"}>
<TableHeader>
Expand All @@ -88,7 +87,7 @@ export const ApisTable = ({ showApiType, apis, getReferenceUrl }: Props & { apis
<TableHeaderCell>
<Body1Strong>Description</Body1Strong>
</TableHeaderCell>
{showApiType && (
{props.showApiType && (
<TableHeaderCell style={{ width: "8em" }}>
<Body1Strong>Type</Body1Strong>
</TableHeaderCell>
Expand All @@ -99,15 +98,13 @@ export const ApisTable = ({ showApiType, apis, getReferenceUrl }: Props & { apis
<TableBody>
{isApisGrouped(apis) ? (
<TableBodyTags
{...props}
tags={apis}
showApiType={showApiType}
getReferenceUrl={getReferenceUrl}
/>
) : (
<TableBodyApis
{...props}
apis={apis.value}
showApiType={showApiType}
getReferenceUrl={getReferenceUrl}
/>
)}
</TableBody>
Expand Down
8 changes: 1 addition & 7 deletions src/components/products/product-apis/ko/productApis.html
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
<!-- ko if: layout() === 'list' -->
<product-apis-runtime data-bind="attr: { params: runtimeConfig }"></product-apis-runtime>
<!-- /ko -->

<!-- ko if: layout() === 'tiles' -->
<product-apis-tiles-runtime data-bind="attr: { params: runtimeConfig }"></product-apis-tiles-runtime>
<!-- /ko -->
<fui-product-apis-runtime data-bind="attr: { props: runtimeConfig }"></fui-product-apis-runtime>
Loading