Skip to content

Commit

Permalink
show v1.x warning only when opening v1.x diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
jgadsden committed Jul 6, 2024
2 parents 563ba53 + 70f70e6 commit 04ca527
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion td.server/src/repositories/gitlabrepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const getClient = (accessToken) => {
return GitlabClientWrapper.getClient(clientOptions.auth);
};

export const reposAsync = (page, accessToken) => searchAsync(page, accessToken, undefined)
export const reposAsync = (page, accessToken) => searchAsync(page, accessToken, undefined);

export const getPagination = (paginationInfo, page) => {
const pagination = {page, next: false, prev: false};
Expand Down
1 change: 0 additions & 1 deletion td.vue/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default {
}),
mounted() {
this.$store.dispatch(LOADER_FINISHED);
this.$toast.warning(this.$t('nav.v2Warning'), { timeout: false });
}
};
</script>
10 changes: 2 additions & 8 deletions td.vue/src/service/migration/diagram.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/**
* @name diagram
* @description Reads an existing v1 diagram to create components for the v2 UI
* This is not for persistence, and is done on a diagram by diagram basis
*/

import cells from './cells.js';
import dataChanged from '@/service/x6/graph/data-changed.js';
import graphFactory from '@/service/x6/graph/graph.js';
Expand Down Expand Up @@ -42,10 +36,10 @@ const upgradeAndDraw = (diagram, graph) => {

const drawGraph = (diagram, graph) => {
if (diagram.version && diagram.version.startsWith('2.')) {
console.debug('open version 2.x diagram');
console.debug('open version 2.x diagram');
graph.fromJSON(diagram);
} else {
console.debug('upgrade version 1.x diagram');
console.debug('upgrade version 1.x diagram');
upgradeAndDraw(diagram, graph);
}
return graph;
Expand Down
4 changes: 4 additions & 0 deletions td.vue/src/service/schema/ajv.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import Ajv from 'ajv';
import Vue from 'vue';
import i18n from '@/i18n/index.js';

import { schema } from './threat-model-schema';
import { schema as schemaV2 } from './threat-model-schema.V2';
import { schema as schemaOTM } from './open-threat-model-schema';
Expand All @@ -20,6 +23,7 @@ export const isValidSchema = (jsonFile) => {
valid = validate(jsonFile);
if (valid) {
console.debug('Schema validate success for V1.x model');
Vue.$toast.warning(i18n.get().t('nav.v2Warning'), { timeout: false });
return true;
}

Expand Down
2 changes: 0 additions & 2 deletions td.vue/tests/e2e/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ beforeEach(() => {
cy.visit('/', {
onBeforeLoad: (win) => win.sessionStorage.clear()
});
cy.get('.Vue-Toastification__toast--warning').should('be.visible');
cy.get('.Vue-Toastification__close-button').click();
cy.get('#local-login-btn').should('be.visible');
});
12 changes: 2 additions & 10 deletions td.vue/tests/unit/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ import { LOADER_FINISHED } from '@/store/actions/loader.js';
import Navbar from '@/components/Navbar.vue';

describe('App.vue', () => {
let wrapper, localVue, mockStore, mockToast;
let wrapper, localVue, mockStore;

beforeEach(() => {
console.log = jest.fn();
mockToast = {
warning: jest.fn()
};
localVue = createLocalVue();
localVue.use(BootstrapVue);
localVue.use(Vuex);
Expand All @@ -36,8 +33,7 @@ describe('App.vue', () => {
stubs: ['router-view'],
store: mockStore,
mocks: {
$t: key => key,
$toast: mockToast
$t: key => key
}
});
});
Expand All @@ -53,8 +49,4 @@ describe('App.vue', () => {
it('has a b-container', () => {
expect(wrapper.findComponent(BContainer).exists()).toBe(true);
});

it('shows a warning toast for v2', () => {
expect(mockToast.warning).toHaveBeenCalled();
});
});

0 comments on commit 04ca527

Please sign in to comment.