-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added environments and launch functionality to projects (#87)
* feat: add environments schema definition Signed-off-by: Francisco Madeira <francisco.madeira@diconium.com> * feat: remove query from getProjects action * refactor: remove query from getProjects * refactor: remove query from getProjectsById * refactor: fix projects/{id} with fixed environtment * refactor: project components list and add * refactor: project components actions * feat: add environment picker * feat: add environment picker to projects page Signed-off-by: Francisco Madeira <francisco.madeira@diconium.com> * refactor: component actions with environments * refactor: api routes for projects * feat: add new environment based api routes * feat: add copy url to environments * feat: actions on project environments * refactor: clean types on projects actions * feat: add default environment to new projects * feat: create launch page Signed-off-by: Francisco Madeira <francisco.madeira@diconium.com> * feat: added launch funcionality * feat: improve comparison page result Signed-off-by: Francisco Madeira <francisco.madeira@diconium.com> * chore: add changeset Signed-off-by: Francisco Madeira <francisco.madeira@diconium.com> * fix: remove group to display all the components Signed-off-by: Francisco Madeira <francisco.madeira@diconium.com> * chore: update the release workflow Signed-off-by: Francisco Madeira <francisco.madeira@diconium.com> --------- Signed-off-by: Francisco Madeira <francisco.madeira@diconium.com>
- Loading branch information
Showing
48 changed files
with
2,509 additions
and
766 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
'@ethereal-nexus/dashboard': major | ||
'@ethereal-nexus/site': major | ||
'@ethereal-nexus/cli': major | ||
'@ethereal-nexus/conector-aem-react': major | ||
'@ethereal-nexus/core': major | ||
'@ethereal-nexus/vite-plugin-ethereal-nexus': major | ||
--- | ||
|
||
This is the first Major release of Ethereal Nexus! | ||
|
||
Added environments features. This allows projects to have several configurations based on the respective environemnt and to publish them from one environment to the other using launches. | ||
Because of this there were breaking changes to the schema of the component configs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
'@ethereal-nexus/core': patch | ||
--- | ||
|
||
fix type inference for select schema | ||
Fix type inference for select schema |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
- uses: pnpm/action-setup@v4 | ||
name: Install pnpm | ||
with: | ||
run_install: false | ||
|
||
- name: Install Dependencies | ||
run: pnpm i --frozen-lockfile | ||
|
||
- name: Build Packages | ||
run: pnpm run build | ||
|
||
- name: Fix npmrc | ||
run: npm config set "//registry.npmjs.org/:_authToken" "$NPM_TOKEN" | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Publish to npm | ||
id: changesets | ||
uses: changesets/action@v1 | ||
with: | ||
publish: pnpm release | ||
commit: "chore: release version" | ||
title: "[ci] Release version" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 26 additions & 33 deletions
59
web/dashboard/src/app/(session)/components/[id]/versions/[versionId]/[tab]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,44 @@ | ||
import React from 'react'; | ||
import {Separator} from '@/components/ui/separator'; | ||
import {notFound} from 'next/navigation'; | ||
import { | ||
getComponentById, | ||
getComponentDependentsProjectsWithOwners, | ||
getComponentVersions | ||
} from "@/data/components/actions"; | ||
import ComponentVersionHeader from "@/components/components/component/version/header"; | ||
import ComponentVersionTabs from "@/components/components/component/version/tabs"; | ||
import {auth} from "@/auth"; | ||
import {getMembersByResourceId} from "@/data/member/actions"; | ||
import {getResourceEvents} from "@/data/events/actions"; | ||
import { Separator } from '@/components/ui/separator'; | ||
import { notFound } from 'next/navigation'; | ||
import { getComponentById, getComponentDependentsProjects, getComponentVersions } from '@/data/components/actions'; | ||
import ComponentVersionHeader from '@/components/components/component/version/header'; | ||
import ComponentVersionTabs from '@/components/components/component/version/tabs'; | ||
import { auth } from '@/auth'; | ||
import { getResourceEvents } from '@/data/events/actions'; | ||
|
||
export default async function EditComponentVersion({params: {id, versionId, tab}}: any) { | ||
const session = await auth() | ||
|
||
const component = await getComponentById(id); | ||
const versions = await getComponentVersions(id); | ||
const dependents = await getComponentDependentsProjectsWithOwners(id); | ||
const dependents = await getComponentDependentsProjects(id, session?.user?.id); | ||
const events = await getResourceEvents(id); | ||
const projects = await getComponentDependentsProjectsWithOwners(id); | ||
|
||
if (projects.success) { | ||
projects.data = await Promise.all( | ||
projects.data.map(async (project) => { | ||
const membersData = await getMembersByResourceId(project.id, session?.user?.id); | ||
const userHasAccess = (membersData.success && membersData.data.some(member => member.user_id == session?.user?.id)); | ||
|
||
return { | ||
...project, | ||
userHasAccess | ||
}; | ||
}) | ||
); | ||
} | ||
|
||
if (!versions.success || !component.success || !dependents.success || !projects.success) { | ||
if (!versions.success || !component.success || !dependents.success ) { | ||
notFound(); | ||
} | ||
|
||
const safeDependents = dependents.data.map(p => p.has_access ? p : null) | ||
const selectedVersion = versions.data.filter((version: any) => version.id === versionId)[0]; | ||
|
||
return ( | ||
<div className="container space-y-6"> | ||
<ComponentVersionHeader versions={versions} component={component} | ||
selectedVersion={selectedVersion} activeTab={tab}/> | ||
<ComponentVersionHeader | ||
versions={versions} | ||
component={component} | ||
selectedVersion={selectedVersion} | ||
activeTab={tab} | ||
/> | ||
<Separator/> | ||
<ComponentVersionTabs activeTab={tab} versions={versions} selectedVersion={selectedVersion} | ||
component={component} dependents={projects.data} events={events}/> | ||
<ComponentVersionTabs | ||
activeTab={tab} | ||
versions={versions} | ||
selectedVersion={selectedVersion} | ||
component={component} | ||
dependents={safeDependents} | ||
events={events} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
web/dashboard/src/app/(session)/projects/launch/new/[id]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import React from 'react'; | ||
import { ComparisonResult, LaunchesList } from '@/components/launches/table/launches-list'; | ||
import { getEnvironmentsById, getEnvironmentsByProject } from '@/data/projects/actions'; | ||
import { auth } from '@/auth'; | ||
import { EnvironmentWithComponents } from '@/data/projects/dto'; | ||
import { notFound } from 'next/navigation'; | ||
import { EnvironmentPicker } from './picker'; | ||
|
||
function compareEnvironments(from: EnvironmentWithComponents, to: EnvironmentWithComponents): ComparisonResult[] { | ||
const result: ComparisonResult[] = []; | ||
|
||
from.components.forEach((compFrom) => { | ||
const compTo = to.components.find((c) => c.id === compFrom.id); | ||
|
||
if (compTo) { | ||
result.push({ | ||
id: compFrom.id, | ||
name: compFrom.name, | ||
title: compFrom.title, | ||
new: false, | ||
is_active: { | ||
from: compFrom.is_active, | ||
to: compTo.is_active, | ||
}, | ||
version: { | ||
from: compFrom.version || 'latest', | ||
to: compTo.version || 'latest', | ||
}, | ||
}); | ||
} else { | ||
result.push({ | ||
id: compFrom.id, | ||
name: compFrom.name, | ||
title: compFrom.title, | ||
new: true, | ||
is_active: { | ||
from: compFrom.is_active, | ||
to: null, | ||
}, | ||
version: { | ||
from: compFrom.version || 'latest', | ||
to: null, | ||
}, | ||
}) | ||
} | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
export default async function NewLaunch({ params: { id } }: any) { | ||
const session = await auth() | ||
const [fromId, toId] = id.split('...') | ||
|
||
const from = await getEnvironmentsById(fromId, session?.user?.id) | ||
const to = await getEnvironmentsById(toId, session?.user?.id) | ||
|
||
if (!from.success || !to.success || from.data.project_id !== to.data.project_id) { | ||
notFound(); | ||
} | ||
|
||
const environments = await getEnvironmentsByProject(from.data.project_id, session?.user?.id) | ||
const comparison = compareEnvironments(from.data, to.data); | ||
|
||
return ( | ||
<div className="container h-full flex-1 flex-col space-y-8 p-8 md:flex"> | ||
<div className="w-full flex items-end"> | ||
<div className="mr-auto"> | ||
<div className="flex items-baseline"> | ||
<h2 className="text-2xl font-bold tracking-tight">Create Launch</h2> | ||
</div> | ||
<p className="text-muted-foreground">Compare the changes to launch</p> | ||
</div> | ||
</div> | ||
<EnvironmentPicker | ||
from={from.data} | ||
to={to.data} | ||
environments={environments.success ? environments.data : []} | ||
/> | ||
<LaunchesList | ||
from={from.data} | ||
to={to.data} | ||
comparison={comparison} | ||
/> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.