Commit 77355dfa authored by Kushal Pandya's avatar Kushal Pandya

Handle null start or due dates for sourcing milestone

parent bd0ecc71
...@@ -260,14 +260,26 @@ export default { ...@@ -260,14 +260,26 @@ export default {
: this.dueDateSourcingMilestoneDates; : this.dueDateSourcingMilestoneDates;
if (startDateTimeFromMilestones && dueDateTimeFromMilestones) { if (startDateTimeFromMilestones && dueDateTimeFromMilestones) {
const startDate = parsePikadayDate(sourcingMilestoneDates.startDate); const { startDate, dueDate } = sourcingMilestoneDates;
const dueDate = parsePikadayDate(sourcingMilestoneDates.dueDate); let startDateInWords = __('No start date');
let dueDateInWords = __('No due date');
return `${dateSourcingMilestoneTitle}<br/><span class="text-tertiary">${dateInWords( if (startDate && dueDate) {
startDate, const startDateObj = parsePikadayDate(startDate);
true, const dueDateObj = parsePikadayDate(dueDate);
startDate.getFullYear() === dueDate.getFullYear(), startDateInWords = dateInWords(
)}${dateInWords(dueDate, true)}</span>`; startDateObj,
true,
startDateObj.getFullYear() === dueDateObj.getFullYear(),
);
dueDateInWords = dateInWords(dueDateObj, true);
} else if (startDate && !dueDate) {
startDateInWords = dateInWords(parsePikadayDate(startDate), true);
} else {
dueDateInWords = dateInWords(parsePikadayDate(dueDate), true);
}
return `${dateSourcingMilestoneTitle}<br/><span class="text-tertiary">${startDateInWords}${dueDateInWords}</span>`;
} }
return sprintf( return sprintf(
...@@ -449,7 +461,7 @@ export default { ...@@ -449,7 +461,7 @@ export default {
> >
<div class="issuable-sidebar js-issuable-update"> <div class="issuable-sidebar js-issuable-update">
<div class="block issuable-sidebar-header"> <div class="block issuable-sidebar-header">
<span class="issuable-header-text hide-collapsed float-left"> {{ __('Todo') }} </span> <span class="issuable-header-text hide-collapsed float-left">{{ __('Todo') }}</span>
<toggle-sidebar :collapsed="collapsed" css-classes="float-right" @toggle="toggleSidebar" /> <toggle-sidebar :collapsed="collapsed" css-classes="float-right" @toggle="toggleSidebar" />
<sidebar-todo <sidebar-todo
v-if="!collapsed" v-if="!collapsed"
...@@ -535,9 +547,8 @@ export default { ...@@ -535,9 +547,8 @@ export default {
@onLabelClick="handleLabelClick" @onLabelClick="handleLabelClick"
@onDropdownClose="handleDropdownClose" @onDropdownClose="handleDropdownClose"
@toggleCollapse="toggleSidebarRevealLabelsDropdown" @toggleCollapse="toggleSidebarRevealLabelsDropdown"
>{{ __('None') }}</sidebar-labels-select
> >
{{ __('None') }}
</sidebar-labels-select>
<sidebar-participants :participants="initialParticipants" @toggleCollapse="toggleSidebar" /> <sidebar-participants :participants="initialParticipants" @toggleCollapse="toggleSidebar" />
<sidebar-subscriptions <sidebar-subscriptions
:loading="savingSubscription" :loading="savingSubscription"
......
...@@ -240,6 +240,58 @@ describe('epicSidebar', () => { ...@@ -240,6 +240,58 @@ describe('epicSidebar', () => {
vmDatesFromMilestones.$destroy(); vmDatesFromMilestones.$destroy();
}); });
it('returns tooltip string containing `No due date` when dueDate from dates sourcing milestone is missing', () => {
const startDate = '2018-01-01';
const dueDate = '2018-03-31';
const vmMissingDueDate = mountComponent(
EpicSidebar,
Object.assign({}, defaultPropsData, {
startDateSourcingMilestoneDates: {
startDate,
dueDate: null,
},
dueDateSourcingMilestoneDates: {
startDate,
dueDate,
},
startDateFromMilestones: startDate,
dueDateFromMilestones: dueDate,
}),
);
expect(vmMissingDueDate.getDateFromMilestonesTooltip('start')).toBe(
'Milestone for Start Date<br/><span class="text-tertiary">Jan 1, 2018 – No due date</span>',
);
vmMissingDueDate.$destroy();
});
it('returns tooltip string containing `No start date` when startDate from dates sourcing milestone is missing', () => {
const startDate = '2018-01-01';
const dueDate = '2018-03-31';
const vmMissingStartDate = mountComponent(
EpicSidebar,
Object.assign({}, defaultPropsData, {
startDateSourcingMilestoneDates: {
startDate: null,
dueDate,
},
dueDateSourcingMilestoneDates: {
startDate,
dueDate,
},
startDateFromMilestones: startDate,
dueDateFromMilestones: dueDate,
}),
);
expect(vmMissingStartDate.getDateFromMilestonesTooltip('start')).toBe(
'Milestone for Start Date<br/><span class="text-tertiary">No start date – Mar 31, 2018</span>',
);
vmMissingStartDate.$destroy();
});
}); });
describe('toggleSidebar', () => { describe('toggleSidebar', () => {
......
...@@ -5732,6 +5732,9 @@ msgstr "" ...@@ -5732,6 +5732,9 @@ msgstr ""
msgid "No schedules" msgid "No schedules"
msgstr "" msgstr ""
msgid "No start date"
msgstr ""
msgid "No, directly import the existing email addresses and usernames." msgid "No, directly import the existing email addresses and usernames."
msgstr "" msgstr ""
......
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