Show warning when exporting empty data
Summary: Shows warning when requiredplugin has empty data. It also makes the validation box as an error one, to distinguish between the two boxes. Reviewed By: passy Differential Revision: D19704910 fbshipit-source-id: ffd9413c3cd65c09f8b6019889191decefa6b6f6
This commit is contained in:
committed by
Facebook Github Bot
parent
959457d1e7
commit
8b7b911637
@@ -19,8 +19,12 @@ import {addStatusMessage, removeStatusMessage} from './application';
|
|||||||
import constants from '../fb-stubs/constants';
|
import constants from '../fb-stubs/constants';
|
||||||
import {getInstance} from '../fb-stubs/Logger';
|
import {getInstance} from '../fb-stubs/Logger';
|
||||||
import {logPlatformSuccessRate} from '../utils/metrics';
|
import {logPlatformSuccessRate} from '../utils/metrics';
|
||||||
|
import {getActivePersistentPlugins} from '../utils/pluginUtils';
|
||||||
export const SUPPORT_FORM_PREFIX = 'support-form-v2';
|
export const SUPPORT_FORM_PREFIX = 'support-form-v2';
|
||||||
|
import {State as PluginStatesState} from './pluginStates';
|
||||||
|
import {State as PluginsState} from '../reducers/plugins';
|
||||||
|
import {State as PluginMessageQueueState} from '../reducers/pluginMessageQueue';
|
||||||
|
import Client from '../Client';
|
||||||
|
|
||||||
const {
|
const {
|
||||||
GRAPHQL_IOS_SUPPORT_GROUP_ID,
|
GRAPHQL_IOS_SUPPORT_GROUP_ID,
|
||||||
@@ -177,6 +181,40 @@ export class Group {
|
|||||||
: {kind: 'success'},
|
: {kind: 'success'},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getWarningMessage(
|
||||||
|
plugins: PluginsState,
|
||||||
|
pluginsState: PluginStatesState,
|
||||||
|
pluginsMessageQueue: PluginMessageQueueState,
|
||||||
|
client: Client,
|
||||||
|
): string | null {
|
||||||
|
const activePersistentPlugins = getActivePersistentPlugins(
|
||||||
|
pluginsState,
|
||||||
|
pluginsMessageQueue,
|
||||||
|
plugins,
|
||||||
|
client,
|
||||||
|
);
|
||||||
|
const emptyPlugins: Array<string> = [];
|
||||||
|
for (const plugin of this.requiredPlugins) {
|
||||||
|
if (
|
||||||
|
!activePersistentPlugins.find(o => {
|
||||||
|
return o.id === plugin;
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
emptyPlugins.push(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const commonStr = 'Are you sure you want to submit?';
|
||||||
|
if (emptyPlugins.length == 1) {
|
||||||
|
return `There is no data in ${emptyPlugins.pop()} plugin. ${commonStr}`;
|
||||||
|
} else if (emptyPlugins.length > 1) {
|
||||||
|
return `The following plugins have no data: ${emptyPlugins.join(
|
||||||
|
',',
|
||||||
|
)}. ${commonStr}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type GroupNames =
|
export type GroupNames =
|
||||||
|
|||||||
Reference in New Issue
Block a user