Skip to content

Commit

Permalink
Merge branch 'main' into 4126-json-assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve-Mcl authored Jul 11, 2024
2 parents 14cef75 + 3dc892a commit 5f30e58
Show file tree
Hide file tree
Showing 18 changed files with 318 additions and 53 deletions.
3 changes: 0 additions & 3 deletions .github/labeler.yml

This file was deleted.

56 changes: 46 additions & 10 deletions .github/workflows/branch-deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,59 @@
name: Create fresh app instance for PR
name: Create pre-staging environment

on:
pull_request:
types:
- opened
- synchronize
- reopened
- closed
- labeled
paths-ignore:
- 'docs/**'

concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: false

jobs:
# This job validates if the user, who triggered the workflow, is a member of the organization
# Note: Any workflow re-runs will use the privileges of github.actor, even if the actor initiating the re-run (github.triggering_actor) has different privileges.
validate-user:
name: Validate trigger author
runs-on: ubuntu-latest
if: |
github.event_name == 'pull_request'
outputs:
is_org_member: ${{ steps.validate.outputs.is_member }}
steps:
- name: Generate a token
id: generate_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.GH_BOT_APP_ID }}
private_key: ${{ secrets.GH_BOT_APP_KEY }}
- name: Validate
id: validate
run: |
if [ "${{ github.actor }}" == 'dependabot[bot]' ]; then
echo "is_member=false" >> $GITHUB_OUTPUT
exit 0
fi
member_status=$(gh api orgs/flowfuse/memberships/${{ github.actor }} -q '.state')
if [ "${member_status}" == "active" ]; then
echo "is_member=true" >> $GITHUB_OUTPUT
else
echo "is_member=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ steps.generate_token.outputs.token }}

build:
name: Build and contenerize
needs: validate-user
if: |
needs.validate-user.outputs.is_org_member == 'true' &&
github.event_name == 'pull_request' &&
github.event.action != 'closed' &&
contains(github.event.pull_request.labels.*.name, 'deploy:pr')
github.event.action != 'closed'
runs-on: ubuntu-latest
env:
IMAGE_NAME: 'forge-k8s'
Expand Down Expand Up @@ -56,11 +91,11 @@ jobs:

deploy:
name: Deploy application
needs: build
needs: [ validate-user, build ]
if: |
needs.validate-user.outputs.is_org_member == 'true' &&
github.event_name == 'pull_request' &&
github.event.action != 'closed' &&
contains(github.event.pull_request.labels.*.name, 'deploy:pr')
github.event.action != 'closed'
runs-on: ubuntu-latest
environment: staging
env:
Expand Down Expand Up @@ -245,11 +280,12 @@ jobs:

destroy:
name: Remove application
needs: [ validate-user ]
runs-on: ubuntu-latest
if: |
if: |
needs.validate-user.outputs.is_org_member == 'true' &&
github.event_name == 'pull_request' &&
github.event.action == 'closed' &&
contains(github.event.pull_request.labels.*.name, 'deploy:pr')
github.event.action == 'closed'
environment: staging
env:
IMAGE_NAME: 'forge-k8s'
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/install-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Install Test
on:
schedule:
- cron: '45 23 * * *'
workflow_dispatch:


jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v4
with:
node-version: 20
- name: install
run: |
npm install @flowfuse/flowfuse
mkdir etc var
cp node_modules/@flowfuse/flowfuse/etc/flowforge.yml etc/
ls -lh node_modules/.bin
- name: start server in background
uses: JarvusInnovations/background-action@v1
with:
run: |
node_modules/.bin/flowfuse
wait-on: |
http://localhost:3000
tail: true
wait-for: 2m
log-output: stderr,stdout
log-output-if: failure
- name: test access
run: |
curl -L -v http://localhost:3000
14 changes: 0 additions & 14 deletions .github/workflows/labeler.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
if: |
( github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/main' ) ||
( github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' )
uses: 'flowfuse/github-actions-workflows/.github/workflows/publish_node_package.yml@v0.10.0'
uses: 'flowfuse/github-actions-workflows/.github/workflows/publish_node_package.yml@v0.21.0'
with:
package_name: flowfuse
build_package: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18
- run: npm ci
- run: npm run build
# - run: npm run test
Expand Down
6 changes: 3 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var/
/var/
docs/
/config/
.github
Expand All @@ -11,5 +11,5 @@ frontend/src/
frontend/public/
forge/containers/localfs_root/
forge/licensing/dev-private-key_enc.pem
test/
ci/
/test/
/ci/
10 changes: 9 additions & 1 deletion forge/routes/api/deviceLive.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ module.exports = async function (app) {
'node-red': nodeRedVersion,
// as of FF v1.14.0, we permit project nodes to work on application owned devices
// the support for this is in @flowfuse/nr-project-nodes > v0.5.0
'@flowfuse/nr-project-nodes': '>0.5.0' // TODO: get this from the "settings" (future)
'@flowfuse/nr-project-nodes': '>0.5.0', // TODO: get this from the "settings" (future)
'@flowfuse/nr-assistant': '>=0.1.0'
},
env: {
FF_SNAPSHOT_ID: '0',
Expand Down Expand Up @@ -191,6 +192,9 @@ module.exports = async function (app) {
if (!settings.modules['@flowfuse/nr-project-nodes'] || SemVer.satisfies(SemVer.coerce(settings.modules['@flowfuse/nr-project-nodes']), '<=0.5.0')) {
settings.modules['@flowfuse/nr-project-nodes'] = '>0.5.0'
}
if (!settings.modules['@flowfuse/nr-assistant']) {
settings.modules['@flowfuse/nr-assistant'] = '>=0.1.0'
}
if (!settings.modules['node-red']) {
// if the snapshot does not have the node-red module specified, ensure it is set to a valid version
settings.modules['node-red'] = getDefaultNodeRedVersion(device)
Expand Down Expand Up @@ -246,6 +250,10 @@ module.exports = async function (app) {
'shared-library': !!(app.config.features.enabled('shared-library') && teamType.getFeatureProperty('shared-library', true)),
projectComms: !!(app.config.features.enabled('projectComms') && teamType.getFeatureProperty('projectComms', true))
}
response.assistant = {
enabled: app.config.assistant?.enabled || false,
requestTimeout: app.config.assistant?.requestTimeout || 60000
}
reply.send(response)
})
}
1 change: 1 addition & 0 deletions frontend/src/pages/instance/Snapshots/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export default {
showRollbackDialog (snapshot) {
Dialog.show({
header: 'Deploy Snapshot',
kind: 'danger',
text: `This will overwrite the current instance.
All changes to the flows, settings and environment variables made since the last snapshot will be lost.
Are you sure you want to deploy to this snapshot?`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</label>
<div class="items-wrapper" :class="{one: singleDevice, two: twoDevices, three: threeDevices}">
<div
v-for="device in Array.from(application.devices.values())"
v-for="device in devices"
:key="device.id"
class="item-wrapper"
@click.stop="openDevice(device)"
Expand Down Expand Up @@ -91,14 +91,14 @@ export default {
emits: ['delete-device'],
computed: {
hasMoreDevices () {
return this.application.deviceCount > this.application.devices.size
return this.application.deviceCount > this.application.devices.length
},
hasNoDevices () {
return this.application.devices.size === 0
return this.application.devices.length === 0
},
remainingDevices () {
if (this.hasNoDevices || this.hasMoreDevices) {
return this.application.deviceCount - this.application.devices.size
return this.application.deviceCount - this.application.devices.length
} else return 0
},
singleDevice () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ export default {
emits: ['delete-instance'],
computed: {
instances () {
return Array.from(this.application.instances.values())
return this.application.instances
},
hasMoreInstances () {
return this.application.instanceCount > this.application.instances.size
return this.application.instanceCount > this.application.instances.length
},
hasNoInstances () {
return this.application.instances.size === 0
return this.application.instances.length === 0
},
remainingInstances () {
if (this.hasNoInstances || this.hasMoreInstances) {
return this.application.instanceCount - this.application.instances.size
return this.application.instanceCount - this.application.instances.length
} else return 0
},
singleInstance () {
Expand Down
46 changes: 41 additions & 5 deletions frontend/src/pages/team/Applications/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,26 @@
<ff-loading v-if="loading" message="Loading Applications..." />

<template v-else-if="!loading && applications.size > 0">
<ul class="ff-applications-list" data-el="applications-list">
<li v-for="application in applicationsList" :key="application.id">
<ff-text-input
v-model="filterTerm"
class="ff-data-table--search"
data-form="search"
placeholder="Search Applications..."
>
<template #icon><SearchIcon /></template>
</ff-text-input>
<ul v-if="filteredApplications.length > 0" class="ff-applications-list" data-el="applications-list">
<li v-for="application in filteredApplications" :key="application.id">
<ApplicationListItem
:application="application"
@instance-deleted="fetchData(false)"
@device-deleted="fetchData(false)"
/>
</li>
</ul>
<p v-else class="no-results">
No Data Found. Try Another Search.
</p>
</template>

<EmptyState v-else>
Expand Down Expand Up @@ -86,7 +97,7 @@
</template>

<script>
import { PlusSmIcon } from '@heroicons/vue/outline'
import { PlusSmIcon, SearchIcon } from '@heroicons/vue/outline'
import teamApi from '../../../api/team.js'
import EmptyState from '../../../components/EmptyState.vue'
Expand All @@ -100,6 +111,7 @@ const ASSOCIATIONS_LIMIT = 3
export default {
name: 'TeamApplications',
components: {
SearchIcon,
ApplicationListItem,
EmptyState,
PlusSmIcon
Expand All @@ -111,12 +123,31 @@ export default {
applications: new Map(),
columns: [
{ label: 'Name', class: ['flex-grow'], key: 'name', sortable: true }
]
],
filterTerm: ''
}
},
computed: {
applicationsList () {
return Array.from(this.applications.values())
return Array.from(this.applications.values()).map(app => {
return {
...app,
instances: Array.from(app.instances.values()),
devices: Array.from(app.devices.values())
}
})
},
filteredApplications () {
if (this.filterTerm) {
return this.applicationsList.filter(app => {
const includes = []
const appNameMatch = app.name.toLowerCase().includes(this.filterTerm.toLowerCase())
includes.push(appNameMatch)
return includes.includes(true)
})
} return this.applicationsList
}
},
watch: {
Expand Down Expand Up @@ -222,4 +253,9 @@ export default {

<style lang="scss">
@import "../../../stylesheets/components/applications-list";
.no-results {
text-align: center;
color: $ff-grey-400;
}
</style>
2 changes: 1 addition & 1 deletion frontend/src/transformers/snapshots.transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function applySystemUserDetails (snapshots, owner) {
snapshot.user = {
name: owner?.name || (snapshot.project || snapshot.device || {}).name || 'Unknown',
username: 'Auto Snapshot',
avatar: '../../avatar/camera.svg'
avatar: '/avatar/camera.svg'
}
}
return snapshot
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5f30e58

Please sign in to comment.