Skip to content

Commit

Permalink
remove feature config where applicable (#5620)
Browse files Browse the repository at this point in the history
Co-authored-by: Cole Blanchard <cblanchard@Coles-MacBook-Pro.local>
  • Loading branch information
blanchco and Cole Blanchard authored Nov 25, 2024
1 parent e1e5b90 commit b1aa592
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 79 deletions.
26 changes: 2 additions & 24 deletions packages/client/hmi-client/src/components/asset/tera-asset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
<div v-if="overline" class="row">
<span class="overline">{{ overline }}</span>
<slot name="edit-buttons" />
<Button
v-if="featureConfig.isPreview"
class="close"
icon="pi pi-times"
rounded
text
@click="emit('close-preview')"
/>
</div>
<!--For naming asset such as model or code file-->
<div class="row">
Expand All @@ -27,14 +19,6 @@
{{ name }}
</h4>
<slot v-if="!overline" name="edit-buttons" />
<Button
v-if="!overline && featureConfig.isPreview"
class="close"
icon="pi pi-times"
rounded
text
@click="emit('close-preview')"
/>
</div>
<!--put model contributors here too-->
<span v-if="authors" class="authors">
Expand Down Expand Up @@ -77,10 +61,8 @@
</template>

<script setup lang="ts">
import { ref, computed, watch, PropType, useSlots, nextTick } from 'vue';
import { ref, computed, watch, useSlots, nextTick } from 'vue';
import { useRoute } from 'vue-router';
import Button from 'primevue/button';
import type { FeatureConfig } from '@/types/common';
import { ProjectPages } from '@/types/Project';
import { AssetType } from '@/types/Types';
import TabView from 'primevue/tabview';
Expand Down Expand Up @@ -112,10 +94,6 @@ const props = defineProps({
type: String,
default: null
},
featureConfig: {
type: Object as PropType<FeatureConfig>,
default: { isPreview: false } as FeatureConfig
},
showHeader: {
type: Boolean,
default: true
Expand All @@ -132,7 +110,7 @@ const props = defineProps({
}
});
const emit = defineEmits(['close-preview', 'tab-change']);
const emit = defineEmits(['tab-change']);
const slots = useSlots();
const pageType = useRoute().params.pageType as ProjectPages | AssetType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
<section class="entries">
<span class="name">
<h6>{{ column.symbol }}</h6>
<template v-if="featureConfig.isPreview">{{ column.name }}</template>
<tera-input-text
v-else
placeholder="Add a name"
:model-value="column.name ?? ''"
@update:model-value="$emit('update-column', { key: 'name', value: $event })"
/>
</span>
<span class="unit">
<template v-if="featureConfig.isPreview"><label>Unit</label>{{ column.unit }}</template>
<tera-input-text
v-else
label="Unit"
placeholder="Add a unit"
:characters-to-reject="[' ']"
Expand All @@ -24,20 +20,16 @@
</span>
<span class="data-type">
<label>Data type</label>
<template v-if="featureConfig.isPreview">{{ column.dataType }}</template>
<Dropdown
v-else
placeholder="Select a data type"
:model-value="column.dataType ?? ''"
@update:model-value="$emit('update-column', { key: 'dataType', value: $event })"
:options="Object.values(ColumnType)"
/>
</span>
<span v-if="showConcept" class="concept">
<span class="concept">
<label>Concept</label>
<template v-if="featureConfig.isPreview">{{ query }}</template>
<AutoComplete
v-else
size="small"
placeholder="Search concepts"
v-model="query"
Expand All @@ -52,9 +44,7 @@
/>
</span>
<span class="description">
<template v-if="featureConfig.isPreview">{{ column.description }}</template>
<tera-input-text
v-else
placeholder="Add a description"
:model-value="column.description ?? ''"
@update:model-value="$emit('update-column', { key: 'description', value: $event })"
Expand All @@ -70,14 +60,13 @@

<script setup lang="ts">
/* Copied the structure of tera-model-parts.vue */
import { ref, computed, watch } from 'vue';
import { ref, watch } from 'vue';
import TeraInputText from '@/components/widgets/tera-input-text.vue';
import TeraBoxplot from '@/components/widgets/tera-boxplot.vue';
import AutoComplete from 'primevue/autocomplete';
import Dropdown from 'primevue/dropdown';
import { type DKG, ColumnType, type Grounding } from '@/types/Types';
import { searchCuriesEntities } from '@/services/concept';
import type { FeatureConfig } from '@/types/common';
type ColumnInfo = {
symbol: string;
Expand All @@ -92,17 +81,13 @@ type ColumnInfo = {
const props = defineProps<{
column: ColumnInfo;
featureConfig: FeatureConfig;
}>();
const emit = defineEmits(['update-column']);
const query = ref('');
const results = ref<DKG[]>([]);
// If we are in preview mode and there is no content, show nothing
const showConcept = computed(() => !(props.featureConfig.isPreview && !query.value));
// Used if an option isn't selected from the Autocomplete suggestions but is typed in regularly
function applyValidConcept() {
// Allows to empty the concept
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<template>
<tera-asset
show-table-of-contents
:feature-config="featureConfig"
:id="assetId"
:is-loading="isDatasetLoading"
:is-naming-asset="isRenaming"
:name="dataset?.name"
:overflow-hidden="selectedTabIndex === 1"
:selected-tab-index="selectedTabIndex"
@close-preview="emit('close-preview')"
@tab-change="(e) => (selectedTabIndex = e.index)"
>
<template #name-input>
Expand All @@ -22,7 +20,7 @@
/>
<Button v-if="isRenaming" icon="pi pi-check" rounded text @click="updateDatasetName" />
</template>
<template #edit-buttons v-if="!featureConfig.isPreview">
<template #edit-buttons>
<Button
icon="pi pi-ellipsis-v"
class="p-button-icon-only p-button-text p-button-rounded"
Expand Down Expand Up @@ -61,7 +59,6 @@
:key="index"
class="column-info"
:column="column"
:feature-config="{ isPreview: false }"
@update-column="updateColumn(index, $event.key, $event.value)"
/>
</AccordionTab>
Expand All @@ -86,7 +83,6 @@ import {
} from '@/services/dataset';
import { AssetType, type CsvAsset, type Dataset, PresignedURL } from '@/types/Types';
import TeraAsset from '@/components/asset/tera-asset.vue';
import type { FeatureConfig } from '@/types/common';
import { DatasetSource } from '@/types/Dataset';
import { useProjects } from '@/composables/project';
import TeraInputText from '@/components/widgets/tera-input-text.vue';
Expand All @@ -106,18 +102,12 @@ const props = defineProps({
type: String,
required: true
},
featureConfig: {
type: Object as PropType<FeatureConfig>,
default: { isPreview: false } as FeatureConfig
},
source: {
type: String as PropType<DatasetSource>,
default: DatasetSource.TERARIUM
}
});
const emit = defineEmits(['close-preview']);
const currentActiveIndexes = ref([1, 2, 3, 4]);
const dataset = ref<Dataset | null>(null);
const transientDataset = ref<Dataset | null>(null);
Expand Down Expand Up @@ -151,7 +141,6 @@ const optionsMenuItems = ref<any[]>([
if (presignedUrl) {
window.open(presignedUrl.url, '_blank');
}
emit('close-preview');
}
}
]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<template>
<div :class="{ isPreview: featureConfig?.isPreview }" ref="outputAreaRef" />
<div class="output-area" ref="outputAreaRef" />
</template>

<script setup lang="ts">
import { JupyterMessage, renderMime } from '@/services/jupyter';
import { computed, onMounted, ref, watch } from 'vue';
import { OutputArea, OutputAreaModel } from '@jupyterlab/outputarea';
import { FeatureConfig } from '@/types/common';
const props = defineProps<{
jupyterMessage: JupyterMessage;
featureConfig?: FeatureConfig;
}>();
const outputAreaRef = ref<HTMLDivElement | null>(null);
Expand Down Expand Up @@ -73,7 +71,7 @@ defineExpose({

<style scoped>
div {
&.isPreview {
&.output-area {
&:deep(.lm-Widget.p-Widget.jp-OutputPrompt.jp-OutputArea-prompt) {
display: none;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Editor v-else v-model="editorContent" />
</AccordionTab>
<AccordionTab header="Diagram">
<tera-model-diagram :model="model" :mmt-data="mmtData" :feature-config="featureConfig" />
<tera-model-diagram :model="model" :mmt-data="mmtData" />
</AccordionTab>
<AccordionTab header="Model equations">
<tera-model-equation :model="model" :is-editable="false" @model-updated="emit('update-model')" />
Expand All @@ -29,7 +29,6 @@ import AccordionTab from 'primevue/accordiontab';
import Column from 'primevue/column';
import DataTable from 'primevue/datatable';
import Editor from 'primevue/editor';
import { FeatureConfig } from '@/types/common';
import type { Dataset, Model } from '@/types/Types';
import TeraModelDiagram from '@/components/model/petrinet/tera-model-diagram.vue';
import TeraModelEquation from '@/components/model/petrinet/tera-model-equation.vue';
Expand All @@ -41,7 +40,6 @@ import type { MMT } from '@/model-representation/mira/mira-common';
const props = defineProps<{
model: Model;
mmtData: MMT;
featureConfig?: FeatureConfig;
isGeneratingCard?: boolean;
}>();
Expand Down
23 changes: 5 additions & 18 deletions packages/client/hmi-client/src/components/model/tera-model.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<template>
<tera-asset
v-bind="$attrs"
:feature-config="featureConfig"
:id="assetId"
:is-loading="isModelLoading"
:is-naming-asset="isNaming"
:name="temporaryModel?.header.name"
@close-preview="emit('close-preview')"
:show-table-of-contents="!isWorkflow"
>
<template #name-input>
Expand All @@ -29,7 +27,7 @@
/>
</div>
</template>
<template #edit-buttons v-if="!featureConfig.isPreview">
<template #edit-buttons>
<Button icon="pi pi-ellipsis-v" text rounded @click="toggleOptionsMenu" />
<ContextMenu ref="optionsMenu" :model="optionsMenuItems" popup :pt="optionsMenuPt" />
<aside class="btn-group">
Expand All @@ -48,17 +46,12 @@
</aside>
</template>
<section v-if="temporaryModel && mmtData">
<tera-model-description
:feature-config="featureConfig"
:model="temporaryModel"
:mmt-data="mmtData"
@update-model="updateTemporaryModel"
/>
<tera-model-description :model="temporaryModel" :mmt-data="mmtData" @update-model="updateTemporaryModel" />
<tera-petrinet-parts
:model="temporaryModel"
:mmt="mmtData.mmt"
:mmt-params="mmtData.template_params"
:feature-config="featureConfig"
:feature-config="{ isPreview: false }"
@update-state="(e: any) => onUpdateModelPart('state', e)"
@update-parameter="(e: any) => onUpdateModelPart('parameter', e)"
@update-observable="(e: any) => onUpdateModelPart('observable', e)"
Expand All @@ -81,7 +74,7 @@
</template>

<script setup lang="ts">
import { computed, PropType, ref, watch, onMounted } from 'vue';
import { computed, ref, watch, onMounted } from 'vue';
import { cloneDeep, isEmpty, isEqual } from 'lodash';
import Button from 'primevue/button';
import ContextMenu from 'primevue/contextmenu';
Expand All @@ -92,7 +85,6 @@ import TeraModelDescription from '@/components/model/petrinet/tera-model-descrip
import TeraPetrinetParts from '@/components/model/petrinet/tera-petrinet-parts.vue';
import TeraSaveAssetModal from '@/components/project/tera-save-asset-modal.vue';
import { getModel, updateModel, getMMT } from '@/services/model';
import type { FeatureConfig } from '@/types/common';
import { AssetType, type Model } from '@/types/Types';
import { useProjects } from '@/composables/project';
import { logger } from '@/utils/logger';
Expand All @@ -110,10 +102,6 @@ const props = defineProps({
type: String,
default: ''
},
featureConfig: {
type: Object as PropType<FeatureConfig>,
default: { isPreview: false } as FeatureConfig
},
isWorkflow: {
type: Boolean,
default: false
Expand All @@ -124,7 +112,7 @@ const props = defineProps({
}
});
const emit = defineEmits(['close-preview', 'on-save']);
const emit = defineEmits(['on-save']);
const model = ref<Model | null>(null);
const temporaryModel = ref<Model | null>(null);
Expand Down Expand Up @@ -188,7 +176,6 @@ const optionsMenuItems = ref<any[]>([
a.click();
a.remove();
}
emit('close-preview');
}
}
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
v-for="m in node.state.selectedOutputs?.[0]?.messages ?? []"
:key="m.header.msg_id"
:jupyter-message="m"
:feature-config="{ isPreview: true }"
/>
<Button label="Edit" @click="emit('open-drilldown')" severity="secondary" outlined />
</template>
Expand Down

0 comments on commit b1aa592

Please sign in to comment.