forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[canvas] disable canvas application when there are no workpads (elast…
…ic#200203) Closes elastic#197370 ### Test instructions 1) open new kibana installation 2) verify canvas is not available in menu or application search bar 3) use saved object import to import canvas workpad. Reload browser 4) verify canvas is available in menu and application search bar --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
26c97e1
commit 60811de
Showing
14 changed files
with
119 additions
and
36 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 was deleted.
Oops, something went wrong.
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,20 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { HttpSetup } from '@kbn/core/public'; | ||
import { API_ROUTE_WORKPAD } from '../../common/lib/constants'; | ||
|
||
export async function getHasWorkpads(http: HttpSetup): Promise<boolean> { | ||
try { | ||
const response = await http.get(`${API_ROUTE_WORKPAD}/hasWorkpads`, { | ||
version: '1', | ||
}); | ||
return (response as { hasWorkpads: boolean })?.hasWorkpads ?? false; | ||
} catch (error) { | ||
return false; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
x-pack/plugins/canvas/server/routes/workpad/has_workpads.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,52 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { SavedObjectAttributes } from '@kbn/core/server'; | ||
import { RouteInitializerDeps } from '..'; | ||
import { CANVAS_TYPE, API_ROUTE_WORKPAD } from '../../../common/lib/constants'; | ||
|
||
export function initializeHasWorkpadsRoute(deps: RouteInitializerDeps) { | ||
const { router } = deps; | ||
router.versioned | ||
.get({ | ||
path: `${API_ROUTE_WORKPAD}/hasWorkpads`, | ||
access: 'internal', | ||
}) | ||
.addVersion( | ||
{ | ||
version: '1', | ||
validate: { | ||
request: {}, | ||
}, | ||
}, | ||
async (context, request, response) => { | ||
const savedObjectsClient = (await context.core).savedObjects.client; | ||
|
||
try { | ||
const workpads = await savedObjectsClient.find<SavedObjectAttributes>({ | ||
type: CANVAS_TYPE, | ||
fields: ['id'], | ||
perPage: 1, | ||
// search across all spaces | ||
namespaces: ['*'], | ||
}); | ||
|
||
return response.ok({ | ||
body: { | ||
hasWorkpads: workpads.total > 0, | ||
}, | ||
}); | ||
} catch (error) { | ||
return response.ok({ | ||
body: { | ||
hasWorkpads: false, | ||
}, | ||
}); | ||
} | ||
} | ||
); | ||
} |
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
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
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