[DASHBOARDS] Dashboard duplication (#16291)
## Description - Created a Dashboard duplication action - Created a new duplication custom resolver - Created the service using the v2 of the API - Created the integration tests following the v2 methodology ## Video QA https://github.com/user-attachments/assets/e409951a-5946-4da0-91a0-1f7d2ecadb08
This commit is contained in:
@@ -103,6 +103,7 @@ export { removeUndefinedFields } from './removeUndefinedFields';
|
||||
export { safeParseRelativeDateFilterJSONStringified } from './safeParseRelativeDateFilterJSONStringified';
|
||||
export { getGenericOperationName } from './sentry/getGenericOperationName';
|
||||
export { getHumanReadableNameFromCode } from './sentry/getHumanReadableNameFromCode';
|
||||
export { appendCopySuffix } from './strings/appendCopySuffix';
|
||||
export { capitalize } from './strings/capitalize';
|
||||
export { uncapitalize } from './strings/uncapitalize';
|
||||
export type {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { appendCopySuffix } from '@/utils/strings/appendCopySuffix';
|
||||
|
||||
describe('appendCopySuffix', () => {
|
||||
it('should add (Copy) suffix to a string', () => {
|
||||
expect(appendCopySuffix('My Dashboard')).toBe('My Dashboard (Copy)');
|
||||
});
|
||||
|
||||
it('should not add (Copy) suffix if string already ends with (Copy)', () => {
|
||||
expect(appendCopySuffix('My Dashboard (Copy)')).toBe('My Dashboard (Copy)');
|
||||
});
|
||||
|
||||
it('should not add (Copy) suffix if string ends with (copy) - case insensitive', () => {
|
||||
expect(appendCopySuffix('My Dashboard (copy)')).toBe('My Dashboard (copy)');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
|
||||
const COPY_SUFFIX = '(Copy)';
|
||||
const COPY_SUFFIX_LOWERCASE = '(copy)';
|
||||
|
||||
export const appendCopySuffix = (value: string): string => {
|
||||
if (!isNonEmptyString(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (value.toLowerCase().endsWith(COPY_SUFFIX_LOWERCASE)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return `${value} ${COPY_SUFFIX}`;
|
||||
};
|
||||
@@ -1 +1,2 @@
|
||||
export * from './appendCopySuffix';
|
||||
export * from './capitalize';
|
||||
|
||||
Reference in New Issue
Block a user