Skip to content

Commit

Permalink
feat: portal administration application (#710)
Browse files Browse the repository at this point in the history
Co-authored-by: Gustav Eikaas <[email protected]>
Co-authored-by: Noggling <[email protected]>
Co-authored-by: Edward Brunton <[email protected]>
  • Loading branch information
4 people authored Sep 13, 2024
1 parent f17f776 commit dee5213
Show file tree
Hide file tree
Showing 139 changed files with 13,944 additions and 68 deletions.
5 changes: 5 additions & 0 deletions .changeset/pr-710-2025280865.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

---
"fusion-project-portal": minor
---
Portal administration application. for managing portal configurations
2 changes: 1 addition & 1 deletion .github/actions/es-lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ runs:
report-json: "eslint-report.log.json"

- name: Upload ESLint report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
continue-on-error: true
with:
name: eslint-report.log.json
Expand Down
32 changes: 32 additions & 0 deletions .github/actions/get-fusion-token/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Get Fusion token
description: "Runs a composite step action"
inputs:
client-id:
description: "SP client id"
required: true
tenant-id:
description: "Equinor tenant id"
required: true
resource-id:
description: "Resource id"
required: true

outputs:
token:
description: "Fusion token"
value: ${{ steps.token.outputs.token }}

runs:
using: "composite"
steps:
- name: "Login to Azure"
uses: azure/login@v1
with:
client-id: ${{inputs.client-id}}
tenant-id: ${{ inputs.tenant-id }}
allow-no-subscriptions: true

- name: "Obtain token for upload"
id: token
shell: bash
run: echo "token=$(az account get-access-token --resource '${{ inputs.resource-id }}' | jq '.accessToken')" >> $GITHUB_OUTPUT
11 changes: 11 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,14 @@ runs:
cd client
yarn install --frozen-lockfile
shell: bash

- name: Install Fusion CLI
run: |
npm i -g @equinor/fusion-framework-cli
shell: bash

- name: Install App Deps
run: |
cd client/apps/portal-administration
yarn install
shell: bash
43 changes: 43 additions & 0 deletions .github/workflows/common-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,46 @@ jobs:
--from-environment test
--to-environment prod
--deployment ${{ steps.get_active_deployments.outputs.activeDeploymentApi }}
releas-admin:
name: Production Release Portal Administartion Application
needs: changesets
environment: production
runs-on: ubuntu-latest
if: needs.changesets.outputs.published == 'true'
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Get fusion token
id: "get-fusion-token"
uses: ./.github/actions/get-fusion-token
with:
client-id: ${{secrets.AZURE_SP_FUSION}}
tenant-id: ${{secrets.AZURE_TENANT_ID}}
resource-id: ${{secrets.AZURE_FUSION_SCOPE}}

- name: Install
run: |
cd client
yarn install
npm i -g @equinor/fusion-framework-cli
cd apps/portal-administration
yarn install
- name: Build
run: |
cd client
yarn build
- name: Deploy
run: |
cd client/apps/portal-administration
yarn bundle
curl -T "app-bundle.zip" -H "Authorization: bearer ${{steps.get-fusion-token.outputs.token}}" -H "Content-Disposition: attachment; filename=app-bundle.zip" -H "Content-Type: application/zip" -X POST --show-error -i --url https://fusion-s-portal-fprd.azurewebsites.net/api/apps/portal-administration/versions
- name: Publish
run: |
curl -H "Authorization: bearer ${{steps.get-fusion-token.outputs.token}}" -X POST --show-error -i --url https://fusion-s-portal-fprd.azurewebsites.net/api/apps/portal-administration/publish
58 changes: 58 additions & 0 deletions .github/workflows/deploy-apps-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Deploy apps CI

on:
push:
branches: ["main"]
paths:
- "client/apps/portal-administration/**"

permissions:
actions: read
checks: write
contents: read
deployments: write
id-token: write

jobs:
build:
environment: non-prod
name: Deploy
timeout-minutes: 15
runs-on: ubuntu-latest

steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 2

- name: Get fusion token
id: "get-fusion-token"
uses: ./.github/actions/get-fusion-token
with:
client-id: ${{secrets.AZURE_SP_FUSION}}
tenant-id: ${{secrets.AZURE_TENANT_ID}}
resource-id: ${{secrets.AZURE_FUSION_SCOPE}}

- name: Install
run: |
cd client
yarn install
npm i -g @equinor/fusion-framework-cli
cd apps/portal-administration
yarn install
- name: Build
run: |
cd client
yarn build
- name: Deploy
run: |
cd client/apps/portal-administration
yarn bundle
curl -T "app-bundle.zip" -H "Authorization: bearer ${{steps.get-fusion-token.outputs.token}}" -H "Content-Disposition: attachment; filename=app-bundle.zip" -H "Content-Type: application/zip" -X POST --show-error -i --url https://fusion-s-portal-ci.azurewebsites.net/api/apps/portal-administration/versions
- name: Publish
run: |
curl -H "Authorization: bearer ${{steps.get-fusion-token.outputs.token}}" -X POST --show-error -i --url https://fusion-s-portal-ci.azurewebsites.net/api/apps/portal-administration/publish
3 changes: 2 additions & 1 deletion client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ testem.log

# System Files
.DS_Store
Thumbs.db
Thumbs.db
*.zip
13 changes: 13 additions & 0 deletions client/apps/portal-administration/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { mergeAppConfigs, defineAppConfig } from '@equinor/fusion-framework-cli';
export default defineAppConfig((_env, { base }) =>
mergeAppConfigs(base, {
environment: {
endpoints: {
client: {
baseUri: 'https://backend-fusion-project-portal-test.radix.equinor.com',
defaultScopes: ['api://02f3484c-cad0-4d1d-853d-3a9e604b38f3/access_as_user'],
},
},
},
})
);
9 changes: 9 additions & 0 deletions client/apps/portal-administration/app.manifest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineAppManifest, mergeManifests } from '@equinor/fusion-framework-cli';

export default defineAppManifest((env, { base }) => {
return mergeManifests(base, {
name: 'Portal Administration',
shortName: 'PA',
description: 'Portal Administration tool for fusion as a service',
});
});
46 changes: 46 additions & 0 deletions client/apps/portal-administration/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "portal-administration",
"version": "1.0.0",
"description": "",
"private": true,
"type": "module",
"main": "src/index.ts",
"scripts": {
"build": "fusion-framework-cli app build",
"dev": "fusion-framework-cli app dev",
"docker": "cd .. && sh docker-script.sh app-react",
"bundle": "fusion-framework-cli app pack"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@equinor/fusion-framework-cli": "^9.12.14",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
"typescript": "^5.1.3",
"vitest": "^2.0.5"
},
"dependencies": {
"react-router-dom": "^6.26.0",
"@equinor/fusion-react-side-sheet": "^1.3.3",
"@equinor/fusion-framework-module-navigation": "^4.0.6",
"@equinor/fusion-framework-react-app": "^5.2.7",
"@ag-grid-community/core": "^32.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@ag-grid-community/react": "^32.1.0",
"@equinor/eds-core-react": "^0.40.1",
"@equinor/eds-icons": "^0.19.3",
"@equinor/eds-tokens": "^0.9.2",
"@equinor/fusion-react-searchable-dropdown": "^0.5.2",
"@equinor/workspace-ag-grid": "^3.0.2",
"@hookform/resolvers": "^3.9.0",
"@tanstack/react-query": "^5.51.23",
"@tanstack/react-query-devtools": "^5.51.23",
"react-hook-form": "^7.52.2",
"rxjs": "^7.8.1",
"styled-components": "^6.1.1",
"uuidv7": "^1.0.1",
"zod": "^3.23.8"
}
}
29 changes: 29 additions & 0 deletions client/apps/portal-administration/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { RouterProvider } from 'react-router-dom';
import { useRouter } from '@equinor/fusion-framework-react-app/navigation';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import styled from 'styled-components';
import routes from './routes';
import { tokens } from '@equinor/eds-tokens';

const queryClient = new QueryClient();

const Style = {
Root: styled.div`
background-color: ${tokens.colors.ui.background__light.hex};
position: absolute;
height: 100%;
width: 100%;
overflow: hidden;
`,
};

export default function () {
const router = useRouter(routes);
return (
<Style.Root>
<QueryClientProvider client={queryClient}>
<RouterProvider router={router} fallbackElement={<p>Error...</p>} />
</QueryClientProvider>
</Style.Root>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Button, Icon } from '@equinor/eds-core-react';
import { AppManifestResponse, FormattedError, PortalApp } from '../../types';
import { UseMutateAsyncFunction } from '@tanstack/react-query';
import { Result } from '../../query/apps-queries';
import { add_circle_outlined } from '@equinor/eds-icons';

type ActivateSelectedButtonProps = {
selection: PortalApp[];
activateSelected: UseMutateAsyncFunction<
Result[],
FormattedError,
PortalApp[],
{
prevApps: AppManifestResponse[];
newApps: AppManifestResponse[];
}
>;
};

export const ActivateSelectedButton = ({ selection, activateSelected }: ActivateSelectedButtonProps) => {
const isActive = selection.some((a) => a.isActive);

if (isActive) {
return null;
}

return (
<Button
id="activate-selected"
onClick={() => {
activateSelected(selection.filter((a) => !a.isActive));
}}
>
<Icon data={add_circle_outlined} size={16} /> Activate Selected
</Button>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Button, Icon } from '@equinor/eds-core-react';
import { PortalApp } from '../../types';

import { add_circle_filled } from '@equinor/eds-icons';

type ActivateSelectedWithContextButtonProps = {
selection: PortalApp[];
activateSelectedWithContext: VoidFunction;
};

export const ActivateSelectedWithContextButton = ({
selection,
activateSelectedWithContext,
}: ActivateSelectedWithContextButtonProps) => {
const isActive = selection.some((a) => a.isActive);

if (isActive) {
return null;
}

return (
<Button
id="activate-selected"
variant="ghost"
onClick={() => {
activateSelectedWithContext();
}}
>
<Icon data={add_circle_filled} size={16} /> Activate Selected with Context
</Button>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Button, Icon } from '@equinor/eds-core-react';
import { PortalApp } from '../../types';

import { add_circle_outlined, edit } from '@equinor/eds-icons';

type EditSelectedButtonProps = {
selection: PortalApp[];
editSelection: VoidFunction;
};

export const EditSelectedButton = ({ selection, editSelection }: EditSelectedButtonProps) => {
const isActive = selection.some((a) => !a.isActive);

if (isActive) {
return null;
}

return (
<Button
id="activate-selected"
variant="ghost"
onClick={() => {
editSelection();
}}
>
<Icon data={edit} size={16} /> Edit Selected
</Button>
);
};
Loading

0 comments on commit dee5213

Please sign in to comment.