Skip to content

Commit 0502c77

Browse files
authored
feat(quickstart): migrate quickstart plugin to NFS (#2842)
Signed-off-by: Rohit Rai <rohitkrai03@gmail.com>
1 parent f0afddf commit 0502c77

20 files changed

Lines changed: 777 additions & 38 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-quickstart': minor
3+
---
4+
5+
Added support for NFS

workspaces/quickstart/app-config-dev.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
app:
22
title: Scaffolded Backstage App
33
baseUrl: http://localhost:3001
4+
5+
# Enable all packages by default, this will discover packages from packages/app/package.json
6+
packages: all
7+
8+
extensions:
9+
- api:app/app-language:
10+
config:
11+
availableLanguages: ['en', 'de', 'es', 'fr', 'it', 'ja']
12+
defaultLanguage: 'en'
13+
414
quickstart:
515
- title: Set up authentication
616
titleKey: steps.setupAuthentication.title

workspaces/quickstart/app-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
app:
22
title: Scaffolded Backstage App
33
baseUrl: http://localhost:3000
4+
5+
# Enable all packages by default, this will discover packages from packages/app/package.json
6+
packages: all
7+
8+
extensions:
9+
- api:app/app-language:
10+
config:
11+
availableLanguages: ['en', 'de', 'es', 'fr', 'it', 'ja']
12+
defaultLanguage: 'en'
13+
414
quickstart:
515
- title: Set up authentication
616
titleKey: steps.setupAuthentication.title

workspaces/quickstart/e2e-tests/quick-start-developer.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import { test, TestInfo } from '@playwright/test';
16+
import { test, expect, TestInfo } from '@playwright/test';
1717
import { UIhelper, switchToLocale } from './utils/helper';
1818
import { getTranslations, QuickstartMessages } from './utils/translations';
1919
import { runAccessibilityTests } from './utils/accessibility';
@@ -143,7 +143,7 @@ test.describe('Test Quick Start plugin', () => {
143143
await uiHelper.clickButtonByText(
144144
translations.steps.exploreSelfServiceTemplates.ctaTitle,
145145
);
146-
await uiHelper.verifyHeading('Create a new component');
146+
await expect(page).toHaveURL(/\/create/);
147147
await page.getByText(translations.steps.findAllLearningPaths.title).click();
148148
await uiHelper.verifyButtonURL(
149149
translations.steps.findAllLearningPaths.ctaTitle,

workspaces/quickstart/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323
"prettier:fix": "prettier --write .",
2424
"new": "backstage-cli new --scope @red-hat-developer-hub",
2525
"postinstall": "cd ../../ && yarn install",
26-
"test:e2e": "playwright test"
26+
"test:e2e": "yarn test:e2e:all",
27+
"test:e2e:legacy": "APP_MODE=legacy playwright test",
28+
"test:e2e:nfs": "APP_MODE=nfs playwright test",
29+
"test:e2e:all": "yarn test:e2e:legacy && yarn test:e2e:nfs",
30+
"test:e2e:ci": "yarn test:e2e:all",
31+
"playwright": "bash -c 'if [[ $@ == test ]]; then yarn test:e2e:all; else npx playwright \"$@\"; fi' _"
2732
},
2833
"workspaces": {
2934
"packages": [

workspaces/quickstart/packages/app/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
"@backstage/ui": "^0.13.1",
4444
"@material-ui/core": "^4.12.2",
4545
"@material-ui/icons": "^4.9.1",
46+
"@mui/icons-material": "5.18.0",
47+
"@mui/material": "5.18.0",
48+
"@red-hat-developer-hub/backstage-plugin-app-react": "^0.0.3",
49+
"@red-hat-developer-hub/backstage-plugin-quickstart": "workspace:^",
4650
"react": "^18.0.2",
4751
"react-dom": "^18.0.2",
4852
"react-router": "^6.30.2",

workspaces/quickstart/packages/app/src/App.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,19 @@
1414
* limitations under the License.
1515
*/
1616
import { createApp } from '@backstage/frontend-defaults';
17-
import catalogPlugin from '@backstage/plugin-catalog/alpha';
17+
import { appDrawerModule } from '@red-hat-developer-hub/backstage-plugin-app-react/alpha';
18+
import quickstartPlugin, {
19+
quickstartInitModule,
20+
quickstartTranslationsModule,
21+
} from '@red-hat-developer-hub/backstage-plugin-quickstart/alpha';
1822
import { navModule } from './modules/nav';
1923

2024
export default createApp({
21-
features: [catalogPlugin, navModule],
25+
features: [
26+
appDrawerModule,
27+
quickstartPlugin,
28+
quickstartInitModule,
29+
quickstartTranslationsModule,
30+
navModule,
31+
],
2232
});

workspaces/quickstart/packages/app/src/modules/nav/Sidebar.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,44 @@ import {
2222
SidebarSpace,
2323
} from '@backstage/core-components';
2424
import { NavContentBlueprint } from '@backstage/plugin-app-react';
25+
import { useAppDrawer } from '@red-hat-developer-hub/backstage-plugin-app-react';
26+
import WavingHandOutlinedIcon from '@mui/icons-material/WavingHandOutlined';
27+
import HomeIcon from '@material-ui/icons/Home';
2528
import { SidebarLogo } from './SidebarLogo';
2629
import MenuIcon from '@material-ui/icons/Menu';
30+
import SearchIcon from '@material-ui/icons/Search';
31+
import { SidebarSearchModal } from '@backstage/plugin-search';
2732
import { UserSettingsSignInAvatar } from '@backstage/plugin-user-settings';
2833

34+
const QUICKSTART_DRAWER_ID = 'quickstart';
35+
2936
export const SidebarContent = NavContentBlueprint.make({
3037
params: {
3138
component: ({ navItems }) => {
3239
const nav = navItems.withComponent(item => (
3340
<SidebarItem icon={() => item.icon} to={item.href} text={item.title} />
3441
));
3542

36-
// Skipped items
37-
nav.take('page:search'); // Using search modal instead
43+
nav.take('page:search');
44+
nav.take('page:catalog');
3845

3946
return (
4047
<Sidebar>
4148
<SidebarLogo />
49+
<SidebarGroup label="Search" icon={<SearchIcon />} to="/search">
50+
<SidebarSearchModal />
51+
</SidebarGroup>
4252
<SidebarDivider />
4353
<SidebarGroup label="Menu" icon={<MenuIcon />}>
44-
{nav.take('page:catalog')}
54+
<SidebarItem icon={HomeIcon} to="/catalog" text="Home" />
4555
{nav.take('page:scaffolder')}
4656
<SidebarDivider />
4757
<SidebarScrollWrapper>
4858
{nav.rest({ sortBy: 'title' })}
4959
</SidebarScrollWrapper>
5060
</SidebarGroup>
5161
<SidebarSpace />
52-
<SidebarDivider />
62+
<QuickstartSidebarItem />
5363
<SidebarDivider />
5464
<SidebarGroup
5565
label="Settings"
@@ -64,3 +74,14 @@ export const SidebarContent = NavContentBlueprint.make({
6474
},
6575
},
6676
});
77+
78+
function QuickstartSidebarItem() {
79+
const { toggleDrawer } = useAppDrawer();
80+
return (
81+
<SidebarItem
82+
text="Quick start"
83+
icon={WavingHandOutlinedIcon}
84+
onClick={() => toggleDrawer(QUICKSTART_DRAWER_ID)}
85+
/>
86+
);
87+
}

workspaces/quickstart/packages/app/src/modules/nav/SidebarLogo.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ export const SidebarLogo = () => {
4343

4444
return (
4545
<div className={classes.root}>
46-
<Link to="/" underline="none" className={classes.link} aria-label="Home">
46+
<Link
47+
to="/catalog"
48+
underline="none"
49+
className={classes.link}
50+
aria-label="Home"
51+
>
4752
{isOpen ? <LogoFull /> : <LogoIcon />}
4853
</Link>
4954
</div>

workspaces/quickstart/plugins/quickstart/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@
3838
"@backstage-community/plugin-rbac-common": "^1.19.0",
3939
"@backstage/core-components": "^0.18.8",
4040
"@backstage/core-plugin-api": "^1.12.4",
41+
"@backstage/frontend-plugin-api": "^0.15.1",
42+
"@backstage/plugin-app-react": "^0.2.1",
4143
"@backstage/plugin-permission-react": "^0.4.41",
4244
"@backstage/theme": "^0.7.2",
4345
"@mui/icons-material": "5.18.0",
4446
"@mui/material": "5.18.0",
47+
"@red-hat-developer-hub/backstage-plugin-app-react": "^0.0.3",
4548
"@red-hat-developer-hub/backstage-plugin-theme": "^0.12.0",
4649
"react-use": "^17.6.0"
4750
},
@@ -62,14 +65,14 @@
6265
},
6366
"exports": {
6467
".": "./src/index.ts",
65-
"./alpha": "./src/alpha.ts",
68+
"./alpha": "./src/alpha/index.tsx",
6669
"./dev": "./dev/CustomDrawer.tsx",
6770
"./package.json": "./package.json"
6871
},
6972
"typesVersions": {
7073
"*": {
7174
"alpha": [
72-
"src/alpha.ts"
75+
"src/alpha/index.tsx"
7376
],
7477
"dev": [
7578
"dev/CustomDrawer.tsx"
@@ -88,7 +91,7 @@
8891
"scalprum": {
8992
"name": "red-hat-developer-hub.backstage-plugin-quickstart",
9093
"exposedModules": {
91-
"Alpha": "./src/alpha.ts",
94+
"Alpha": "./src/alpha/index.tsx",
9295
"PluginRoot": "./src/index.ts",
9396
"QuickstartPlugin": "./src/index.ts"
9497
}

0 commit comments

Comments
 (0)