Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[announcements] Migrate announcements plugin #1134

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions workspaces/announcements/.changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
11 changes: 11 additions & 0 deletions workspaces/announcements/.changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
10 changes: 10 additions & 0 deletions workspaces/announcements/.changeset/twenty-bottles-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
'@backstage-community/plugin-search-backend-module-announcements': minor
'@backstage-community/plugin-announcements-backend': minor
'@backstage-community/plugin-announcements-common': minor
'@backstage-community/plugin-announcements-react': minor
'@backstage-community/plugin-announcements-node': minor
'@backstage-community/announcements': minor
---

Migrates the existing [announcements plugins](https://github.com/procore-oss/backstage-plugin-announcements) to @backstage-community. This change will benefit from the new `@backstage-community` namespace and will allow for easier maintenance and collaboration.
19 changes: 19 additions & 0 deletions workspaces/announcements/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8

# 4 space indentation for JS stuff
[*.{js,json,ts,tsx}]
indent_style = space
indent_size = 2

# Tab indentation (no size specified)
[Makefile]
indent_style = tab
3 changes: 3 additions & 0 deletions workspaces/announcements/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
root: true,
};
26 changes: 26 additions & 0 deletions workspaces/announcements/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
node_modules

# Tests
coverage

# Ts generated output
dist-types
dist

# Yarn 3 files
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

.env
.npmrc
**/*.tgz
.vscode
.idea

local.sqlite
tmp/*
1 change: 1 addition & 0 deletions workspaces/announcements/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 18.17.1
98 changes: 98 additions & 0 deletions workspaces/announcements/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Contributing Guidelines

`backstage-plugin-announcements` is [MIT licensed](LICENSE.md) and accepts contributions via
GitHub pull requests. This document outlines some of the conventions on
the development workflow, commit message formatting, contact points, and other
resources to make it easier to get your contribution accepted.

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. ❤️

## Support Channels

The official support channels, for both users and contributors, are:

- GitHub [issues](https://github.com/backstage-community/backstage-plugin-announcements/issues)

## How to Contribute

Pull Requests (PRs) are the main and exclusive way to contribute to the project.

## Local setup

### Create a fork

[Fork][fork], then clone the repository:

```bash
git clone [email protected]:your_github_username/backstage-plugin-announcements.git
cd backstage-plugin-announcements
git remote add upstream https://github.com/backstage-community/backstage-plugin-announcements.git
git fetch upstream
```

### Install dependencies

```bash
cp env.sample .env

yarn install
```

### Run the plugins locally

A standalone development version of both the frontend and backend plugins are included in this repository.
They can be started as follows:

```bash
yarn dev # starts both the frontend and the backend in parallel
yarn start # starts the frontend only
yarn start-backend # starts the backend only
```

## Making Changes

Start by creating a new branch for your changes:

```bash
git checkout main
git fetch upstream
git rebase upstream/main
git checkout -b new-feature
```

Make your changes, then ensure that `yarn lint` and `yarn test` still pass. If you're satisfied with your changes, push them to your fork.

```bash
git push origin new-feature
```

Then use the GitHub UI to open a pull request.

Your changes are much more likely to be approved if you:

- add tests for new functionality
- write a [good commit message][commit-message]
- maintain backward compatibility

## Creating Changesets

We use [changesets](https://github.com/atlassian/changesets) in order to prepare releases. To make the process of generating releases easy, please include changesets with your pull request. This will result in a every package affected by a change getting a proper version number and an entry in its `CHANGELOG.md.

### When to use a changeset?

Any time a patch, minor, or major change aligning to [Semantic Versioning](https://semver.org) is made to any published package in `plugins/`, a changeset should be used.
In general, changesets are not needed for the documentation, build utilities or similar.

### How to create a changeset

1. Run `yarn changeset`
2. Select which packages you want to include a changeset for
3. Select impact of change that you're introducing, using `minor` for breaking changes and `patch` otherwise.
4. Explain your changes in the generated changeset. See [examples of well written changesets](https://backstage.io/docs/getting-started/contributors#writing-changesets).
5. Add generated changeset to git
6. Push the commit with your changeset to the branch associated with your PR

For more information, checkout [adding a changeset](https://github.com/atlassian/changesets/blob/master/docs/adding-a-changeset.md) documentation in the changesets repository.

[fork]: https://github.com/backstage-community/backstage-plugin-announcements/fork
[commit-message]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
35 changes: 35 additions & 0 deletions workspaces/announcements/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Announcements plugin for Backstage

## Overview

The Announcements plugin is a frontend, backend, and common plugin that manages and displays announcements within Backstage.

This plugin provides:

- a component to display the latest announcement as a banner, if there is one
- a component to display the latest announcements, for example on a homepage
- pages to list, view, create, edit and delete announcements
- integration with the [`@backstage/plugin-search`](https://github.com/backstage/backstage/tree/master/plugins/search) plugin
- integration with the [`@backstage/plugin-permission-backend`](https://github.com/backstage/backstage/tree/master/plugins/permission-backend) plugin

## Installation

Find [installation instructions](./docs/index.md#installation) in our documentation.

## How does it look?

### Latest announcement banner

![Latest announcement banner](./docs/images/announcement_banner.png)

### Announcements card

![Announcements card](./docs/images/announcements_card.png)

### Announcements page

![Announcements page](./docs/images/announcements_page.png)

### Announcements search

![Announcements search results](./docs/images/announcements_search.png)
28 changes: 28 additions & 0 deletions workspaces/announcements/app-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
app:
title: Announcements Dev App
baseUrl: http://localhost:3000

backend:
baseUrl: http://localhost:7007
listen:
port: 7007
database:
client: better-sqlite3
connection: ':memory:'
cache:
store: memory
cors:
origin: http://localhost:3000
methods: [GET, HEAD, PATCH, POST, PUT, DELETE]
credentials: true
csp:
connect-src: ["'self'", 'http:', 'https:']
# Content-Security-Policy directives follow the Helmet format: https://helmetjs.github.io/#reference
# Default Helmet Content-Security-Policy values can be removed by setting the key to false
reading:
allow:
- host: localhost

auth:
providers:
guest: {}
3 changes: 3 additions & 0 deletions workspaces/announcements/backstage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "1.30.1"
}
21 changes: 21 additions & 0 deletions workspaces/announcements/docs/announcement-timeline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Display announcements in a timeline

Adding the `AnnouncementsTimeline` component to a page will display a raw timeline of the latest announcements.

```ts
import { AnnouncementsTimeline } from '@backstage-community/plugin-announcements';

export const TimelineExampleCard = () => {
return (
<Content>
<Grid container>
<Grid item md={6}>
<InfoCard>
<AnnouncementsTimeline />
</InfoCard>
</Grid>
</Grid>
</Content>
);
};
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions workspaces/announcements/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Getting started

## Installation

- [Plugin setup](setup.md)

## Usage

- [Integration with `@backstage/plugin-search`](search.md)

## Components

- [Display latest announcements on a page](latest-announcements-on-page.md)
- [Display a banner for the latest announcement](latest-announcement-banner.md)
- [Display announcements in a timeline](announcement-timeline.md)

## Customization

### Overriding the AnnouncementCard

It is possible to specify the length of the title for announcements rendered on the `AnnouncementsPage`. You can do this by passing a `cardOptions` prop to the `AnnouncementsPage` component. The `cardOptions` prop accepts an object with the following properties:

```ts
{
titleLength: number; // defaults to 50
}
```

Example

```tsx
<AnnouncementsPage cardOptions={{ titleLength: 10 }} />
```

### Overriding the AnnouncementsPage

It is possible to specify the Announcements within a specific category rendered on the `AnnouncementsPage`. You can do this by passing a `category` prop to the `AnnouncementsPage` component. The `AnnouncementsPage` prop accepts an value such as:

```ts
category = 'conferences';
```

Example

```tsx
<AnnouncementsPage category="conferences" />
```

### Overriding the AnnouncementCreateButton

It is possible to specify the text for the "New announcement" button rendered on the `AnnouncementsPage`. You can do this by passing a `buttonOptions` prop to the `AnnouncementsPage` component. The `buttonOptions` prop accepts an object with the following properties:

```ts
{
name: string; // defaults to 'announcement'
}
```
25 changes: 25 additions & 0 deletions workspaces/announcements/docs/latest-announcement-banner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Display a banner for the latest announcement

Adding the `NewAnnouncementBanner` component to a page will display a banner with the title and excerpt of the latest unseen announcement.

**Note:** if there are no announcements or the latest announcement has already been seen by the user, nothing will be displayed.

```ts
import { NewAnnouncementBanner } from '@backstage-community/plugin-announcements';

export const HomePage = () => {
return (
<Page themeId="home">
<Header title="NewAnnouncementBanner" />

<Content>
<Grid container>
<Grid item md={12}>
<NewAnnouncementBanner />
</Grid>
</Grid>
</Content>
</Page>
);
};
```
24 changes: 24 additions & 0 deletions workspaces/announcements/docs/latest-announcements-on-page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Display latest announcements on a page

Adding the `AnnouncementsCard` component to a page will display a Card with the latest announcements.
Announcements yet unseen by the user will be prefixed by a specific icon.

```ts
import { AnnouncementsCard } from '@backstage-community/plugin-announcements';

export const HomePage = () => {
return (
<Page themeId="home">
<Header title="AnnouncementsCard" />

<Content>
<Grid container>
<Grid item md={6}>
<AnnouncementsCard max={3} />
</Grid>
</Grid>
</Content>
</Page>
);
};
```
Loading
Loading