Skip to content

Commit 5b32c5f

Browse files
authored
Merge pull request #1999 from microsoftgraph/docs/add-version-info
docs: adds version information to storybook
2 parents c9e252d + 80d91b6 commit 5b32c5f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+255
-42
lines changed

.github/workflows/pr-storybook.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,25 @@ jobs:
2525
node-version: ${{ matrix.node-version }}
2626
registry-url: 'https://registry.npmjs.org'
2727

28-
- name: Build 🛠
28+
- name: Install deps 🛠
2929
run: |
3030
npm install -g yarn lerna
3131
yarn
32+
- name: Extract tag name
33+
shell: bash
34+
run: |
35+
tag=$(branch=${{ github.event.pull_request.head.ref }}; echo ${branch/\//.})
36+
if [[ $tag == next.* ]];
37+
then
38+
echo "##[set-output name=tag;]$tag"
39+
else
40+
echo "##[set-output name=tag;]pr.${{ github.event.pull_request.number }}"
41+
fi
42+
id: extract_tag
43+
- run: node scripts/setVersion.js --tag ${{ steps.extract_tag.outputs.tag }}
44+
45+
- name: Build 🛠
46+
run: |
3247
yarn build
3348
yarn storybook:build
3449

.storybook/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = {
1818
],
1919
stories: ['../stories/overview.stories.mdx', '../stories/**/*.@(js|mdx)'],
2020
addons: [
21+
'storybook-version',
2122
'@storybook/addon-docs'
2223
// '@storybook/addon-a11y/register',
2324
// '@storybook/addon-actions/register',

.storybook/manager-head.html

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
</script>
77

88
<footer class="storybook-footer">
9-
Microsoft Graph Toolkit Playground was founded by Microsoft as a community guided, open source project.
9+
Microsoft Graph Toolkit (v<span id="mgt-version"></span>) Playground was founded by Microsoft as a community guided,
10+
open source project.
1011
<a tabindex="-1" href="https://privacy.microsoft.com/en-us/privacystatement">Privacy & cookies</a>
1112
<a tabindex="-1" href="https://www.microsoft.com/en-us/legal/intellectualproperty/copyright/default">Term of use</a>
1213
</footer>
14+
<script type="module">
15+
import { PACKAGE_VERSION } from './mgt.storybook.js'
16+
document.getElementById('mgt-version').innerText = PACKAGE_VERSION;
17+
</script>
1318

1419
<script src="https://consentdeliveryfd.azurefd.net/mscc/lib/v2/wcp-consent.js"></script>
1520
<script src="https://az725175.vo.msecnd.net/scripts/jsll-4.js" type="text/javascript"></script>
@@ -309,11 +314,26 @@
309314
</style>
310315

311316
<style>
317+
318+
/* don't show the footer on mobile */
319+
@media (max-width: 599px) {
320+
.storybook-footer {
321+
display: none !important;
322+
}
323+
}
324+
312325
/* this keeps the storybook body area above footer */
313-
#root>div:first-of-type {
314-
height: calc(100% - 40px);
326+
@media (max-width: 768px) {
327+
#root>div:first-of-type {
328+
height: calc(100% - 50px);
329+
}
315330
}
316331

332+
@media (min-width: 769px) {
333+
#root>div:first-of-type {
334+
height: calc(100% - 40px);
335+
}
336+
}
317337
.sidebar-header button {
318338
display: none !important;
319339
}
@@ -341,12 +361,6 @@
341361
color: #717171 !important;
342362
}
343363

344-
@media (max-width: 768px) {
345-
#root>div:first-of-type {
346-
height: calc(100% - 50px);
347-
}
348-
}
349-
350364
.sidebar-header h1 {
351365
font-size: 14px;
352366
font-weight: 700;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
"sass": "^1.29.0",
114114
"shx": "^0.3.3",
115115
"storybook-addon-web-components-knobs": "^0.3.20",
116+
"storybook-version": "^0.1.1",
116117
"ts-jest": "^26.5.5",
117118
"tslint": "^6.1.3",
118119
"tslint-config-prettier": "^1.18.0",

packages/mgt-element/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export * from './utils/TemplateContext';
2727
export * from './utils/TemplateHelper';
2828
export * from './utils/GraphPageIterator';
2929
export * from './utils/LocalizationHelper';
30+
export { PACKAGE_VERSION } from './utils/version';
3031

3132
export * from './mock/MockProvider';
3233
export * from './mock/mgt-mock-provider';

scripts/setVersion.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
var child_process = require('child_process')
1+
var child_process = require('child_process');
22
var path = require('path');
33
var fs = require('fs');
44
var project = require('../package.json');
55

6-
const ignoreDirs = ['node_modules'];
6+
const ignoreDirs = ['node_modules', 'samples'];
77

88
const getFiles = (filter, startPath = 'packages') => {
99
let results = [];
@@ -25,30 +25,30 @@ const getFiles = (filter, startPath = 'packages') => {
2525
}
2626

2727
return results;
28-
}
28+
};
2929

3030
const updateMgtDependencyVersion = (packages, version) => {
3131
for (let package of packages) {
32-
console.log(`updating package ${package} with version ${version}`)
32+
console.log(`updating package ${package} with version ${version}`);
3333
const data = fs.readFileSync(package, 'utf8');
3434

3535
var result = data.replace(/"(@microsoft\/mgt.*)": "(\*)"/g, `"$1": "${version}"`);
3636
result = result.replace(/"version": "(.*)"/g, `"version": "${version}"`);
3737

3838
fs.writeFileSync(package, result, 'utf8');
3939
}
40-
}
40+
};
4141

4242
const updateSpfxSolutionVersion = (solutions, version) => {
4343
for (let solution of solutions) {
44-
console.log(`updating spfx solution ${solution} with version ${version}`)
44+
console.log(`updating spfx solution ${solution} with version ${version}`);
4545
const data = fs.readFileSync(solution, 'utf8');
4646

4747
var result = data.replace(/"version": "(.*)"/g, `"version": "${version}.0"`);
4848

4949
fs.writeFileSync(solution, result, 'utf8');
5050
}
51-
}
51+
};
5252

5353
let version = project.version;
5454

@@ -83,8 +83,8 @@ if (process.argv.length > 2) {
8383
return;
8484
}
8585
}
86-
87-
const packages = getFiles('package.json');
86+
// include update to the root package.json
87+
const packages = getFiles('package.json', '.');
8888
updateMgtDependencyVersion(packages, version);
8989

9090
const spfxSolutions = getFiles('package-solution.json');

stories/components/agenda/agenda.a.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77

88
import { html } from 'lit-element';
99
import { withCodeEditor } from '../../../.storybook/addons/codeEditorAddon/codeAddon';
10+
import { versionInfo } from '../../versionInfo';
1011

1112
export default {
13+
parameters: {
14+
version: versionInfo
15+
},
1216
title: 'Components / mgt-agenda',
1317
component: 'mgt-agenda',
1418
decorators: [withCodeEditor]

stories/components/agenda/agenda.properties.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77

88
import { html } from 'lit-element';
99
import { withCodeEditor } from '../../../.storybook/addons/codeEditorAddon/codeAddon';
10+
import { versionInfo } from '../../versionInfo';
1011

1112
export default {
13+
parameters: {
14+
version: versionInfo
15+
},
1216
title: 'Components / mgt-agenda / Properties',
1317
component: 'mgt-agenda',
1418
decorators: [withCodeEditor]
@@ -37,4 +41,3 @@ export const getEventsForNextWeek = () => html`
3741
export const preferredTimezone = () => html`
3842
<mgt-agenda preferred-timezone="Europe/Paris"></mgt-agenda>
3943
`;
40-

stories/components/agenda/agenda.style.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77

88
import { html } from 'lit-element';
99
import { withCodeEditor } from '../../../.storybook/addons/codeEditorAddon/codeAddon';
10+
import { versionInfo } from '../../versionInfo';
1011

1112
export default {
13+
parameters: {
14+
version: versionInfo
15+
},
1216
title: 'Components / mgt-agenda / Style',
1317
component: 'mgt-agenda',
1418
decorators: [withCodeEditor]

stories/components/agenda/agenda.templating.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77

88
import { html } from 'lit-element';
99
import { withCodeEditor } from '../../../.storybook/addons/codeEditorAddon/codeAddon';
10+
import { versionInfo } from '../../versionInfo';
1011

1112
export default {
13+
parameters: {
14+
version: versionInfo
15+
},
1216
title: 'Components / mgt-agenda / Templating',
1317
component: 'mgt-agenda',
1418
decorators: [withCodeEditor]
@@ -261,4 +265,3 @@ export const header = () => html`
261265
</template>
262266
</mgt-agenda>
263267
`;
264-

0 commit comments

Comments
 (0)