-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bump cookie and socket.io in /PolyLookupComponent (#178) Bumps [cookie](https://github.com/jshttp/cookie) and [socket.io](https://github.com/socketio/socket.io). These dependencies needed to be updated together. Updates `cookie` from 0.4.2 to 0.7.2 - [Release notes](https://github.com/jshttp/cookie/releases) - [Commits](jshttp/cookie@v0.4.2...v0.7.2) Updates `socket.io` from 4.7.5 to 4.8.0 - [Release notes](https://github.com/socketio/socket.io/releases) - [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md) - [Commits](https://github.com/socketio/socket.io/compare/[email protected]@4.8.0) --- updated-dependencies: - dependency-name: cookie dependency-type: indirect - dependency-name: socket.io dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * split query hooks * enhance use query hooks --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
199fff8
commit 8f906d0
Showing
26 changed files
with
506 additions
and
428 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
65 changes: 65 additions & 0 deletions
65
LookdownComponent/Lookdown/hooks/queries/useEntityOptions.ts
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,65 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { getHandlebarsVariables, getFetchTemplateString } from "../../services/TemplateService"; | ||
import { IMetadata } from "../../types/metadata"; | ||
import { ShowIconOptions, IconSizes } from "../../types/typings"; | ||
import { getEntityRecords } from "../../services/DataverseService"; | ||
|
||
export function useEntityOptions( | ||
metadata: IMetadata | undefined, | ||
customFilter?: string | null, | ||
groupBy?: string | null, | ||
optionTemplate?: string | null, | ||
selectedItemTemplate?: string | null, | ||
iconOptions?: ShowIconOptions, | ||
iconSize?: IconSizes | ||
) { | ||
const entitySetName = metadata?.lookupEntity.EntitySetName ?? ""; | ||
const lookupViewFetchXml = metadata?.lookupView.fetchxml ?? ""; | ||
|
||
const entityIcon = | ||
metadata?.lookupEntity.IconVectorName ?? | ||
(iconSize === IconSizes.Large | ||
? metadata?.lookupEntity.IconMediumName ?? metadata?.lookupEntity.IconSmallName | ||
: metadata?.lookupEntity.IconSmallName); | ||
|
||
const recordImageUrlTemplate = metadata?.lookupEntity.RecordImageUrlTemplate; | ||
|
||
let iconTemplate = ""; | ||
if (iconOptions === ShowIconOptions.RecordImage) { | ||
iconTemplate = recordImageUrlTemplate ?? ""; | ||
} else if (iconOptions === ShowIconOptions.EntityIcon) { | ||
iconTemplate = entityIcon ?? ""; | ||
} | ||
|
||
return useQuery({ | ||
queryKey: [ | ||
"entityRecords", | ||
entitySetName, | ||
lookupViewFetchXml, | ||
customFilter, | ||
groupBy, | ||
optionTemplate, | ||
selectedItemTemplate, | ||
], | ||
queryFn: () => { | ||
const templateColumns: string[] = []; | ||
if (optionTemplate || selectedItemTemplate) { | ||
templateColumns.push(...getHandlebarsVariables(optionTemplate ?? "" + " " + selectedItemTemplate ?? "")); | ||
} | ||
const populatedFetchXml = getFetchTemplateString(lookupViewFetchXml ?? "", customFilter, templateColumns); | ||
return getEntityRecords( | ||
entitySetName, | ||
metadata?.lookupEntity.PrimaryIdAttribute ?? "", | ||
metadata?.lookupEntity.PrimaryNameAttribute ?? "", | ||
populatedFetchXml, | ||
groupBy, | ||
optionTemplate, | ||
selectedItemTemplate, | ||
iconOptions, | ||
iconTemplate, | ||
iconSize | ||
); | ||
}, | ||
enabled: !!entitySetName && !!lookupViewFetchXml, | ||
}); | ||
} |
11 changes: 11 additions & 0 deletions
11
LookdownComponent/Lookdown/hooks/queries/useLanguagePack.ts
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,11 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { getLanguagePack } from "../../services/DataverseService"; | ||
import { LanguagePack } from "../../types/languagePack"; | ||
|
||
export function useLanguagePack(webResourcePath: string | undefined, defaultLanguagePack: LanguagePack) { | ||
return useQuery({ | ||
queryKey: ["languagePack", webResourcePath], | ||
queryFn: () => getLanguagePack(webResourcePath, defaultLanguagePack), | ||
enabled: !!webResourcePath, | ||
}); | ||
} |
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,10 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { getMetadata } from "../../services/DataverseService"; | ||
|
||
export function useMetadata(lookupTable: string, lookupViewId: string) { | ||
return useQuery({ | ||
queryKey: ["metadata", lookupTable, lookupViewId], | ||
queryFn: () => getMetadata(lookupTable, lookupViewId), | ||
enabled: !!lookupTable && !!lookupViewId, | ||
}); | ||
} |
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,92 @@ | ||
import { TagPickerOption, Avatar, Divider, Text, tokens, makeStyles } from "@fluentui/react-components"; | ||
import React from "react"; | ||
import { LanguagePack } from "../types/languagePack"; | ||
import { EntityOption, ShowIconOptions, ShowOptionDetailsEnum } from "../types/typings"; | ||
import { SuggestionInfo } from "./SuggestionInfo"; | ||
|
||
const useStyles = makeStyles({ | ||
optionListFooter: { | ||
padding: tokens.spacingVerticalS, | ||
}, | ||
listBox: { | ||
maxHeight: "50vh", | ||
overflowX: "hidden", | ||
overflowY: "auto", | ||
padding: tokens.spacingVerticalXS, | ||
}, | ||
transparentBackground: { | ||
backgroundColor: tokens.colorTransparentBackground, | ||
}, | ||
}); | ||
|
||
export interface OptionListProps { | ||
options: EntityOption[]; | ||
columns: string[]; | ||
languagePack: LanguagePack; | ||
isLoading?: boolean; | ||
hasMoreRecords?: boolean; | ||
showIcon?: ShowIconOptions; | ||
entityIconUrl?: string; | ||
showOptionDetails?: ShowOptionDetailsEnum; | ||
} | ||
|
||
export function OptionList({ | ||
options, | ||
columns, | ||
languagePack, | ||
isLoading, | ||
hasMoreRecords, | ||
showIcon, | ||
entityIconUrl, | ||
showOptionDetails, | ||
}: OptionListProps) { | ||
const { optionListFooter, listBox, transparentBackground } = useStyles(); | ||
|
||
if (!options?.length) { | ||
return ( | ||
<div className={optionListFooter}> | ||
<Text>{isLoading ? languagePack.LoadingMessage : languagePack.EmptyListDefaultMessage}</Text> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div> | ||
<div className={listBox}> | ||
{options?.map((option) => ( | ||
<TagPickerOption | ||
media={ | ||
showIcon ? ( | ||
<Avatar | ||
className={transparentBackground} | ||
size={showIcon === ShowIconOptions.EntityIcon ? 16 : 28} | ||
shape="square" | ||
name={showIcon === ShowIconOptions.EntityIcon ? "" : option.optionText} | ||
image={{ | ||
className: transparentBackground, | ||
src: showIcon === ShowIconOptions.EntityIcon ? entityIconUrl : option.iconSrc, | ||
}} | ||
color={showIcon === ShowIconOptions.EntityIcon ? "neutral" : "colorful"} | ||
aria-hidden | ||
/> | ||
) : undefined | ||
} | ||
key={option.id} | ||
value={option.id} | ||
text={option.optionText} | ||
> | ||
<SuggestionInfo | ||
data={option} | ||
columns={columns} | ||
showOptionDetails={showOptionDetails ?? ShowOptionDetailsEnum.Collapsed} | ||
/> | ||
</TagPickerOption> | ||
))} | ||
</div> | ||
<Divider /> | ||
<div className={optionListFooter}> | ||
<Text>{hasMoreRecords ? languagePack.SuggestionListFullMessage : languagePack.NoMoreRecordsMessage}</Text> | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.