Skip to content

Commit

Permalink
Adding changes to export widgets to be imported as card (#83)
Browse files Browse the repository at this point in the history
* Adding changes to export widgets to be imported as card

Signed-off-by: Balasundaram <[email protected]>

* Adding changes to include individual cards

* version bump

Co-authored-by: Sathish Kumar <[email protected]>
  • Loading branch information
Balasundaram and satrox28 authored Feb 11, 2022
1 parent 0038ad8 commit 34b5b33
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 8 deletions.
44 changes: 40 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,58 @@ yarn add @loblaw/backstage-plugin-gitlab
```


2. Add the `EntityGitlabContent` extension to the entity page in your app:
2. Add a new Gitlab tab to the entity page.

```tsx
// In packages/app/src/components/catalog/EntityPage.tsx
// packages/app/src/components/catalog/EntityPage.tsx

import { isGitlabAvailable, EntityGitlabContent } from '@loblaw/backstage-plugin-gitlab';

// Farther down at the serviceEntityPage declaration
const serviceEntityPage = (
<EntityLayout>
{/* Place the following section where you want the tab to appear */}
<EntityLayout.Route if={isGitlabAvailable} path="/gitlab" title="Gitlab">
<EntityGitlabContent />
</EntityLayout.Route>
</EntityLayout>
);
```
3. Add the Gitlab cards to the Overview tab on the entity page(Optional).

```tsx
// packages/app/src/components/catalog/EntityPage.tsx

import {
isGitlabAvailable,
EntityGitlabContent,
EntityGitlabLanguageCard,
EntityGitlabContributorsCard,
EntityGitlabMergeRequestsTable,
EntityGitlabMergeRequestStatsCard,
EntityGitlabPipelinesTable
} from '@loblaw/backstage-plugin-gitlab';

//Farther down at the overviewContent declaration
//Depends on user's need the individual card can be added or removed from the Grid item.
const overviewContent = (
<Grid container spacing={3} alignItems="stretch">
<EntitySwitch>
<EntitySwitch.Case if={isGitlabAvailable}>
<Grid item md={6}>
<EntityGitlabContributorsCard />
<EntityGitlabLanguageCard />
<EntityGitlabMergeRequestStatsCard />
<EntityGitlabPipelinesTable />
<EntityGitlabMergeRequestsTable />
</Grid>
</EntitySwitch.Case>
</EntitySwitch>
</Grid>
);
```

3. Add integration:
4. Add integration:
In `app-config.yaml` add the integration for gitlab:
```
integrations:
Expand All @@ -60,7 +96,7 @@ integrations:
token: ${GITLAB_TOKEN}
```

4. Add proxy config:
5. Add proxy config:

```
'/gitlabci':
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@loblaw/backstage-plugin-gitlab",
"version": "0.1.20",
"version": "0.1.21",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
Expand Down
13 changes: 11 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
export { gitlabPlugin, EntityGitlabContent } from './plugin';
export { isGitlabAvailable } from './Router';
export {
gitlabPlugin,
EntityGitlabContent,
EntityGitlabLanguageCard,
EntityGitlabContributorsCard,
EntityGitlabMergeRequestsTable,
EntityGitlabMergeRequestStatsCard,
EntityGitlabPipelinesTable,
} from './plugin';

export { isGitlabAvailable } from './Router';
55 changes: 54 additions & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { createPlugin, createRoutableExtension } from '@backstage/core-plugin-api';
import { createPlugin,
createRoutableExtension,
createComponentExtension,
} from '@backstage/core-plugin-api';

import {
configApiRef,
Expand Down Expand Up @@ -34,3 +37,53 @@ export const EntityGitlabContent = gitlabPlugin.provide(
mountPoint: rootRouteRef,
}),
);

export const EntityGitlabLanguageCard = gitlabPlugin.provide(
createComponentExtension({
name: 'EntityGitlabLanguageCard',
component: {
lazy: () =>
import('./components/widgets/index').then((m) => m.LanguagesCard),
},
})
);

export const EntityGitlabContributorsCard = gitlabPlugin.provide(
createComponentExtension({
name: 'EntityGitlabContributorsCard',
component: {
lazy: () =>
import('./components/widgets/index').then((m) => m.ContributorsCard),
},
})
);

export const EntityGitlabMergeRequestsTable = gitlabPlugin.provide(
createComponentExtension({
name: 'EntityGitlabMergeRequestsTable',
component: {
lazy: () =>
import('./components/widgets/index').then((m) => m.MergeRequestsTable),
},
})
);

export const EntityGitlabMergeRequestStatsCard = gitlabPlugin.provide(
createComponentExtension({
name: 'EntityGitlabMergeRequestStatsCard',
component: {
lazy: () =>
import('./components/widgets/index').then((m) => m.MergeRequestStats),
},
})
);

export const EntityGitlabPipelinesTable = gitlabPlugin.provide(
createComponentExtension({
name: 'EntityGitlabPipelinesTable',
component: {
lazy: () =>
import('./components/widgets/index').then((m) => m.PipelinesTable),
},
})
);

0 comments on commit 34b5b33

Please sign in to comment.