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

AIMAAS #197: refactor users/groups state management #198

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
34 changes: 12 additions & 22 deletions frontend/src/components/Entity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
</div>
</template>
</BaseLayout>
<Tabbing :bind-args="currentProperties" :tabs="tabs" ref="entitytabbing"
<Tabbing :bind-args="bindArgs" :tabs="tabs" ref="entitytabbing"
:tabEvents="{update: onUpdate}"/>
</template>

<script>
import {shallowRef} from "vue";
import { markRaw } from "vue";
import BaseLayout from "@/components/layout/BaseLayout";
import EntityForm from "@/components/inputs/EntityForm";
import Changes from "@/components/change_review/Changes";
Expand All @@ -38,19 +38,19 @@ export default {
tabs: [
{
name: 'Show/Edit',
component: shallowRef(EntityForm),
component: markRaw(EntityForm),
crazyscientist marked this conversation as resolved.
Show resolved Hide resolved
icon: "mode_edit",
tooltip: "Edit/show entity details"
},
{
name: "Permissions",
component: PermissionList,
component: markRaw(PermissionList),
icon: "security",
tooltip: "Manage permissions on the entity"
},
{
name: "History",
component: shallowRef(Changes),
component: markRaw(Changes),
icon: "history",
tooltip: 'Change history of entity'
}
Expand All @@ -61,23 +61,13 @@ export default {
title() {
return this.entity?.name || this.$route.params.entitySlug || '-';
},
currentProperties() {
const currIndex = this.$refs.entitytabbing?.currentTab || 0;
if (this.tabs[currIndex].component.name === "PermissionList") {
return {objectType: "Entity", objectId: this.entity?.id};
}
let props = {schema: this.activeSchema};

if (this.tabs[currIndex].component.name === "Changes") {
props.entitySlug = this.$route.params.entitySlug;
}

if (this.tabs[currIndex].component.name === "EntityForm") {
props.entity = this.entity;
}

return props;
}
bindArgs() {
return [
{ schema: this.activeSchema, entity: this.entity },
{ objectType: "Entity", objectId: this.entity?.id },
{ schema: this.activeSchema, entitySlug: this.$route.params.entitySlug },
]
},
},
methods: {
async updateEntity() {
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/components/EntityList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
</template>

<script>
import {computed} from "vue";

import ConfirmButton from "@/components/inputs/ConfirmButton";
import Pagination from "./layout/Pagination.vue";
import EntityListTable from "@/components/EntityListTable";
Expand All @@ -79,13 +77,13 @@ export default {
this.getEntities({resetPage: false});
},
computed: {
pages: computed(() => {
pages() {
try {
return this.$refs.paginator.pageCount;
} catch (e) {
return 0;
}
}),
},
numSelected() {
return this.selected.length;
},
Expand Down
34 changes: 15 additions & 19 deletions frontend/src/components/Schema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
</template>
</BaseLayout>

<Tabbing :bind-args="currentProperties" :tabs="tabs" ref="schematabbing"/>
<Tabbing :bind-args="bindArgs" :tabs="tabs" ref="schematabbing"/>

</template>

<script>
import {shallowRef} from "vue";
import { markRaw } from "vue";
import BaseLayout from "@/components/layout/BaseLayout";
import EntityList from "@/components/EntityList";
import EntityForm from "@/components/inputs/EntityForm";
Expand All @@ -33,31 +33,31 @@ export default {
tabs: [
{
name: "Entities",
component: shallowRef(EntityList),
component: markRaw(EntityList),
icon: "table_view",
tooltip: "Show entities"
},
{
name: "Edit / Show",
component: shallowRef(SchemaEdit),
component: markRaw(SchemaEdit),
icon: "mode_edit",
tooltip: "Edit/Show schema structure"
},
{
name: "Add Entity",
component: shallowRef(EntityForm),
component: markRaw(EntityForm),
icon: 'add_circle',
tooltip: 'Add new entity'
},
{
name: "Permissions",
component: PermissionList,
component: markRaw(PermissionList),
icon: "security",
tooltip: "Manage permissions on the schema"
},
{
name: "History",
component: shallowRef(Changes),
component: markRaw(Changes),
icon: 'history',
tooltip: 'Change history of schema'
}
Expand All @@ -66,18 +66,14 @@ export default {
},
inject: ['activeSchema'],
computed: {
currentProperties() {
const currIndex = this.$refs.schematabbing?.currentTab || 0;
if (this.tabs[currIndex].component.name === "PermissionList") {
return {objectType: "Schema", objectId: this.activeSchema.id};
}

const props = {schema: this.activeSchema};

if (this.tabs[currIndex].component.name === "EntityList") {
props.advancedControls = true;
}
return props;
bindArgs() {
return [
{ schema: this.activeSchema, advancedControls: true },
{ schema: this.activeSchema },
{ schema: this.activeSchema },
{ objectType: "Schema", objectId: this.activeSchema?.id },
{ schema: this.activeSchema },
]
},
title() {
try {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/SearchPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
</template>

<script>
import {shallowRef} from "vue";
import { markRaw } from "vue";
import {TYPE_INPUT_MAP} from "@/utils";
import IntegerInput from "@/components/inputs/IntegerInput.vue";
import FloatInput from "@/components/inputs/FloatInput.vue";
Expand Down Expand Up @@ -148,7 +148,7 @@ export default {
operator: null,
value: null,
operatorOptions: [],
component: shallowRef(TextInput)
component: markRaw(TextInput)
});
},
clearFilters() {
Expand Down
65 changes: 15 additions & 50 deletions frontend/src/components/auth/AuthManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,63 +4,28 @@
<li class="breadcrumb-item active">User Management</li>
</template>
</BaseLayout>

<Tabbing :bind-args="{}" :tabs="tabs" ref="admtabbing"/>
<Tabbing :tabs="tabs" ref="admtabbing" />
</template>

<script>
import {computed, shallowRef} from "vue";
<script setup>
import { markRaw } from "vue";
import BaseLayout from "@/components/layout/BaseLayout";
import GroupManager from "@/components/auth/GroupManager";
import UserManager from "@/components/auth/UserManager";
import Tabbing from "@/components/layout/Tabbing";
import {loadGroupData, loadUserData} from "@/composables/auth";

export default {
name: "AuthManager",
components: {Tabbing, BaseLayout},
data() {
return {
groups: {},
users: {},
tree: {},
activeGroup: null,
tabs: [
{
name: "Groups",
component: shallowRef(GroupManager),
icon: "groups",
tooltip: "Manage groups"
},
{
name: "Users",
component: shallowRef(UserManager),
icon: "person",
tooltip: "Manage users"
}
]
};
},
provide() {
return {
groups: computed(() => this.groups),
users: computed(() => this.users),
tree: computed(() => this.tree)
}
const tabs = [
{
name: "Groups",
component: markRaw(GroupManager),
icon: "groups",
tooltip: "Manage groups",
},
async activated() {
await this.loadData();
{
name: "Users",
component: markRaw(UserManager),
icon: "person",
tooltip: "Manage users",
},
methods: {
async loadData() {
[this.groups, this.tree] = await loadGroupData(this.$api);
this.users = await loadUserData(this.$api);
},

}
}
];
</script>

<style scoped>

</style>
79 changes: 0 additions & 79 deletions frontend/src/components/auth/GroupEdit.vue

This file was deleted.

Loading
Loading