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

Add devTools flag to config and use it to gate EntityBranchData #1100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion src/components/entity/feed-entry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ const deletedSubmission = (key) => t(key, { id: props.submission.instanceId });

// entity.create, entity.update.version
const versionAnchor = (v) => `#v${v}`;
const config = inject('config');
const showBranchData = () => {
emit('branch-data', props.entityVersion.version);
if (config.devTools) emit('branch-data', props.entityVersion.version);
};
</script>

Expand Down
12 changes: 7 additions & 5 deletions src/components/entity/show.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ except according to the terms contained in the LICENSE file.
:label="entity.dataExists ? entity.currentVersion.label : ''"
:awaiting-response="awaitingResponse" @hide="deleteModal.hide()"
@delete="requestDelete"/>
<entity-branch-data v-bind="branchData" @hide="branchData.hide()"/>
<entity-branch-data v-if="config.devTools" v-bind="branchData"
@hide="branchData.hide()"/>
</div>
</template>

<script setup>
import { computed, inject, provide } from 'vue';
import { computed, defineAsyncComponent, inject, provide } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';

import Breadcrumbs from '../breadcrumbs.vue';
import EntityActivity from './activity.vue';
import EntityBasicDetails from './basic-details.vue';
import EntityBranchData from './branch-data.vue';
import EntityData from './data.vue';
import EntityDelete from './delete.vue';
import EntityUpdate from './update.vue';
Expand All @@ -62,6 +62,7 @@ import useEntityVersions from '../../request-data/entity-versions';
import useRequest from '../../composables/request';
import useRoutes from '../../composables/routes';
import { apiPaths } from '../../util/request';
import { loadAsync } from '../../util/load-async';
import { modalData, setDocumentTitle } from '../../util/reactivity';
import { noop } from '../../util/util';
import { useRequestData } from '../../request-data';
Expand Down Expand Up @@ -121,7 +122,7 @@ fetchActivityData();
setDocumentTitle(() => [entity.dataExists ? entity.currentVersion.label : null]);

const updateModal = modalData();
const { i18n, alert } = inject('container');
const { i18n, alert, config } = inject('container');
const afterUpdate = (updatedEntity) => {
fetchActivityData();
updateModal.hide();
Expand Down Expand Up @@ -154,7 +155,8 @@ const requestDelete = () => {
.catch(noop);
};

const branchData = modalData();
const EntityBranchData = defineAsyncComponent(loadAsync('EntityBranchData'));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The component will only be loaded if it's rendered (if the v-if is true). So it won't ever have to be loaded for users.

const branchData = modalData('EntityBranchData');

const breadcrumbLinks = computed(() => [
{ text: project.nameWithArchived, path: projectPath() },
Expand Down
4 changes: 3 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,7 @@ export default {
// VUE_APP_OIDC_ENABLED is not set in production. It can be set during local
// development to facilitate work on SSO.
oidcEnabled: process.env.VUE_APP_OIDC_ENABLED === 'true',
showsFeedbackButton: false
showsFeedbackButton: false,
// `true` to show additional buttons to facilitate development and testing.
devTools: false
};
4 changes: 4 additions & 0 deletions src/util/load-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ const loaders = new Map()
/* webpackChunkName: "component-download" */
'../components/download.vue'
)))
.set('EntityBranchData', loader(() => import(
/* webpackChunkName: "component-entity-branch-data" */
'../components/entity/branch-data.vue'
)))
.set('EntityShow', loader(() => import(
/* webpackChunkName: "component-entity-show" */
'../components/entity/show.vue'
Expand Down