Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site picker changes #1389

Merged
merged 10 commits into from
Jan 4, 2023
Merged
24 changes: 24 additions & 0 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"@types/react-dom": "17.0.17",
"@types/react-addons-shallow-compare": "0.14.17",
"@types/react-addons-test-utils": "0.14.15",
"@types/react-addons-update": "0.14.14",
"@types/react-addons-update": "0.14.21",
"@types/react-mentions": "^4.1.3",
"@types/sinon": "2.3.4",
"@types/webpack-env": "~1.15.2",
Expand Down
5 changes: 5 additions & 0 deletions src/controls/sitePicker/ISitePicker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { IDropdownStyles } from 'office-ui-fabric-react';

import { BaseComponentContext } from '@microsoft/sp-component-base';

import { ISite } from '../../services/SPSitesService';

export interface ISitePickerProps {
Expand Down Expand Up @@ -95,4 +98,6 @@ export interface ISitePickerProps {
* If mode is set to associatedsites and no hubsiteId is provided, the current site's hub ID will be used.
*/
hubsiteId?: string;
styles?: IDropdownStyles ;
}
export { ISite };
39 changes: 29 additions & 10 deletions src/controls/sitePicker/SitePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
import { Async } from '@uifabric/utilities/lib/Async';
import * as React from 'react';

import findIndex from 'lodash/findIndex';
import orderBy from 'lodash/orderBy';
import { Dropdown, IDropdownOption } from 'office-ui-fabric-react/lib/Dropdown';
import {
Dropdown,
IDropdownOption,
} from 'office-ui-fabric-react/lib/Dropdown';
import { SearchBox } from 'office-ui-fabric-react/lib/SearchBox';
import { Spinner, SpinnerSize } from 'office-ui-fabric-react/lib/Spinner';
import {
Spinner,
SpinnerSize,
} from 'office-ui-fabric-react/lib/Spinner';
import { mergeStyleSets } from 'office-ui-fabric-react/lib/Styling';
import { ISelectableOption, SelectableOptionMenuItemType } from 'office-ui-fabric-react/lib/utilities/selectableOption/SelectableOption.types';
import * as React from 'react';
import {
ISelectableOption,
SelectableOptionMenuItemType,
} from 'office-ui-fabric-react/lib/utilities/selectableOption/SelectableOption.types';

import { Async } from '@uifabric/utilities/lib/Async';

import * as telemetry from '../../common/telemetry';
import { toRelativeUrl } from '../../common/utilities/GeneralHelper';
import { getAllSites, getHubSites, ISite, getAssociatedSites } from '../../services/SPSitesService';
import { ISitePickerProps } from './ISitePicker';
import {
getAllSites,
getAssociatedSites,
getHubSites,
} from '../../services/SPSitesService';
import {
ISite,
ISitePickerProps,
} from './ISitePicker';

const styles = mergeStyleSets({
loadingSpinnerContainer: {
Expand Down Expand Up @@ -73,7 +91,7 @@ export const SitePicker: React.FunctionComponent<ISitePickerProps> = (props: Rea
className,
selectedSites,
trimDuplicates,
additionalQuery,
additionalQuery,
hubsiteId
} = props;

Expand Down Expand Up @@ -238,11 +256,11 @@ export const SitePicker: React.FunctionComponent<ISitePickerProps> = (props: Rea
case 'hub':
promise = getHubSites(context);
break;

case 'associatedsites':
promise = getAssociatedSites(context, trimDuplicates === true, hubsiteId);
break;

default:
promise = getAllSites(context, mode !== 'site', limitToCurrentSiteCollection, trimDuplicates === true, additionalQuery);
break;
Expand Down Expand Up @@ -291,6 +309,7 @@ export const SitePicker: React.FunctionComponent<ISitePickerProps> = (props: Rea
onChange={onSelectionChange}
notifyOnReselect={true}
className={className}
styles={props.styles}
/>
</>
);
Expand Down