Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.js « extensions « components « vue_merge_request_widget « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2bfaec8a1c9d072946e1e8bf84382efba5772243 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import ExtensionBase from './base.vue';

// Holds all the currently registered extensions
export const extensions = [];

export const registerExtension = extension => {
  // Pushes into the extenions array a dynamically created Vue component
  // that gets exteneded from `base.vue`
  extensions.push({
    extends: ExtensionBase,
    name: extension.name,
    props: extension.props,
    computed: {
      ...Object.keys(extension.computed).reduce(
        (acc, computedKey) => ({
          ...acc,
          // Making the computed property a method allows us to pass in arguments
          // this allows for each computed property to recieve some data
          [computedKey]() {
            return extension.computed[computedKey];
          },
        }),
        {},
      ),
    },
    methods: {
      ...extension.methods,
    },
  });
};