Skip to content

Commit 086e259

Browse files
authored
Merge pull request #267 from outerbase/develop
deployment 2025-01-26
2 parents c539eff + 391b7e6 commit 086e259

File tree

122 files changed

+7958
-9740
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+7958
-9740
lines changed

.vscode/settings.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
{
2-
"editor.formatOnSave": true,
3-
"typescript.tsdk": "node_modules\\typescript\\lib",
4-
"files.eol": "\n"
5-
}
2+
"editor.formatOnSave": true,
3+
"typescript.tsdk": "node_modules\\typescript\\lib",
4+
"files.eol": "\n",
5+
"editor.tabSize": 2,
6+
"editor.codeActionsOnSave": {
7+
"source.organizeImports": "explicit"
8+
}
9+
}

docs/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
This is working in progress about how to extend our studio functionality
2+
3+
## Extensions
4+
5+
We have transitioned our architecture to an extension-based approach, where most features will be implemented as extensions. This shift allows new contributors to easily contribute to the codebase without requiring in-depth knowledge of the entire system.
6+
7+
This is the minimalist example of extension
8+
9+
```typescript
10+
export default class SampleExtension extends StudioExtension {
11+
extensionName = "sample-extension";
12+
13+
init(studio: StudioExtensionContext): void {
14+
// this is where we extend studio functionality
15+
}
16+
}
17+
```
18+
19+
- All of the extension is located at `/src/extensions`.
20+
- Once you finish implement your extension, you can attach it to studio at `/src/core/standard-extension.tsx`
21+
22+
Below is a list of areas where extensions can build upon our core Outerbase Studio.
23+
24+
- [Sidebar](sidebar.md)
25+
- [Window Tab](window-tab.md)
26+
- Resource Creation Menu
27+
- Resource Context Menu
28+
- Query Hook

docs/sidebar.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## Extending Sidebar
2+
3+
To create extension that add new sidebar with content.
4+
5+
```tsx
6+
function SampleSidebar() {
7+
return <div>Sidebar Content</div>;
8+
}
9+
10+
export default class SampleExtension extends StudioExtension {
11+
extensionName = "sample-extension";
12+
13+
init(studio: StudioExtensionContext): void {
14+
studio.registerSidebar({
15+
key: "sample-extension-sidebar",
16+
name: "Sample",
17+
icon: <LucideArrow />,
18+
content: <SampleSidebar />,
19+
});
20+
}
21+
}
22+
```
23+
24+
You can also create sidebar without content. You need just need to provide `onClick` instead of `content`
25+
26+
```tsx
27+
export default class SampleExtension extends StudioExtension {
28+
extensionName = "sample-extension";
29+
30+
init(studio: StudioExtensionContext): void {
31+
studio.registerSidebar({
32+
key: "sample-extension-sidebar",
33+
name: "Sample",
34+
icon: <LucideArrow />,
35+
onClick: () => {
36+
// do something
37+
},
38+
});
39+
}
40+
}
41+
```

docs/window-tab.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Extending Window Tab
2+
3+
To create window tab, you need to use `createTabExtension`
4+
5+
- `key`: This is used to define the uniqueness of the tab. If no other tab has the same key, a new tab will be opened. Otherwise, it will attempt to reopen the previously opened tab with the same key. **Note: The key generated by the `key()` function will have the name appended to to avoid conflicts with other extensions.**
6+
- `generate`: This is used to define the component of the tab.
7+
8+
```typescript
9+
function SampleTabContent() {
10+
return <div>This is tab</div>;
11+
}
12+
13+
export const sampleExtensionTab = createTabExtension({
14+
name: "sample-extension",
15+
key: () => "sample-extension-type",
16+
generate: () => ({
17+
title: "Sample Extension",
18+
component: <SampleTabContent />,
19+
icon: LucideCog,
20+
}),
21+
});
22+
```
23+
24+
Now you can open this tab from any other code simply by
25+
26+
```typescript
27+
sampleExtensionTab.open();
28+
```
29+
30+
## Passing Parameters
31+
32+
You can pass additional parameters to tab as the following
33+
34+
```typescript
35+
function SampleTabContent(
36+
{ schema, table }:
37+
{ schema: string, table: string }
38+
) {
39+
return <div>This is tab for {table} of {schema}</div>;
40+
}
41+
42+
export const sampleExtensionTab = createTabExtension<{
43+
schema: string,
44+
table: string,
45+
}>({
46+
name: "sample-extension",
47+
key: ({ schema, table }) => `${schema}-${table}`,
48+
generate: ({ schema, table }) => ({
49+
title: "Sample Extension",
50+
component: <SampleTabContent schema={schema} table={table} />,
51+
icon: LucideCog,
52+
}),
53+
});
54+
```
55+
56+
To open the tab
57+
58+
```typescript
59+
sampleExtensionTab.open({
60+
schema: "public",
61+
table: "users",
62+
});
63+
```
64+
65+
You can also close the tab
66+
67+
```typescript
68+
sampleExtensionTab.close({
69+
schema: "public",
70+
table: "users",
71+
});
72+
```

next.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ const nextConfig = {
99
env: {
1010
NEXT_PUBLIC_STUDIO_VERSION: pkg.version,
1111
},
12+
async rewrites() {
13+
return [
14+
{
15+
source: "/api/v1/:path*",
16+
destination: `${process.env.NEXT_PUBLIC_OB_API ?? "https://app.dev.outerbase.com/api/v1"}/:path*`,
17+
},
18+
];
19+
},
1220
};
1321

1422
module.exports = withMDX(nextConfig);

0 commit comments

Comments
 (0)