Skip to content

Commit cfeb59c

Browse files
mportiz08anferbui
authored andcommitted
Render availability items without version range details (#891)
Resolves: rdar://135420580
1 parent b14e61a commit cfeb59c

File tree

6 files changed

+59
-18
lines changed

6 files changed

+59
-18
lines changed

src/components/DocumentationTopic/Summary/AvailabilityRange.vue

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default {
2626
},
2727
introducedAt: {
2828
type: String,
29-
required: true,
29+
required: false,
3030
},
3131
platformName: {
3232
type: String,
@@ -51,23 +51,38 @@ export default {
5151
introducedAt,
5252
platformName: name,
5353
} = this;
54-
return deprecatedAt ? (
55-
this.$t('availability.introduced-and-deprecated', { name, introducedAt, deprecatedAt })
56-
) : (
57-
this.$t('availability.available-on', { name, introducedAt })
58-
);
54+
if (introducedAt && deprecatedAt) {
55+
return this.$t('availability.introduced-and-deprecated', {
56+
name,
57+
introducedAt,
58+
deprecatedAt,
59+
});
60+
}
61+
62+
if (introducedAt) {
63+
return this.$t('availability.available-on-platform-version', {
64+
name,
65+
introducedAt,
66+
});
67+
}
68+
69+
return this.$t('availability.available-on-platform', { name });
5970
},
6071
text() {
6172
const {
6273
deprecatedAt,
6374
introducedAt,
6475
platformName: name,
6576
} = this;
66-
return deprecatedAt ? (
67-
`${name} ${introducedAt}\u2013${deprecatedAt}`
68-
) : (
69-
`${name} ${introducedAt}+`
70-
);
77+
if (introducedAt && deprecatedAt) {
78+
return `${name} ${introducedAt}\u2013${deprecatedAt}`;
79+
}
80+
81+
if (introducedAt) {
82+
return `${name} ${introducedAt}+`;
83+
}
84+
85+
return name;
7186
},
7287
},
7388
};

src/lang/locales/en-US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@
124124
},
125125
"availability": {
126126
"introduced-and-deprecated": "Introduced in {name} {introducedAt} and deprecated in {name} {deprecatedAt}",
127-
"available-on": "Available on {name} {introducedAt} and later"
127+
"available-on-platform": "Available on {name}",
128+
"available-on-platform-version": "Available on {name} {introducedAt} and later"
128129
},
129130
"more": "More",
130131
"less": "Less",

src/lang/locales/ja-JP.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
},
124124
"availability": {
125125
"introduced-and-deprecated": "{name} {introducedAt}で導入され、{name} {deprecatedAt}で非推奨になりました",
126-
"available-on": "{name} {introducedAt}以降で使用できます"
126+
"available-on-platform-version": "{name} {introducedAt}以降で使用できます"
127127
},
128128
"more": "さらに表示",
129129
"less": "表示を減らす",

src/lang/locales/ko-KR.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
},
124124
"availability": {
125125
"introduced-and-deprecated": "{name} {introducedAt}에서 소개되었고 {name} {deprecatedAt}에서 제거됨",
126-
"available-on": "{name} {introducedAt} 이상에서 사용할 수 있음"
126+
"available-on-platform-version": "{name} {introducedAt} 이상에서 사용할 수 있음"
127127
},
128128
"more": "더 보기",
129129
"less": "간략히",

src/lang/locales/zh-CN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
},
124124
"availability": {
125125
"introduced-and-deprecated": "{name} {introducedAt} 中引入,{name} {deprecatedAt} 中弃用",
126-
"available-on": "{name} {introducedAt} 及更高版本中可用"
126+
"available-on-platform-version": "{name} {introducedAt} 及更高版本中可用"
127127
},
128128
"more": "更多",
129129
"less": "更少",

tests/unit/components/DocumentationTopic/Summary/AvailabilityRange.spec.js

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,45 @@ describe('AvailabilityRange', () => {
3434

3535
wrapper.setProps({ deprecatedAt });
3636
expect(wrapper.text()).toBe('fooOS 1.0\u20132.0');
37+
38+
wrapper.setProps({
39+
...propsData,
40+
deprecatedAt: null,
41+
introducedAt: null,
42+
});
43+
expect(wrapper.text()).toBe('fooOS');
3744
});
3845

3946
it('renders a descriptive title attribute', () => {
40-
expect(wrapper.attributes('title')).toBe('availability.available-on fooOS 1.0');
47+
expect(wrapper.attributes('title'))
48+
.toBe('availability.available-on-platform-version fooOS 1.0');
4149

4250
wrapper.setProps({ deprecatedAt });
43-
expect(wrapper.attributes('title')).toBe('availability.introduced-and-deprecated fooOS 1.0 2.0');
51+
expect(wrapper.attributes('title'))
52+
.toBe('availability.introduced-and-deprecated fooOS 1.0 2.0');
53+
54+
wrapper.setProps({
55+
...propsData,
56+
deprecatedAt: null,
57+
introducedAt: null,
58+
});
59+
expect(wrapper.attributes('title')).toBe('availability.available-on-platform fooOS');
4460
});
4561

4662
it('renders an aria label with the description (prepended with short text)', () => {
47-
expect(wrapper.attributes('aria-label')).toBe('fooOS 1.0+, availability.available-on fooOS 1.0');
63+
expect(wrapper.attributes('aria-label'))
64+
.toBe('fooOS 1.0+, availability.available-on-platform-version fooOS 1.0');
4865

4966
wrapper.setProps({ deprecatedAt });
5067
expect(wrapper.attributes('aria-label'))
5168
.toBe('fooOS 1.0\u20132.0, change-type.deprecated, availability.introduced-and-deprecated fooOS 1.0 2.0');
69+
70+
wrapper.setProps({
71+
...propsData,
72+
deprecatedAt: null,
73+
introducedAt: null,
74+
});
75+
expect(wrapper.attributes('aria-label'))
76+
.toBe('fooOS, availability.available-on-platform fooOS');
5277
});
5378
});

0 commit comments

Comments
 (0)