-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(quay): add permissions support for quay plugin
- Loading branch information
1 parent
d2a76fd
commit aa965b5
Showing
15 changed files
with
209 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); |
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 @@ | ||
# Quay Common plugin | ||
|
||
Welcome to the quay-common plugin! | ||
|
||
This plugin contains common utilities for the quay plugin. | ||
|
||
# Quay plugin for Backstage | ||
|
||
The Quay plugin displays the information about your container images within the Quay registry in your Backstage application. | ||
|
||
For more information about Quay plugin, see the [Quay plugin documentation](https://github.com/janus-idp/backstage-plugins/tree/main/plugins/quay) on GitHub. |
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,55 @@ | ||
{ | ||
"name": "@janus-idp/backstage-plugin-quay-common", | ||
"version": "0.1.0", | ||
"main": "src/index.ts", | ||
"types": "src/index.ts", | ||
"license": "Apache-2.0", | ||
"publishConfig": { | ||
"access": "public", | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.esm.js", | ||
"types": "dist/index.d.ts" | ||
}, | ||
"backstage": { | ||
"role": "common-library", | ||
"supported-versions": "1.26.5" | ||
}, | ||
"author": "Red Hat", | ||
"homepage": "https://red.ht/rhdh", | ||
"bugs": "https://github.com/janus-idp/backstage-plugins/issues", | ||
"maintainers": [ | ||
"janus-idp/rhtap" | ||
], | ||
"keywords": [ | ||
"support:production", | ||
"lifecycle:active", | ||
"backstage", | ||
"plugin" | ||
], | ||
"scripts": { | ||
"build": "backstage-cli package build", | ||
"clean": "backstage-cli package clean", | ||
"lint": "backstage-cli package lint", | ||
"postpack": "backstage-cli package postpack", | ||
"prepack": "backstage-cli package prepack", | ||
"test": "backstage-cli package test --passWithNoTests --coverage", | ||
"tsc": "tsc" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/janus-idp/backstage-plugins", | ||
"directory": "plugins/quay-common" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"dependencies": { | ||
"@backstage/plugin-permission-common": "^0.7.13" | ||
}, | ||
"peerDependencies": { | ||
"react": "16.13.1 || ^17.0.0 || ^18.0.0" | ||
}, | ||
"devDependencies": { | ||
"@backstage/cli": "0.26.6" | ||
} | ||
} |
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,7 @@ | ||
/** | ||
* Common functionalities for the quay plugin. | ||
* | ||
* @packageDocumentation | ||
*/ | ||
|
||
export * from './permissions'; |
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,13 @@ | ||
import { createPermission } from '@backstage/plugin-permission-common'; | ||
|
||
export const quayViewPermission = createPermission({ | ||
name: 'quay.view.read', | ||
attributes: { | ||
action: 'read', | ||
}, | ||
}); | ||
|
||
/** | ||
* List of all permissions on permission polices. | ||
*/ | ||
export const quayPermissions = [quayViewPermission]; |
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,9 @@ | ||
{ | ||
"extends": "@backstage/cli/config/tsconfig.json", | ||
"include": ["src", "dev"], | ||
"exclude": ["node_modules"], | ||
"compilerOptions": { | ||
"outDir": "../../dist-types/plugins/quay-common", | ||
"rootDir": "." | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"extends": ["//"], | ||
"pipeline": { | ||
"tsc": { | ||
"outputs": ["../../dist-types/plugins/quay-common/**"], | ||
"dependsOn": ["^tsc"] | ||
} | ||
} | ||
} |
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
14 changes: 14 additions & 0 deletions
14
plugins/quay/src/components/PermissionAlert/PermissionAlert.tsx
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,14 @@ | ||
import React from 'react'; | ||
|
||
import { Alert, AlertTitle } from '@material-ui/lab'; | ||
|
||
const PermissionAlert = () => { | ||
return ( | ||
<Alert severity="warning" data-testid="no-permission-alert"> | ||
<AlertTitle>Permission required</AlertTitle> | ||
To view quay image registry, contact your administrator to give you the | ||
quay.view.read and catalog.entity.read permissions. | ||
</Alert> | ||
); | ||
}; | ||
export default PermissionAlert; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { catalogEntityReadPermission } from '@backstage/plugin-catalog-common/alpha'; | ||
import { usePermission } from '@backstage/plugin-permission-react'; | ||
|
||
import { quayViewPermission } from '@janus-idp/backstage-plugin-quay-common'; | ||
|
||
export const useQuayViewPermission = () => { | ||
const quayViewPermissionResult = usePermission({ | ||
permission: quayViewPermission, | ||
}); | ||
|
||
const catalogEntityPermissionResult = usePermission({ | ||
permission: catalogEntityReadPermission, | ||
resourceRef: catalogEntityReadPermission.resourceType, | ||
}); | ||
|
||
return ( | ||
quayViewPermissionResult.allowed && catalogEntityPermissionResult.allowed | ||
); | ||
}; |
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