Skip to content

Commit

Permalink
Merge branch 'main' into feat/add_api_usage_nudge
Browse files Browse the repository at this point in the history
  • Loading branch information
zachaysan committed Feb 15, 2024
2 parents 1dce1f6 + a04aafb commit 13126e4
Show file tree
Hide file tree
Showing 67 changed files with 2,304 additions and 737 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/platform-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,54 @@ jobs:
tests: segment-part-3 signup flag invite project
concurrency: 2

run-e2e-tests-4:
runs-on: ubuntu-latest
name: E2E Local - Versioning

services:
postgres:
image: postgres:11.12-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: flagsmith
ports: ['5432:5432']
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- name: Cloning repo
uses: actions/checkout@v3

- name: Run E2E tests against local
uses: ./.github/actions/local-e2e-tests
with:
slack_token: ${{ secrets.SLACK_TOKEN }}
tests: versioning
concurrency: 1

run-e2e-versioning-tests-docker-unified:
runs-on: ubuntu-latest
name: E2E Unified - Versioning

steps:
- name: Cloning repo
uses: actions/checkout@v3

- name: Build unified docker container
uses: ./.github/actions/unified-e2e-tests
with:
github_actor: ${{github.actor}}
github_token: ${{secrets.GITHUB_TOKEN}}
e2e_test_token_staging: ${{ secrets.E2E_TEST_TOKEN }}

- name: Run tests on unified docker image
working-directory: frontend
env:
SLACK_TOKEN: ${{ inputs.slack_token }}
GITHUB_ACTION_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
docker compose -f docker-compose-e2e-tests.yml run frontend npx cross-env E2E_CONCURRENCY=1 npm run test -- versioning
run-e2e-segments-1-tests-docker-unified:
runs-on: ubuntu-latest
name: E2E Unified - Segments-1, Environment
Expand Down
371 changes: 193 additions & 178 deletions docs/docs/deployment/hosting/kubernetes.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion frontend/common/code-help/init/init-curl.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = (envId) => `
curl 'https://edge.api.flagsmith.com/api/v1/flags/'
curl 'https://edge.api.flagsmith.com/api/v1/flags/'\\
-H 'x-environment-key: ${envId}'
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = (envId) => `
npm i flagsmith-cli -g
export FLAGSMITH_ENVIRONMENT=${envId}
flagsmith get
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = (envId) => `
curl 'https://edge.api.flagsmith.com/api/v1/flags/'\\
-H 'x-environment-key: ${envId}' > flagsmith.json
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import _data from 'common/data/base/_data'
module.exports = (serversideEnvironmentKey) => `
npm i flagsmith-cli -g
export FLAGSMITH_ENVIRONMENT=${serversideEnvironmentKey}
flagsmith get -e document
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = (serversideEnvironmentKey) => `
curl 'https://edge.api.flagsmith.com/api/v1/environment-document/'\\
-H 'x-environment-key: ${serversideEnvironmentKey}' > flagsmith.json
`
20 changes: 20 additions & 0 deletions frontend/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,26 @@ export default {
'iOS': require('./code-help/install/install-ios')(keywords),
},

'OFFLINE_LOCAL': (envId: string) => ({
'cli': require('common/code-help/offline_server/offline-server-cli')(
envId,
),
'curl': require('common/code-help/offline_server/offline-server-curl')(
envId,
),
}),

'OFFLINE_REMOTE': (envId: string) => ({
'cli': require('common/code-help/offline_client/offline-client-cli')(
envId,
keywords,
),
'curl': require('common/code-help/offline_client/offline-client-curl')(
envId,
keywords,
),
}),

'USER_TRAITS': (envId: string, userId?: string) => ({
'.NET': require('./code-help/traits/traits-dotnet')(
envId,
Expand Down
1 change: 0 additions & 1 deletion frontend/common/dispatcher/action-constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const Actions = Object.assign({}, require('./base/_action-constants'), {
'SEARCH_FLAGS': 'SEARCH_FLAGS',
'SELECT_ENVIRONMENT': 'SELECT_ENVIRONMENT',
'SELECT_ORGANISATION': 'SELECT_ORGANISATION',
'TOGGLE_FLAG': 'TOGGLE_FLAG',
'TOGGLE_USER_FLAG': 'TOGGLE_USER_FLAG',
'TWO_FACTOR_LOGIN': 'TWO_FACTOR_LOGIN',
'UPDATE_CHANGE_REQUEST': 'UPDATE_CHANGE_REQUEST',
Expand Down
19 changes: 12 additions & 7 deletions frontend/common/providers/FeatureListProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,18 @@ const FeatureListProvider = class extends React.Component {
})
}

toggleFlag = (i, environments, comment, environmentFlags, projectFlags) => {
AppActions.toggleFlag(
i,
environments,
comment,
environmentFlags,
projectFlags,
toggleFlag = (projectId, environmentId, projectFlag, environmentFlag) => {
AppActions.editEnvironmentFlag(
projectId,
environmentId,
{
...projectFlag,
default_enabled: !environmentFlag.enabled,
},
projectFlag,
environmentFlag,
null,
'VALUE',
)
}

Expand Down
2 changes: 2 additions & 0 deletions frontend/common/services/useAuditLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Res } from 'common/types/responses'
import { Req } from 'common/types/requests'
import { service } from 'common/service'
import Utils from 'common/utils/utils'
import transformCorePaging from 'common/transformCorePaging'

export const auditLogService = service
.enhanceEndpoints({ addTagTypes: ['AuditLog'] })
Expand All @@ -24,6 +25,7 @@ export const auditLogService = service
url: `audit/?${Utils.toParam(params)}`,
}
},
transformResponse: (res, _, req) => transformCorePaging(req, res),
}),
// END OF ENDPOINTS
}),
Expand Down
49 changes: 49 additions & 0 deletions frontend/common/services/useEnableFeatureVersioning.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Res } from 'common/types/responses'
import { Req } from 'common/types/requests'
import { service } from 'common/service'

export const featureVersioningService = service
.enhanceEndpoints({ addTagTypes: ['FeatureVersioning'] })
.injectEndpoints({
endpoints: (builder) => ({
enableFeatureVersioning: builder.mutation<
Res['enableFeatureVersioning'],
Req['enableFeatureVersioning']
>({
invalidatesTags: [{ id: 'LIST', type: 'FeatureVersioning' }],
query: (query: Req['enableFeatureVersioning']) => ({
body: query,
method: 'POST',
url: `environments/${query.environmentId}/enable-v2-versioning/`,
}),
}),
// END OF ENDPOINTS
}),
})

export async function enableFeatureVersioning(
store: any,
data: Req['enableFeatureVersioning'],
options?: Parameters<
typeof featureVersioningService.endpoints.enableFeatureVersioning.initiate
>[1],
) {
return store.dispatch(
featureVersioningService.endpoints.enableFeatureVersioning.initiate(
data,
options,
),
)
}
// END OF FUNCTION_EXPORTS

export const {
useEnableFeatureVersioningMutation,
// END OF EXPORTS
} = featureVersioningService

/* Usage examples:
const { data, isLoading } = useGetFeatureVersioningQuery({ id: 2 }, {}) //get hook
const [enableFeatureVersioning, { isLoading, data, isSuccess }] = useEnableFeatureVersioningMutation() //create hook
featureVersioningService.endpoints.getFeatureVersioning.select({id: 2})(store.getState()) //access data from any function
*/
49 changes: 49 additions & 0 deletions frontend/common/services/useFeatureSegment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Res } from 'common/types/responses'
import { Req } from 'common/types/requests'
import { service } from 'common/service'

export const featureSegmentService = service
.enhanceEndpoints({ addTagTypes: ['FeatureSegment'] })
.injectEndpoints({
endpoints: (builder) => ({
deleteFeatureSegment: builder.mutation<
Res['featureSegment'],
Req['deleteFeatureSegment']
>({
invalidatesTags: [{ id: 'LIST', type: 'FeatureSegment' }],
query: (query: Req['deleteFeatureSegment']) => ({
body: query,
method: 'DELETE',
url: `features/feature-segments/${query.id}/`,
}),
}),
// END OF ENDPOINTS
}),
})

export async function deleteFeatureSegment(
store: any,
data: Req['deleteFeatureSegment'],
options?: Parameters<
typeof featureSegmentService.endpoints.deleteFeatureSegment.initiate
>[1],
) {
return store.dispatch(
featureSegmentService.endpoints.deleteFeatureSegment.initiate(
data,
options,
),
)
}
// END OF FUNCTION_EXPORTS

export const {
useDeleteFeatureSegmentMutation,
// END OF EXPORTS
} = featureSegmentService

/* Usage examples:
const { data, isLoading } = useGetFeatureSegmentQuery({ id: 2 }, {}) //get hook
const [createFeatureSegment, { isLoading, data, isSuccess }] = useCreateFeatureSegmentMutation() //create hook
featureSegmentService.endpoints.getFeatureSegment.select({id: 2})(store.getState()) //access data from any function
*/
Loading

0 comments on commit 13126e4

Please sign in to comment.