Commit 22078f8a authored by Enrique Alcantara's avatar Enrique Alcantara

Migrate isSupportedContent to Apollo

Use VueApollo to handle the isSupportedContent
business logic
parent bac995be
extend type Query {
isSupportedContent: Boolean!
projectId: String!
project: String!
returnUrl: String
sourcePath: String!
username: String!
......
......@@ -6,7 +6,14 @@ import createRouter from './router';
import createApolloProvider from './graphql';
const initStaticSiteEditor = el => {
const { isSupportedContent, projectId, path: sourcePath, baseUrl } = el.dataset;
const {
isSupportedContent,
projectId,
path: sourcePath,
baseUrl,
namespace,
project,
} = el.dataset;
const { current_username: username } = window.gon;
const returnUrl = el.dataset.returnUrl || null;
......@@ -22,7 +29,7 @@ const initStaticSiteEditor = el => {
const router = createRouter(baseUrl);
const apolloProvider = createApolloProvider({
isSupportedContent: parseBoolean(isSupportedContent),
projectId,
project: `${namespace}/${project}`,
returnUrl,
sourcePath,
username,
......
......@@ -11,6 +11,8 @@ import PublishToolbar from '../components/publish_toolbar.vue';
import InvalidContentMessage from '../components/invalid_content_message.vue';
import SubmitChangesError from '../components/submit_changes_error.vue';
import appDataQuery from '../graphql/queries/app_data.query.graphql';
export default {
components: {
RichContentEditor,
......@@ -23,13 +25,17 @@ export default {
SubmitChangesError,
},
mixins: [glFeatureFlagsMixin()],
apollo: {
isSupportedContent: {
query: appDataQuery,
},
},
computed: {
...mapState([
'content',
'isLoadingContent',
'isSavingChanges',
'isContentLoaded',
'isSupportedContent',
'returnUrl',
'title',
'submitChangesError',
......
......@@ -6,7 +6,6 @@ const createState = (initialState = {}) => ({
isLoadingContent: false,
isSavingChanges: false,
isSupportedContent: false,
isContentLoaded: false,
......
......@@ -40,7 +40,6 @@ describe('static_site_editor/pages/home', () => {
store = new Vuex.Store({
state: createState({
isSupportedContent: true,
...initialState,
}),
getters: {
......@@ -67,13 +66,16 @@ describe('static_site_editor/pages/home', () => {
});
};
const buildWrapper = () => {
const buildWrapper = (data = { isSupportedContent: true }) => {
wrapper = shallowMount(Home, {
localVue,
store,
provide: {
glFeatures: { richContentEditor: true },
},
data() {
return data;
},
});
};
......@@ -194,8 +196,7 @@ describe('static_site_editor/pages/home', () => {
});
it('displays invalid content message when content is not supported', () => {
buildStore({ initialState: { isSupportedContent: false } });
buildWrapper();
buildWrapper({ isSupportedContent: false });
expect(findInvalidContentMessage().exists()).toBe(true);
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment