-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reactify Licenses page [BIVS-2912] (#1372)
- Loading branch information
1 parent
ddef4ec
commit 7138839
Showing
25 changed files
with
440 additions
and
257 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
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,31 @@ | ||
import {safeDigest} from "@/services/react-compat"; | ||
|
||
(function() { | ||
"use strict"; | ||
|
||
angular | ||
.module("BitriseWorkflowEditor") | ||
.controller("LicensesController", function($rootScope, $scope, appService) { | ||
var viewModel = this; | ||
viewModel.yml = null; | ||
|
||
viewModel.init = function () { | ||
viewModel.yml = appService.appConfig; | ||
}; | ||
|
||
viewModel.onChange = (yml) => { | ||
appService.appConfig = yml; | ||
safeDigest($rootScope); | ||
} | ||
|
||
$scope.$on( | ||
"$destroy", | ||
$rootScope.$on("MainController::changesDiscarded", function() { | ||
safeDigest($scope); | ||
viewModel.init(); | ||
}) | ||
); | ||
|
||
viewModel.init(); | ||
}); | ||
})(); |
This file was deleted.
Oops, something went wrong.
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,50 @@ | ||
import { delay, http, HttpResponse } from 'msw'; | ||
import { LicensePoolKind } from '../models/LicensePool'; | ||
import LicensePoolsApi, { LicencePoolsResponse } from './LicensePoolsApi'; | ||
|
||
function getWorkspaceLicensePools(isEmpty?: boolean) { | ||
return http.get(LicensePoolsApi.getWorkspaceLicensesPoolsPath(':workspaceSlug'), async (): Promise<Response> => { | ||
await delay(); | ||
|
||
if (isEmpty) { | ||
return HttpResponse.json<LicencePoolsResponse>([]); | ||
} | ||
|
||
return HttpResponse.json<LicencePoolsResponse>([ | ||
{ | ||
id: 'pool-1', | ||
name: 'pool 1', | ||
env_var_name: 'pool_1_env', | ||
description: 'dede', | ||
kind: LicensePoolKind.UNITY, | ||
created_at: '2023-08-29T14:48:17.367908Z', | ||
modified_at: '2023-08-29T14:48:17.367908Z', | ||
licenses: [ | ||
{ | ||
id: 'license-1', | ||
value: 'h', | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 'pool-2', | ||
name: 'pool 2', | ||
env_var_name: 'pool_2_env', | ||
description: 'dede', | ||
kind: LicensePoolKind.UNITY, | ||
created_at: '2023-08-29T14:48:17.367908Z', | ||
modified_at: '2023-08-29T14:48:17.367908Z', | ||
licenses: [ | ||
{ | ||
id: 'license-2', | ||
value: 'h', | ||
}, | ||
], | ||
}, | ||
]); | ||
}); | ||
} | ||
|
||
export default { | ||
getWorkspaceLicensePools, | ||
}; |
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,50 @@ | ||
import { pick } from 'es-toolkit'; | ||
import { LicensePool, LicensePoolKind } from '../models/LicensePool'; | ||
import Client from './client'; | ||
|
||
// DTOs | ||
export type LicencePoolsResponse = Array<{ | ||
created_at: string; | ||
description?: string; | ||
env_var_name: string; | ||
id: string; | ||
kind: LicensePoolKind; | ||
name: string; | ||
modified_at: string; | ||
licenses: Array<{ | ||
id: string; | ||
value: string; | ||
}>; | ||
}>; | ||
|
||
// TRANSFORMATIONS | ||
function toLicensePools(response: LicencePoolsResponse): Array<LicensePool> { | ||
return response.map((pool) => ({ | ||
...pick(pool, ['description', 'id', 'kind', 'name', 'licenses']), | ||
createdAt: pool.created_at, | ||
envVarName: pool.env_var_name, | ||
modifiedAt: pool.modified_at, | ||
})); | ||
} | ||
|
||
export function getWorkspaceLicensesPoolsPath(workspaceSlug: string): string { | ||
return `/organizations/${workspaceSlug}/license_pools`; | ||
} | ||
|
||
export async function getWorkspaceLicensePools({ | ||
workspaceSlug, | ||
signal, | ||
}: { | ||
workspaceSlug: string; | ||
signal?: AbortSignal; | ||
}): Promise<Array<LicensePool>> { | ||
const response = await Client.get<LicencePoolsResponse>(getWorkspaceLicensesPoolsPath(workspaceSlug), { | ||
signal, | ||
}); | ||
return toLicensePools(response); | ||
} | ||
|
||
export default { | ||
getWorkspaceLicensesPoolsPath, | ||
getWorkspaceLicensePools, | ||
}; |
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
Oops, something went wrong.