chore: drop initialGroup prop
Signed-off-by: djamaile <rdjamaile@gmail.com>
This commit is contained in:
@@ -18,7 +18,7 @@ To use the `GroupListPicker` component you'll need to import it and add it to yo
|
||||
|
||||
<Grid container spacing={3}>
|
||||
<Grid item xs={12}>
|
||||
+ <GroupListPicker groupTypes={['team']} initialGroup={group.metadata.name} placeholder='Search for a team' onChange={setGroup}/>
|
||||
+ <GroupListPicker groupTypes={['team']} placeholder='Search for a team' onChange={setGroup}/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
```
|
||||
@@ -26,6 +26,5 @@ To use the `GroupListPicker` component you'll need to import it and add it to yo
|
||||
The `GroupListPicker` comes with three optional props:
|
||||
|
||||
- `groupTypes`: gives the user the option which group types the component should load. If no value is provided all group types will be loaded in;
|
||||
- `initialGroup`: which group by default should be selected. For example, a group of the logged in user;
|
||||
- `placeholder`: the placeholder that the select box in the component should display. This might be helpful in informing your users what the functionality of the component is.
|
||||
- `onChange`: a prop to help the user to give access to the selected group
|
||||
|
||||
@@ -63,28 +63,12 @@ const mockCatalogApi = {
|
||||
const apis = TestApiRegistry.from([catalogApiRef, mockCatalogApi]);
|
||||
|
||||
describe('<GroupListPicker />', () => {
|
||||
it('renders group list picker', () => {
|
||||
const { queryByText } = render(
|
||||
<ApiProvider apis={apis}>
|
||||
<GroupListPicker
|
||||
placeholder="Search"
|
||||
groupTypes={['org', 'department']}
|
||||
initialGroup="test"
|
||||
onChange={() => {}}
|
||||
/>
|
||||
</ApiProvider>,
|
||||
);
|
||||
|
||||
expect(queryByText('test')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('can choose a group', async () => {
|
||||
const { getByText, queryByText, getByTestId } = render(
|
||||
<ApiProvider apis={apis}>
|
||||
<GroupListPicker
|
||||
placeholder="Search"
|
||||
groupTypes={['org', 'department']}
|
||||
initialGroup="Group A"
|
||||
onChange={() => {}}
|
||||
/>
|
||||
</ApiProvider>,
|
||||
|
||||
@@ -36,7 +36,6 @@ import { GroupListPickerButton } from './GroupListPickerButton';
|
||||
export type GroupListPickerProps = {
|
||||
placeholder?: string;
|
||||
groupTypes?: Array<string>;
|
||||
initialGroup?: string | undefined;
|
||||
onChange: (value: GroupEntity | undefined) => void;
|
||||
};
|
||||
|
||||
@@ -44,7 +43,7 @@ export type GroupListPickerProps = {
|
||||
export const GroupListPicker = (props: GroupListPickerProps) => {
|
||||
const catalogApi = useApi(catalogApiRef);
|
||||
|
||||
const { onChange, groupTypes, initialGroup, placeholder = '' } = props;
|
||||
const { onChange, groupTypes, placeholder = '' } = props;
|
||||
const [anchorEl, setAnchorEl] = React.useState<HTMLElement | null>(null);
|
||||
const [inputValue, setInputValue] = React.useState('');
|
||||
|
||||
@@ -116,7 +115,7 @@ export const GroupListPicker = (props: GroupListPickerProps) => {
|
||||
)}
|
||||
/>
|
||||
</Popover>
|
||||
<GroupListPickerButton handleClick={handleClick} group={initialGroup} />
|
||||
<GroupListPickerButton handleClick={handleClick} group={inputValue} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -13,5 +13,5 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export { GroupListPicker } from './plugin';
|
||||
export { GroupListPicker } from './components/GroupListPicker';
|
||||
export type { GroupListPickerProps } from './components/GroupListPicker';
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright 2022 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { orgReactPlugin } from './plugin';
|
||||
|
||||
describe('org-react', () => {
|
||||
it('should export plugin', () => {
|
||||
expect(orgReactPlugin).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -1,39 +0,0 @@
|
||||
/*
|
||||
* Copyright 2022 The Backstage Authors
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import {
|
||||
createComponentExtension,
|
||||
createPlugin,
|
||||
} from '@backstage/core-plugin-api';
|
||||
|
||||
import { rootRouteRef } from './routes';
|
||||
|
||||
export const orgReactPlugin = createPlugin({
|
||||
id: 'org-react',
|
||||
routes: {
|
||||
root: rootRouteRef,
|
||||
},
|
||||
});
|
||||
|
||||
/** @public */
|
||||
export const GroupListPicker = orgReactPlugin.provide(
|
||||
createComponentExtension({
|
||||
name: 'GroupListPicker',
|
||||
component: {
|
||||
lazy: () =>
|
||||
import('./components/GroupListPicker').then(m => m.GroupListPicker),
|
||||
},
|
||||
}),
|
||||
);
|
||||
Reference in New Issue
Block a user