Skip to content

chore: setup initial repo #2

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

Merged
merged 17 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: add code for isolated plugin development
  • Loading branch information
Parkreiner committed Feb 14, 2024
commit 3dd9b1b8736834455b71895e5477c849c939a1a5
69 changes: 69 additions & 0 deletions plugins/backstage-plugin-coder/dev/DevPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New component

* @file Defines a simple routable component for wrapping around non-page
* Backstage components.
*/
import React from 'react';
import { CoderWorkspacesCard } from '../src/components/CoderWorkspacesCard';
import {
type CoderAppConfig,
CoderProvider,
} from '../src/components/CoderProvider';

import {
Content,
ContentHeader,
Header,
Page,
SupportButton,
} from '@backstage/core-components';
import { Grid } from '@material-ui/core';

const appConfig: CoderAppConfig = {
deployment: {
accessUrl: 'https://dev.coder.com',
},

workspaces: {
templateName: 'devcontainers',
mode: 'manual',
repoUrlParamKeys: ['custom_repo', 'repo_url'],
params: {
repo: 'custom',
region: 'eu-helsinki',
},
},
};

const pluginTitle = 'Coder Plugin - dev mode';

export const DevPage = () => {
return (
<CoderProvider appConfig={appConfig}>
<Page themeId="tool">
<Header
title={pluginTitle}
subtitle="Place non-routable components in this wrapper for development"
/>

<Content>
<ContentHeader title={pluginTitle}>
<SupportButton />
</ContentHeader>

<Grid container spacing={3} direction="column">
<Grid
item
style={{
width: '600px',
marginLeft: 'auto',
marginRight: 'auto',
}}
>
<CoderWorkspacesCard />
</Grid>
</Grid>
</Content>
</Page>
</CoderProvider>
);
};
30 changes: 26 additions & 4 deletions plugins/backstage-plugin-coder/dev/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
import React from 'react';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a new file, but this is the first time it's really being filled out

import { createDevApp } from '@backstage/dev-utils';
import { coderPlugin, CoderPage } from '../src/plugin';

import { coderPlugin } from '../src/plugin';
import { createRoutableExtension } from '@backstage/core-plugin-api';
import { rootRouteRef } from '../src/routes';

/**
* This extension should only be made available in dev mode, which is why it is
* not being exported with the other extensions.
*
* 2024-02-14 - This does not work just yet – the plugin is able to launch in
* isolated dev mode, but it needs a running backend process so that it has a
* proxy to go through. With no backend, all network requests will time out.
*
* @todo Figure out how to make proxying available to isolated plugin instances;
* until then, development will have to be done with a full Backstage app.
*/
const DevEnvironmentPage = coderPlugin.provide(
createRoutableExtension({
name: 'CoderDevPage',
mountPoint: rootRouteRef,
component: () => import('./DevPage').then(m => m.DevPage),
}),
);

createDevApp()
.registerPlugin(coderPlugin)
.addPage({
element: <CoderPage />,
title: 'Root Page',
path: '/backstage-plugin-coder',
element: <DevEnvironmentPage />,
title: 'CoderDevPage',
path: '/dev',
})
.render();