Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Enable loading of samples and Permissions descriptions files from Github #829

Merged
merged 14 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/services/actions/devxApi-action-creators.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SET_DEVX_API_URL_SUCCESS } from '../redux-constants';

export function setDevxApiUrl(response: string): any {
export function setDevxApiUrl(response: object): any {
thewahome marked this conversation as resolved.
Show resolved Hide resolved
return {
type: SET_DEVX_API_URL_SUCCESS,
response,
Expand Down
7 changes: 6 additions & 1 deletion src/app/services/actions/permissions-action-creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export function fetchScopes(query?: IQuery): Function {
return async (dispatch: Function, getState: Function) => {
try {
const { devxApi } = getState();
let permissionsUrl = `${devxApi}/permissions`;
let permissionsUrl = `${devxApi.baseUrl}/permissions`;

let hasUrl = false; // whether permissions are for a specific url

if (query) {
Expand All @@ -49,6 +50,10 @@ export function fetchScopes(query?: IQuery): Function {
hasUrl = true;
}

if (devxApi.parameters) {
permissionsUrl = `${permissionsUrl}${query ? '&' : '?'}${devxApi.parameters}`;
}

const headers = {
'Content-Type': 'application/json',
'Accept-Language': geLocale
Expand Down
6 changes: 5 additions & 1 deletion src/app/services/actions/samples-action-creators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ export function fetchSamplesPending(): any {
export function fetchSamples(): Function {
return async (dispatch: Function, getState: Function) => {
const { devxApi } = getState();
const samplesUrl = `${devxApi}/samples`;
let samplesUrl = `${devxApi.baseUrl}/samples`;

if (devxApi.parameters) {
samplesUrl = `${samplesUrl}?${devxApi.parameters}`;
}
thewahome marked this conversation as resolved.
Show resolved Hide resolved

const headers = {
'Content-Type': 'application/json',
Expand Down
6 changes: 5 additions & 1 deletion src/app/services/reducers/devxApi-reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { IAction } from '../../../types/action';
import { DEVX_API_URL } from '../graph-constants';
import { SET_DEVX_API_URL_SUCCESS } from '../redux-constants';

export function devxApi(state: string = DEVX_API_URL, action: IAction): any {
const initialState = {
baseUrl: DEVX_API_URL,
parameters: ''
};
thewahome marked this conversation as resolved.
Show resolved Hide resolved
export function devxApi(state = initialState, action: IAction): any {
thewahome marked this conversation as resolved.
Show resolved Hide resolved
switch (action.type) {

case SET_DEVX_API_URL_SUCCESS:
Expand Down
13 changes: 12 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,18 @@ if (theme) {
const devxApiUrl = new URLSearchParams(location.search).get('devx-api');

if (devxApiUrl) {
appState.dispatch(setDevxApiUrl(devxApiUrl));
const org = new URLSearchParams(location.search).get('org');
const branchName = new URLSearchParams(location.search).get('branchName');

const devxApi = {
baseUrl: devxApiUrl,
parameters: ''
};
thewahome marked this conversation as resolved.
Show resolved Hide resolved

if (org && branchName) {
devxApi.parameters = `org=${org}&branchName=${branchName}`;
}
appState.dispatch(setDevxApiUrl(devxApi));
}

readHistoryData().then((data: any) => {
Expand Down