mirror of
https://github.com/HangarMC/Hangar.git
synced 2025-03-13 15:39:18 +08:00
load licences from server
This commit is contained in:
parent
7548b0ca52
commit
a096444336
@ -299,6 +299,7 @@ import { MemberList } from '~/components/projects';
|
||||
@ProjectPermission(NamedPermission.EDIT_SUBJECT_SETTINGS)
|
||||
export default class ProjectManagePage extends HangarProjectMixin {
|
||||
roles!: Role[];
|
||||
licences!: String[];
|
||||
apiKey = '';
|
||||
newName = '';
|
||||
nameErrors: TranslateResult[] = [];
|
||||
@ -357,11 +358,6 @@ export default class ProjectManagePage extends HangarProjectMixin {
|
||||
return this.form.settings.license.type === '(custom)';
|
||||
}
|
||||
|
||||
// TODO do we want to get those from the server? Jake: I think so, it'd be nice to admins to be able to configure default licenses, but not needed for MVP
|
||||
get licences() {
|
||||
return ['MIT', 'Apache 2.0', 'GPL', 'LGPL', '(custom)'];
|
||||
}
|
||||
|
||||
onFileChange() {
|
||||
if (this.projectIcon) {
|
||||
const reader = new FileReader();
|
||||
@ -475,8 +471,11 @@ export default class ProjectManagePage extends HangarProjectMixin {
|
||||
generateApiKey() {}
|
||||
|
||||
async asyncData({ $api, $util }: Context) {
|
||||
const roles = await $api.requestInternal('data/projectRoles', false).catch($util.handlePageRequestError);
|
||||
return { roles };
|
||||
const data = await Promise.all([$api.requestInternal('data/projectRoles', false), $api.requestInternal('data/licences', false)]).catch(
|
||||
$util.handlePageRequestError
|
||||
);
|
||||
if (typeof data === 'undefined') return;
|
||||
return { roles: data[0], licences: data[1] };
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.papermc.hangar.config.hangar.HangarConfig;
|
||||
import io.papermc.hangar.model.Announcement;
|
||||
import io.papermc.hangar.model.api.project.ProjectLicense;
|
||||
import io.papermc.hangar.model.common.Color;
|
||||
import io.papermc.hangar.model.common.NamedPermission;
|
||||
import io.papermc.hangar.model.common.Platform;
|
||||
@ -136,6 +137,11 @@ public class BackendDataController {
|
||||
return ResponseEntity.ok(OrganizationRole.getAssignableRoles());
|
||||
}
|
||||
|
||||
@GetMapping("/licences")
|
||||
public ResponseEntity<List<String>> getLicences() {
|
||||
return ResponseEntity.ok(config.getLicences());
|
||||
}
|
||||
|
||||
@GetMapping("/validations")
|
||||
public ResponseEntity<ObjectNode> getValidations() {
|
||||
ObjectNode validations = mapper.createObjectNode();
|
||||
|
Loading…
x
Reference in New Issue
Block a user