Panel/DashList: Fetch folders with View permission (#32406)

Closes #31357
This commit is contained in:
kay delaney 2021-03-29 11:11:51 +01:00 committed by GitHub
parent 5b2a419df8
commit a98fd22e34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -18,6 +18,7 @@ export interface Props {
dashboardId?: any; dashboardId?: any;
initialTitle?: string; initialTitle?: string;
initialFolderId?: number; initialFolderId?: number;
permissionLevel?: 'View' | 'Edit';
} }
interface State { interface State {
@ -40,11 +41,12 @@ export class FolderPicker extends PureComponent<Props, State> {
}); });
} }
static defaultProps = { static defaultProps: Partial<Props> = {
rootName: 'General', rootName: 'General',
enableReset: false, enableReset: false,
initialTitle: '', initialTitle: '',
enableCreateNew: false, enableCreateNew: false,
permissionLevel: 'Edit',
}; };
componentDidMount = async () => { componentDidMount = async () => {
@ -52,11 +54,11 @@ export class FolderPicker extends PureComponent<Props, State> {
}; };
getOptions = async (query: string) => { getOptions = async (query: string) => {
const { rootName, enableReset, initialTitle } = this.props; const { rootName, enableReset, initialTitle, permissionLevel } = this.props;
const params = { const params = {
query, query,
type: 'dash-folder', type: 'dash-folder',
permission: 'Edit', permission: permissionLevel,
}; };
// TODO: move search to BackendSrv interface // TODO: move search to BackendSrv interface

View File

@ -49,6 +49,7 @@ export const plugin = new PanelPlugin<DashListOptions>(DashList)
initialFolderId={props.value} initialFolderId={props.value}
initialTitle="All" initialTitle="All"
enableReset={true} enableReset={true}
permissionLevel="View"
onChange={({ id }) => props.onChange(id)} onChange={({ id }) => props.onChange(id)}
/> />
); );